2019-06-17 12:35:31 +00:00
|
|
|
#!/bin/sh -eux
|
|
|
|
|
2020-03-05 18:51:57 +00:00
|
|
|
# BUILD_SRPM serves as a flag whether we should build and install the composer packages
|
|
|
|
BUILD_SRPM=${BUILD_SRPM:-1}
|
|
|
|
|
|
|
|
if [ "$BUILD_SRPM" -eq 1 ]; then
|
|
|
|
SRPM="$1"
|
|
|
|
fi
|
2019-06-17 12:35:31 +00:00
|
|
|
|
2019-11-21 09:10:57 +00:00
|
|
|
# always remove older versions of these RPMs if they exist
|
|
|
|
# to ensure newly built packages have been installed
|
|
|
|
yum -y remove lorax lorax-composer composer-cli
|
|
|
|
|
2020-04-29 10:09:14 +00:00
|
|
|
RHEL_VERSION=$(. /etc/os-release; echo $VERSION_ID)
|
|
|
|
if grep -qE "https?://.*/nightly/" /etc/yum.repos.d/*; then
|
|
|
|
RELEASE_TYPE="nightly"
|
|
|
|
# there are only -latest symlinks with major version for nightlies
|
|
|
|
RHEL_VERSION=7
|
|
|
|
else
|
|
|
|
RELEASE_TYPE="rel-eng"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# add nightly/rel-eng repo only if it's not already present (it is by default in bots images)
|
|
|
|
LATEST_REPO="/etc/yum.repos.d/rhel7-$RELEASE_TYPE-latest.repo"
|
|
|
|
if ! grep -qE "https?://.*redhat\.com/rhel-7/$RELEASE_TYPE/RHEL-7/latest-RHEL-$RHEL_VERSION/compose/Server/\$basearch/os/" \
|
|
|
|
/etc/yum.repos.d/*; then
|
2019-07-05 14:56:14 +00:00
|
|
|
cat > $LATEST_REPO << __EOF__
|
2020-04-29 10:09:14 +00:00
|
|
|
[rhel7-$RELEASE_TYPE-latest]
|
2019-07-05 14:56:14 +00:00
|
|
|
gpgcheck=0
|
|
|
|
enabled=1
|
|
|
|
skip_if_unavailable=0
|
2020-04-29 10:09:14 +00:00
|
|
|
name=rhel7-$RELEASE_TYPE-latest
|
|
|
|
baseurl=http://download.devel.redhat.com/rhel-7/$RELEASE_TYPE/RHEL-7/latest-RHEL-$RHEL_VERSION/compose/Server/\$basearch/os/
|
2019-07-05 14:56:14 +00:00
|
|
|
__EOF__
|
|
|
|
fi
|
|
|
|
|
2019-06-17 12:35:31 +00:00
|
|
|
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)
|
2019-11-06 13:12:13 +00:00
|
|
|
# disable sslverify b/c yum will fail to sync metadata otherwise
|
|
|
|
sed -i "s/\(gpgcheck=0\)/\1\nsslverify=0/" /etc/yum.repos.d/beaker-client-RedHatEnterpriseLinux.repo
|
|
|
|
# do not remove the repo file. We now have tests which use beakerlib
|
|
|
|
# inside their blueprints so this needs to stay on the VM
|
2019-06-17 12:35:31 +00:00
|
|
|
fi
|
2019-11-06 13:12:13 +00:00
|
|
|
|
|
|
|
yum install -y beakerlib
|
2019-06-17 12:35:31 +00:00
|
|
|
fi
|
|
|
|
|
2019-08-01 11:34:57 +00:00
|
|
|
EPEL_REPO="/etc/yum.repos.d/epel7.repo"
|
|
|
|
if [ ! -f "$EPEL_REPO" ]; then
|
|
|
|
cat > $EPEL_REPO << __EOF__
|
|
|
|
[epel7]
|
|
|
|
name=epel7
|
|
|
|
failovermethod=priority
|
|
|
|
enabled=1
|
|
|
|
skip_if_unavailable=0
|
|
|
|
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=\$basearch
|
|
|
|
gpgcheck=0
|
|
|
|
__EOF__
|
|
|
|
fi
|
|
|
|
|
|
|
|
# EPEL packages used in tests
|
|
|
|
if ! rpm -q python2-pip; then
|
|
|
|
yum -y install python2-pip
|
|
|
|
fi
|
|
|
|
|
2019-08-01 11:45:56 +00:00
|
|
|
if ! rpm -q python-virtualenv; then
|
|
|
|
yum -y install python-virtualenv
|
|
|
|
fi
|
|
|
|
|
2019-08-01 11:34:57 +00:00
|
|
|
# don't build images with EPEL enabled
|
|
|
|
rm -f $EPEL_REPO
|
|
|
|
|
2019-07-05 16:00:55 +00:00
|
|
|
if rpm -q python2-cryptography; then
|
|
|
|
yum remove -y python2-cryptography
|
|
|
|
fi
|
|
|
|
|
|
|
|
if rpm -q pyparsing; then
|
|
|
|
yum remove -y pyparsing
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! rpm -q git; then
|
|
|
|
yum install -y git
|
|
|
|
fi
|
|
|
|
|
2019-06-17 12:35:31 +00:00
|
|
|
# Grow root partition to make room for images. This only works on Fedora right now.
|
|
|
|
parted --script /dev/vda resizepart 2 100%
|
|
|
|
partprobe
|
|
|
|
pvs --noheadings -opv_name | xargs pvresize
|
|
|
|
rootlv=$(findmnt --noheadings -oSOURCE /)
|
|
|
|
lvresize $rootlv -l+100%FREE -r
|
|
|
|
|
|
|
|
rm -rf build-results
|
|
|
|
|
|
|
|
|
2020-03-05 18:51:57 +00:00
|
|
|
if [ "$BUILD_SRPM" -eq 1 ]; then
|
|
|
|
SRPM="$1"
|
|
|
|
su builder -c "/usr/bin/mock --no-clean --resultdir build-results --rebuild $SRPM"
|
|
|
|
|
|
|
|
packages=$(find build-results -name '*.rpm' -not -name '*.src.rpm')
|
|
|
|
yum install -y $packages
|
|
|
|
else
|
|
|
|
yum -y install lorax-composer composer-cli
|
|
|
|
fi
|
2019-06-17 12:35:31 +00:00
|
|
|
systemctl enable lorax-composer.socket
|
2019-10-23 23:44:15 +00:00
|
|
|
|
|
|
|
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
|