From 2415624fe325e4bce28e052dddb546594eabba6f Mon Sep 17 00:00:00 2001 From: Gregory Giguashvili Date: Mon, 13 Feb 2023 20:39:24 +0200 Subject: [PATCH] Fix image builder scripts to run on RHEL 9 --- docs/rhel4edge_iso.md | 7 +++---- scripts/devenv-builder/configure-vm.sh | 0 scripts/image-builder/build.sh | 12 +++++++----- scripts/image-builder/config/kickstart.ks.template | 2 +- scripts/image-builder/configure.sh | 4 +++- 5 files changed, 14 insertions(+), 11 deletions(-) mode change 100644 => 100755 scripts/devenv-builder/configure-vm.sh diff --git a/docs/rhel4edge_iso.md b/docs/rhel4edge_iso.md index c049f8dfdc..787cdac7a3 100644 --- a/docs/rhel4edge_iso.md +++ b/docs/rhel4edge_iso.md @@ -3,7 +3,7 @@ To test MicroShift in a setup similar to the production environment, it is neces ## Build RHEL for Edge Installer ISO Log into the development virtual machine with the `microshift` user credentials. -> The development machine configuration guidelines can be found in the [MicroShift Development Environment.x](./devenv_setup.md) document. +> The development machine configuration guidelines can be found in the [MicroShift Development Environment](./devenv_setup.md) document. Follow the instructions in the [RPM Packages](./devenv_setup.md#rpm-packages) section to create MicroShift RPM packages. @@ -134,7 +134,7 @@ EOF > **NOTE**
> Embedding container images in the generated ISO requires the functionality from the latest version of the `rpm-ostree` package. -> This functionality will be available in the future releases of the RHEL 8 operating system. +> This functionality will be available in the future releases of the RHEL 8 and 9 operating systems. To install the necessary functionality, run the following command to upgrade your system with the up-to-date `rpm-ostree` software from the `copr` repository. ```bash @@ -168,7 +168,6 @@ sudo scp microshift@microshift-dev:/home/microshift/microshift/_output/image-bui Run the following commands to create a virtual machine using the installer image. ```bash VMNAME="microshift-edge" -VERSION=$(grep "^var Base =" ~/microshift/pkg/release/release.go | cut -d\" -f 2) sudo -b bash -c " \ cd /var/lib/libvirt/images/ && \ virt-install \ @@ -179,7 +178,7 @@ virt-install \ --network network=default,model=virtio \ --os-type generic \ --events on_reboot=restart \ - --cdrom ./microshift-installer-${VERSION}.$(uname -i).iso \ + --cdrom ./microshift-installer-*.$(uname -i).iso \ " ``` diff --git a/scripts/devenv-builder/configure-vm.sh b/scripts/devenv-builder/configure-vm.sh old mode 100644 new mode 100755 diff --git a/scripts/image-builder/build.sh b/scripts/image-builder/build.sh index 9edcec7e69..b42c478f6c 100755 --- a/scripts/image-builder/build.sh +++ b/scripts/image-builder/build.sh @@ -6,6 +6,7 @@ SCRIPTDIR=${ROOTDIR}/scripts/image-builder IMGNAME=microshift IMAGE_VERSION=$(jq -r '.release.base' assets/release/release-$(uname -i).json) BUILD_ARCH=$(uname -i) +OSVERSION=$(awk -F: '{print $5}' /etc/system-release-cpe) OSTREE_SERVER_NAME=127.0.0.1:8080 LVM_SYSROOT_SIZE_MIN=10240 LVM_SYSROOT_SIZE=${LVM_SYSROOT_SIZE_MIN} @@ -119,10 +120,10 @@ build_image() { sudo podman run -d --name=${parent_blueprint}-server -p 8080:8080 localhost/${parent_blueprint}:${parent_version} title "Building ${image_type} for ${blueprint} v${version}, parent ${parent_blueprint} v${parent_version}" - buildid=$(sudo composer-cli compose start-ostree --ref rhel/8/${BUILD_ARCH}/edge --url http://localhost:8080/repo/ ${blueprint} ${image_type} | awk '{print $2}') + buildid=$(sudo composer-cli compose start-ostree --ref rhel/${OSVERSION}/${BUILD_ARCH}/edge --url http://localhost:8080/repo/ ${blueprint} ${image_type} | awk '{print $2}') else title "Building ${image_type} for ${blueprint} v${version}" - buildid=$(sudo composer-cli compose start-ostree --ref rhel/8/${BUILD_ARCH}/edge ${blueprint} ${image_type} | awk '{print $2}') + buildid=$(sudo composer-cli compose start-ostree --ref rhel/${OSVERSION}/${BUILD_ARCH}/edge ${blueprint} ${image_type} | awk '{print $2}') fi waitfor_image ${buildid} @@ -240,10 +241,10 @@ createrepo microshift-local >/dev/null # Download openshift local RPM packages (noarch for python and selinux packages) rm -rf openshift-local 2>/dev/null || true -OCP_REPO_NAME=rhocp-4.12-for-rhel-8-${BUILD_ARCH}-rpms +OCP_REPO_NAME=rhocp-4.12-for-rhel-${OSVERSION}-${BUILD_ARCH}-rpms reposync -n -a ${BUILD_ARCH} -a noarch --download-path openshift-local \ --repo=${OCP_REPO_NAME} \ - --repo=fast-datapath-for-rhel-8-${BUILD_ARCH}-rpms >/dev/null + --repo=fast-datapath-for-rhel-${OSVERSION}-${BUILD_ARCH}-rpms >/dev/null # Remove 'coreos' packages to avoid conflicts find openshift-local -name \*coreos\* -exec rm -f {} \; @@ -305,7 +306,7 @@ fi # Add container images if ${EMBED_CONTAINERS} ; then - # TODO: This should be removed when RHEL 8.x stream gets an up-to-date package + # TODO: This should be removed when RHEL 8/9 streams gets an up-to-date package # Include up-to-date ostree packages in the image builder to support whiteouts repo_name=ostree-copr cat ${SCRIPTDIR}/config/${repo_name}.toml | sed "s;REPLACE_ARCH_VALUE;${BUILD_ARCH};g" > ${repo_name}.toml @@ -337,6 +338,7 @@ cat "${SCRIPTDIR}/config/kickstart.ks.template" \ | sed "s;REPLACE_OSTREE_SERVER_NAME;${OSTREE_SERVER_NAME};g" \ | sed "s;REPLACE_OCP_PULL_SECRET_CONTENTS;$(cat $OCP_PULL_SECRET_FILE | jq -c);g" \ | sed "s;REPLACE_REDHAT_AUTHORIZED_KEYS_CONTENTS;${AUTHORIZED_KEYS};g" \ + | sed "s;REPLACE_OSVERSION;${OSVERSION};g" \ | sed "s;REPLACE_BUILD_ARCH;${BUILD_ARCH};g" \ > kickstart.ks diff --git a/scripts/image-builder/config/kickstart.ks.template b/scripts/image-builder/config/kickstart.ks.template index d8f0b05a0f..c862b12dc8 100644 --- a/scripts/image-builder/config/kickstart.ks.template +++ b/scripts/image-builder/config/kickstart.ks.template @@ -30,7 +30,7 @@ volgroup rhel pv.01 logvol / --vgname=rhel --fstype=xfs --size=REPLACE_LVM_SYSROOT_SIZE --name=root # Configure ostree -ostreesetup --nogpg --osname=rhel --remote=edge --url=file:///run/install/repo/ostree/repo --ref=rhel/8/REPLACE_BUILD_ARCH/edge +ostreesetup --nogpg --osname=rhel --remote=edge --url=file:///run/install/repo/ostree/repo --ref=rhel/REPLACE_OSVERSION/REPLACE_BUILD_ARCH/edge %post --log=/var/log/anaconda/post-install.log --erroronfail diff --git a/scripts/image-builder/configure.sh b/scripts/image-builder/configure.sh index 95362b6cb9..0bdf0b7da6 100755 --- a/scripts/image-builder/configure.sh +++ b/scripts/image-builder/configure.sh @@ -1,6 +1,8 @@ #!/bin/bash set -exo pipefail +OSVERSION=$(awk -F: '{print $5}' /etc/system-release-cpe) + sudo dnf install -y git osbuild-composer composer-cli ostree rpm-ostree \ cockpit-composer cockpit-machines bash-completion podman genisoimage \ createrepo yum-utils selinux-policy-devel jq wget lorax rpm-build @@ -9,7 +11,7 @@ sudo systemctl enable cockpit.socket --now sudo firewall-cmd --add-service=cockpit --permanent # The mock utility comes from the EPEL repository -sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm +sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-${OSVERSION}.noarch.rpm sudo dnf install -y mock sudo usermod -a -G mock $(whoami)