lorax/test/vm.install
Martin Pitt 7ca927946e test: Fix vm.install for non-LVM cloud images
Some of our images, like centos-8-stream, are already built from the
official cloud images instead of virt-install with LVM. More images are
going to do that soon [1][2], so fix vm.install to only do the LVM grow
steps if the image actually uses LVM.

Also adjust the comment, as commit 6ddaa5e0dd fixed this for
RHEL images.

[1] https://github.com/cockpit-project/bots/pull/1518
[2] https://github.com/cockpit-project/bots/pull/1527

(cherry picked from commit 04ce221a65)
2021-02-08 11:01:17 -08:00

62 lines
2.1 KiB
Bash

#!/bin/sh -eux
BACKEND="${BACKEND:-lorax-composer}"
SRPM="$1"
# always remove older versions of these RPMs if they exist
# to ensure newly built packages have been installed
yum -y remove lorax $BACKEND composer-cli
if ! rpm -q beakerlib; then
if [ $(. /etc/os-release && echo $ID) = "rhel" ]; then
(cd /etc/yum.repos.d; curl -O -L http://download.devel.redhat.com/beakerrepos/beaker-client-RedHatEnterpriseLinux.repo)
# The beaker repository doesn't include repos for minor releases
VERSION=$(. /etc/os-release && echo ${VERSION_ID%.*})
yum install -y --releasever=$VERSION --setopt=sslverify=0 beakerlib
# prevent yum from trying to sync the cache again later (it fails without sslverify=0)
rm /etc/yum.repos.d/beaker-client-RedHatEnterpriseLinux.repo
else
yum install -y beakerlib
fi
fi
# disable mirrors & re-enable direct download
sed -i "s/metalink.*//" /etc/yum.repos.d/*.repo
sed -i "s/#\(baseurl=.*\)/\1/" /etc/yum.repos.d/*.repo
sed -i "s/download.fedoraproject/dl.fedoraproject/" /etc/yum.repos.d/*.repo
# HACK: Fedora ships baseurl with `example.com` as domain
# Example: `#baseurl=http://download.example/pub/fedora/linux/updates/$releasever/Everything/$basearch/`
sed -i "s/download.example/dl.fedoraproject.org/" /etc/yum.repos.d/*.repo
# Grow root partition on LVM test images to make room for built images
PVS=$(pvs --noheadings -opv_name)
if [ -n "$PVS" ]; then
echo ", +" | sfdisk -N 2 -f /dev/vda
partprobe
echo "$PVS" | xargs pvresize
rootlv=$(findmnt --noheadings -oSOURCE /)
lvresize $rootlv -l+100%FREE -r
fi
rm -rf build-results
su builder -c "/usr/bin/mock --verbose --no-clean --resultdir build-results --rebuild $SRPM"
packages=$(find build-results -name '*.rpm' -not -name '*.src.rpm')
if [ "$BACKEND" == "osbuild-composer" ]; then
packages=$(find build-results -name '*.rpm' -not -name '*.src.rpm' -not -name '*lorax-composer*')
fi
yum install -y $packages $BACKEND
systemctl enable $BACKEND.socket
if [ -f /usr/bin/docker ]; then
yum remove -y $(rpm -qf /usr/bin/docker)
fi
if ! rpm -q podman-docker; then
yum install -y podman-docker
fi