cockpit/bots/images/scripts/fedora.setup

202 lines
5.0 KiB
Bash
Executable File

#!/bin/bash
set -ex
IMAGE="$1"
# avoid failures when running image builds in a non-English locale (ssh transfers the host environment)
unset LANGUAGE
unset LANG
export LC_ALL=C.utf8
# keep this in sync with avocado/selenium image mapping in bots/tests-invoke
if [ "$IMAGE" = fedora-30 ]; then
AVOCADO=1
fi
# HACK - virt-resize might not be able to resize our xfs rootfs,
# depending on how it was compiled and which plugins are installed,
# and will just silently not do it. So we do it here.
#
if [ "$IMAGE" != fedora-31 ]; then
xfs_growfs /
fi
df -h /
echo foobar | passwd --stdin root
HAVE_KUBERNETES=
if [ $(uname -m) = x86_64 ]; then
HAVE_KUBERNETES=1
fi
# HACK docker not available on f31
# https://github.com/cockpit-project/cockpit/issues/12670
HAVE_DOCKER=
if [ "$1" != fedora-31 ]; then
HAVE_DOCKER=1
fi
# We install all dependencies of the cockpit packages since we want
# them to not spontaneously change from one test run to the next when
# the distribution repository is updated.
#
COCKPIT_DEPS="\
device-mapper-multipath \
etcd \
glibc-all-langpacks \
glib-networking \
grubby \
json-glib \
kexec-tools \
libssh \
libvirt-daemon-kvm \
libvirt-client \
libvirt-dbus \
NetworkManager-team \
openssl \
PackageKit \
pcp \
pcp-libs \
qemu \
realmd \
selinux-policy-targeted \
setroubleshoot-server \
sos \
sscg \
system-logos \
subscription-manager \
tuned \
virt-install \
"
[ -z "$HAVE_DOCKER" ] || COCKPIT_DEPS="$COCKPIT_DEPS atomic docker"
COCKPIT_DEPS="$COCKPIT_DEPS udisks2 udisks2-lvm2 udisks2-iscsi"
[ -z "$HAVE_KUBERNETES" ] || COCKPIT_DEPS="$COCKPIT_DEPS kubernetes"
# We also install the packages necessary to join a FreeIPA domain so
# that we don't have to go to the network during a test run.
#
IPA_CLIENT_PACKAGES="\
freeipa-client \
oddjob \
oddjob-mkhomedir \
sssd \
sssd-dbus \
libsss_sudo \
"
TEST_PACKAGES="\
systemtap-runtime-virtguest \
valgrind \
gdb \
targetcli \
dnf-automatic \
cryptsetup \
clevis-luks \
socat \
tang \
podman \
ntp \
libvirt-daemon-config-network \
"
# HACK - For correct work of ABRT in Fedora 26 Alpha release a following
# packages are necessary. In Fedora 26 Beta and later these packages should be
# installed by default. See https://bugzilla.redhat.com/show_bug.cgi?id=1436941
#
ABRT_PACKAGES="\
abrt-desktop \
libreport-plugin-systemd-journal \
"
rm -rf /etc/sysconfig/iptables
maybe() { if type "$1" >/dev/null 2>&1; then "$@"; fi; }
# For the D-Bus test server
maybe firewall-cmd --permanent --add-port 8765/tcp
echo 'NETWORKING=yes' > /etc/sysconfig/network
useradd -c Administrator -G wheel admin
echo foobar | passwd --stdin admin
if [ "${IMAGE%-i386}" != "$IMAGE" ]; then
TEST_PACKAGES="${TEST_PACKAGES/podman /}"
fi
if [ "${IMAGE%-testing}" != "$IMAGE" ]; then
dnf config-manager --set-enabled updates-testing
fi
dnf $DNF_OPTS -y upgrade
dnf $DNF_OPTS -y install $TEST_PACKAGES $COCKPIT_DEPS $IPA_CLIENT_PACKAGES $ABRT_PACKAGES
if [ -n "$AVOCADO" ]; then
# enable python3 avocado support repository
dnf module install -y avocado:69lts
dnf $DNF_OPTS -y install \
fontconfig \
npm \
chromium-headless \
python3-libvirt \
python3-avocado \
python3-avocado-plugins-output-html \
python3-selenium
npm -g install chrome-remote-interface
echo 'NODE_PATH=/usr/lib/node_modules' >> /etc/environment
fi
dnf $DNF_OPTS -y install mock dnf-plugins-core rpm-build
useradd -c Builder -G mock builder
if [ "${IMAGE%-testing}" != "$IMAGE" ]; then
# Enable updates-testing in mock
echo "config_opts['yum.conf'] += '[updates-testing]\nenabled=1'" >>/etc/mock/default.cfg
fi
# HACK - mock --installdeps is broken, it seems that it forgets to
# copy the source rpm to a location that dnf can actually access. A
# workaround is to pass "--no-bootstrap-chroot".
#
# When you remove this hack, also remove it in fedora-*.install.
#
# https://bugzilla.redhat.com/show_bug.cgi?id=1447627
opsys=$(cut -d '-' -f 1 <<< "$IMAGE")
version=$(cut -d '-' -f 2 <<< "$IMAGE")
# If version is not number (testing/i386) then use Fedora 30
if ! [ "$version" -eq "$version" ] 2>/dev/null; then version=30; fi
su builder -c "/usr/bin/mock --no-bootstrap-chroot --verbose -i $(/var/lib/testvm/build-deps.sh "$opsys $version")"
su builder -c "/usr/bin/mock --install --verbose rpmlint"
if [ -n "$HAVE_DOCKER" ]; then
# HACK: docker falls over regularly, print its log if it does
systemctl start docker || journalctl -u docker
# docker images that we need for integration testing
/var/lib/testvm/docker-images.setup
fi
# Configure kubernetes
[ -z "$HAVE_KUBERNETES" ] || /var/lib/testvm/kubernetes.setup
# reduce image size
dnf clean all
/var/lib/testvm/zero-disk.setup --keep-mock-cache
ln -sf ../selinux/config /etc/sysconfig/selinux
printf "SELINUX=enforcing\nSELINUXTYPE=targeted\n" > /etc/selinux/config
# Prevent SSH from hanging for a long time when no external network access
echo 'UseDNS no' >> /etc/ssh/sshd_config
# Audit events to the journal
rm -f '/etc/systemd/system/multi-user.target.wants/auditd.service'
rm -rf /var/log/audit/