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)
This commit is contained in:
Martin Pitt 2021-01-07 11:29:01 +01:00 committed by Brian C. Lane
parent ce68a7d945
commit 7ca927946e

View File

@ -31,12 +31,15 @@ sed -i "s/download.fedoraproject/dl.fedoraproject/" /etc/yum.repos.d/*.repo
# Example: `#baseurl=http://download.example/pub/fedora/linux/updates/$releasever/Everything/$basearch/` # 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 sed -i "s/download.example/dl.fedoraproject.org/" /etc/yum.repos.d/*.repo
# Grow root partition to make room for images. This only works on Fedora right now. # Grow root partition on LVM test images to make room for built images
echo ", +" | sfdisk -N 2 -f /dev/vda PVS=$(pvs --noheadings -opv_name)
partprobe if [ -n "$PVS" ]; then
pvs --noheadings -opv_name | xargs pvresize echo ", +" | sfdisk -N 2 -f /dev/vda
rootlv=$(findmnt --noheadings -oSOURCE /) partprobe
lvresize $rootlv -l+100%FREE -r echo "$PVS" | xargs pvresize
rootlv=$(findmnt --noheadings -oSOURCE /)
lvresize $rootlv -l+100%FREE -r
fi
rm -rf build-results rm -rf build-results
su builder -c "/usr/bin/mock --verbose --no-clean --resultdir build-results --rebuild $SRPM" su builder -c "/usr/bin/mock --verbose --no-clean --resultdir build-results --rebuild $SRPM"