Skip to content

Commit 8fbadcd

Browse files
committed
Implement local repo inside the VM instance for additional packages
During cloud-init package installation it is observered if `*.rpm` used which include required package and all dependencies then installed dependencies is not going to override and you need to first uninstall those or remove the that package from *.rpm list which is not ideal. With current approach it is easy to installed package just using the required package name since all deps is part of local repo and if package already installed it can be ignored.
1 parent 3b1a5b5 commit 8fbadcd

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

createdisk-library.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,24 @@ function install_additional_packages() {
189189
# SCP the downloaded rpms to VM
190190
${SCP} -r ${pkgDir}/packages core@${vm_ip}:/home/core/
191191

192+
# Create local repo of downloaded RPMs in the VM
193+
${SSH} core@${vm_ip} 'sudo bash -x -s' <<EOF
194+
podman run --rm -v /home/core/packages:/packages:Z quay.io/centos/centos:stream9 sh -c "dnf install -y createrepo && createrepo /packages"
195+
podman rmi quay.io/centos/centos:stream9
196+
EOF
197+
${SSH} core@${vm_ip} "sudo bash -c 'cat > /etc/yum.repos.d/local.repo << EOF
198+
[local]
199+
name=Local repo
200+
baseurl=file:///home/core/packages/
201+
enabled=1
202+
gpgcheck=0
203+
EOF'"
192204
# Install these rpms to VM
193-
${SSH} core@${vm_ip} -- 'sudo rpm-ostree install /home/core/packages/*.rpm'
205+
${SSH} core@${vm_ip} -- "sudo rpm-ostree install $ADDITIONAL_PACKAGES"
194206

195-
# Remove the packages from VM
196-
${SSH} core@${vm_ip} -- rm -fr /home/core/packages
207+
# Remove the packages and repo from VM
208+
${SSH} core@${vm_ip} -- sudo rm -fr /home/core/packages
209+
${SSH} core@${vm_ip} -- sudo rm -fr /etc/yum.repos.d/local.repo
197210

198211
# Cleanup up packages
199212
rm -fr ${pkgDir}

createdisk.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ EOF
138138
${SSH} core@${VM_IP} -- "sudo rpm-ostree install qemu-user-static-x86"
139139
fi
140140

141+
# Beyond this point, packages added to the ADDITIONAL_PACKAGES variable won’t be installed in the guest
142+
install_additional_packages ${VM_IP}
141143
cleanup_vm_image ${VM_NAME} ${VM_IP}
142144

143145
# Delete all the pods except openshift-multus (which have file for crio cni config)

0 commit comments

Comments
 (0)