@@ -16,13 +16,8 @@ SNC_CLUSTER_CPUS=${SNC_CLUSTER_CPUS:-2}
16
16
CRC_VM_DISK_SIZE=${CRC_VM_DISK_SIZE:- 31}
17
17
BASE_DOMAIN=${CRC_BASE_DOMAIN:- testing}
18
18
MIRROR=${MIRROR:- https:// mirror.openshift.com/ pub/ openshift-v4/ $ARCH / clients/ ocp-dev-preview}
19
- OPENSHIFT_MINOR_VERSION=${OPENSHIFT_MINOR_VERSION:- 4.17}
20
-
21
- if ! grep -q -i " release 9" /etc/redhat-release
22
- then
23
- echo " This script only works for RHEL-9"
24
- exit 1
25
- fi
19
+ MICROSHIFT_VERSION=${MICROSHIFT_VERSION:- 4.19}
20
+ MIRROR_REPO=${MIRROR_REPO:- https:// mirror.openshift.com/ pub/ openshift-v4/ $ARCH / microshift/ ocp-dev-preview/ latest-${MICROSHIFT_VERSION} / el9/ os}
26
21
27
22
echo " Check if system is registered"
28
23
# Check the subscription status and register if necessary
@@ -42,96 +37,28 @@ create_libvirt_resources
42
37
rm id_ecdsa_crc* || true
43
38
ssh-keygen -t ecdsa -b 521 -N " " -f id_ecdsa_crc -C " core"
44
39
45
- # This requirement is taken from https://github.com/openshift/microshift/blob/main/scripts/image-builder/configure.sh
46
- # Also https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/composing_a_customized_rhel_system_image/installing-composer_composing-a-customized-rhel-system-image
47
- # list out the dependencies and usecase.
48
- # lorax packages which install mkksiso is required for embedding kickstart file to iso file
49
- # podman package is required to run the ostree-container to serve the rpm-ostree content
50
- # createrepo package is required to create localrepo for microshift and it's dependenices
51
- # yum-utils package is required for reposync utility to synchronize packages of a remote DNF repository to a local directory
52
- function configure_host {
53
- sudo dnf install -y git osbuild-composer composer-cli ostree rpm-ostree \
54
- cockpit-composer cockpit-machines bash-completion lorax \
55
- yum-utils createrepo
56
- sudo dnf install -y podman --setopt=install_weak_deps=True
57
- sudo systemctl start osbuild-composer.socket
58
- sudo systemctl start cockpit.socket
59
- sudo firewall-cmd --add-service=cockpit
60
- }
61
-
62
- function enable_repos {
63
- local enable_repos=" --enable fast-datapath-for-rhel-9-$( uname -i) -rpms"
64
- if [ -z " ${MICROSHIFT_PRERELEASE-} " ]; then
65
- enable_repos=" ${enable_repos} --enable rhocp-${OPENSHIFT_MINOR_VERSION} -for-rhel-9-$( uname -i) -rpms"
66
- fi
67
- sudo subscription-manager repos ${enable_repos}
68
- }
69
-
70
- function download_microshift_rpm {
71
- local pkgDir=$1
72
- local extra_opts=" "
73
- local nvr_suffix=" "
74
- if [ -n " ${MICROSHIFT_PRERELEASE-} " ]; then
75
- extra_opts=" --setopt=reposdir=./repos"
76
- elif [ -n " ${MICROSHIFT_NVR-} " ]; then
77
- nvr_suffix=" -${MICROSHIFT_NVR-} "
78
- fi
79
- sudo yum download ${extra_opts} --downloaddir ${pkgDir} --downloadonly microshift${nvr_suffix} microshift-networking${nvr_suffix} \
80
- microshift-release-info${nvr_suffix} microshift-selinux${nvr_suffix} microshift-greenboot${nvr_suffix} microshift-olm${nvr_suffix} \
81
- microshift-multus${nvr_suffix}
82
- }
83
-
84
40
function create_iso {
85
- local pkgDir=$1
86
- rm -fr microshift
87
- git clone -b release-${OPENSHIFT_MINOR_VERSION} https://github.com/openshift/microshift.git
88
- cp podman_changes.ks microshift/
89
- pushd microshift
90
- sed -i ' /# customizations/,$d' scripts/image-builder/config/blueprint_v0.0.1.toml
91
- cat << EOF >> scripts/image-builder/config/blueprint_v0.0.1.toml
92
- [[packages]]
93
- name = "microshift-release-info"
94
- version = "*"
95
- [[packages]]
96
- name = "cloud-utils-growpart"
97
- version = "*"
98
- [[packages]]
99
- name = "qemu-guest-agent"
100
- version = "*"
101
- EOF
102
- sed -i ' s/redhat/core/g' scripts/image-builder/config/kickstart.ks.template
103
- sed -i " /--bootproto=dhcp/a\network --hostname=api.${SNC_PRODUCT_NAME} .${BASE_DOMAIN} " scripts/image-builder/config/kickstart.ks.template
104
- sed -i ' s/clearpart --all --initlabel/clearpart --all --disklabel gpt/g' scripts/image-builder/config/kickstart.ks.template
105
- sed -i " /clearpart --all/a\part biosboot --fstype=biosboot --size=1" scripts/image-builder/config/kickstart.ks.template
106
- sed -i ' $i\grub2-install --target=i386-pc /dev/vda' scripts/image-builder/config/kickstart.ks.template
107
- sed -i ' $e cat podman_changes.ks' scripts/image-builder/config/kickstart.ks.template
108
- scripts/image-builder/cleanup.sh -full
109
- # The home dir and files must have read permissions to group
110
- # and others because osbuilder is running from another non-priviledged user account
111
- # and allow it to read the files on current user home (like reading yum repo which is created as part of build script), it is required.
112
- # https://github.com/openshift/microshift/blob/main/scripts/image-builder/configure.sh#L29-L32
113
- chmod 0755 $HOME
114
-
115
- scripts/image-builder/build.sh -microshift_rpms ${pkgDir} -pull_secret_file ${OPENSHIFT_PULL_SECRET_PATH} -lvm_sysroot_size 15360 -authorized_keys_file $( realpath ../id_ecdsa_crc.pub)
116
- popd
41
+ local buildDir=$1
42
+ local mirror_repo=" "
43
+ if [ -n " ${MICROSHIFT_PRERELEASE-} " ]; then
44
+ mirror_repo=${MIRROR_REPO}
45
+ fi
46
+ BUILDDIR=${buildDir} image-mode/microshift/build.sh -pull_secret_file ${OPENSHIFT_PULL_SECRET_PATH} \
47
+ -lvm_sysroot_size 15360 \
48
+ -authorized_keys_file $( realpath id_ecdsa_crc.pub) \
49
+ -ushift-version ${MICROSHIFT_VERSION} \
50
+ -use-mirror-repo ${mirror_repo}
117
51
}
118
52
119
- configure_host
120
-
121
- enable_repos
122
53
microshift_pkg_dir=$( mktemp -p /tmp -d tmp-rpmXXX)
123
- # This directory contains the microshift rpm passed to osbuilder, worker for osbuilder
124
- # running as non-priviledged user and this tmp directory have 0700 permission. To allow
125
- # worker to read/execute this file we need to change the permission to 0755
126
- chmod 0755 ${microshift_pkg_dir}
127
- download_microshift_rpm ${microshift_pkg_dir}
54
+
128
55
create_iso ${microshift_pkg_dir}
129
- sudo cp -Z microshift/_output/image-builder/microshift-installer- * .iso /var/lib/libvirt/${SNC_PRODUCT_NAME} /microshift-installer.iso
130
- OPENSHIFT_RELEASE_VERSION=$( rpm -qp -- qf ' %{VERSION}' ${microshift_pkg_dir} / microshift-4. * .rpm )
56
+ sudo cp -Z ${microshift_pkg_dir} /bootiso/install .iso /var/lib/libvirt/${SNC_PRODUCT_NAME} /microshift-installer.iso
57
+ OPENSHIFT_RELEASE_VERSION=$( sudo podman run --rm -it localhost/microshift: ${MICROSHIFT_VERSION} /usr/bin/rpm -q -- qf ' %{VERSION}' microshift)
131
58
# Change 4.x.0~ec0 to 4.x.0-ec0
132
59
# https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/#_complex_versioning
133
60
OPENSHIFT_RELEASE_VERSION=$( echo ${OPENSHIFT_RELEASE_VERSION} | tr ' ~' ' -' )
134
- rm -fr ${microshift_pkg_dir}
61
+ sudo rm -fr ${microshift_pkg_dir}
135
62
136
63
# Download the oc binary for specific OS environment
137
64
OC=./openshift-clients/linux/oc
0 commit comments