121 lines
3.8 KiB
Bash
Executable File
121 lines
3.8 KiB
Bash
Executable File
#! /bin/bash
|
|
|
|
set -ex
|
|
|
|
# don't update already installed cockpit packages
|
|
installed=$(rpm --query --all --queryformat "%{NAME}-\[0-9\]\n" "cockpit*")
|
|
skip="cockpit-doc-[0-9]"
|
|
if [ -n "$installed" ]; then
|
|
skip="$skip
|
|
$installed"
|
|
fi
|
|
|
|
do_build=
|
|
do_install=
|
|
# we build RHEL 7.x in a CentOS mock, thus we can't parse os-release in the .spec
|
|
mock_opts="--define='os_version_id $(. /etc/os-release; echo $VERSION_ID)'"
|
|
args=$(getopt -o "vqs:" -l "verbose,quick,skip:,build,install,rhel,HACK-no-bootstrap-chroot" -- "$@")
|
|
eval set -- "$args"
|
|
while [ $# -gt 0 ]; do
|
|
case $1 in
|
|
-v|--verbose)
|
|
mock_opts="$mock_opts --verbose"
|
|
;;
|
|
-q|--quick)
|
|
mock_opts="$mock_opts --nocheck --define='selinux 0'"
|
|
;;
|
|
-s|--skip)
|
|
skip="$skip
|
|
$2"
|
|
shift
|
|
;;
|
|
--build)
|
|
do_build=t
|
|
;;
|
|
--install)
|
|
do_install=t
|
|
;;
|
|
--rhel)
|
|
# For RHEL we actually build in EPEL, which is based
|
|
# on CentOS. On CentOS, the spec file has both
|
|
# %centos and %rhel defined, but it gives precedence
|
|
# to %centos, as it must. To make it produce the RHEL
|
|
# packages, we explicitly undefine %centos here.
|
|
mock_opts="$mock_opts --define='centos 0'"
|
|
;;
|
|
--HACK-no-bootstrap-chroot)
|
|
mock_opts="$mock_opts --no-bootstrap-chroot"
|
|
;;
|
|
--)
|
|
shift
|
|
break
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
tar=$1
|
|
|
|
# Build
|
|
|
|
if [ -n "$do_build" ]; then
|
|
# Some tests need a non-loopback internet address, so we allow
|
|
# networking during build. Note that we use "--offline" below, so
|
|
# we should still be protected against unexpected package
|
|
# installations.
|
|
echo "config_opts['rpmbuild_networking'] = True" >>/etc/mock/site-defaults.cfg
|
|
# don't destroy the mock after building, we want to run rpmlint
|
|
echo "config_opts['cleanup_on_success'] = False" >>/etc/mock/site-defaults.cfg
|
|
# HACK: don't fall over on unavailable repositories, as we are offline
|
|
# (https://bugzilla.redhat.com/show_bug.cgi?id=1549291)
|
|
sed --follow-symlinks -i '/skip_if_unavailable=False/d' /etc/mock/default.cfg
|
|
|
|
rm -rf build-results
|
|
srpm=$(/var/lib/testvm/make-srpm "$tar")
|
|
LC_ALL=C.UTF-8 su builder -c "/usr/bin/mock --offline --no-clean --resultdir build-results $mock_opts --rebuild $srpm"
|
|
|
|
cat <<EOF >/tmp/rpmlint
|
|
#! /bin/bash
|
|
rm -rf /builddir/build
|
|
if type rpmlint >/dev/null 2>&1; then
|
|
# blacklist "E: no-changelogname-tag" rpmlint error, expected due to our template cockpit.spec
|
|
mkdir -p ~/.config
|
|
echo 'addFilter("E: no-changelogname-tag")' > ~/.config/rpmlint
|
|
# we expect the srpm to be clean
|
|
echo
|
|
echo '====== rpmlint on srpm ====='
|
|
rpmlint /builddir/build/SRPMS/*.src.rpm
|
|
# this still has lots of errors, run it for information only
|
|
echo
|
|
echo '====== rpmlint binary rpms (advisory) ====='
|
|
rpmlint /builddir/build/RPMS/ || true
|
|
else
|
|
echo '====== skipping rpmlint check, not installed ====='
|
|
fi
|
|
EOF
|
|
chmod +x /tmp/rpmlint
|
|
su builder -c "/usr/bin/mock --offline --copyin /tmp/rpmlint /var/tmp/rpmlint"
|
|
su builder -c "/usr/bin/mock --offline --shell /var/tmp/rpmlint"
|
|
fi
|
|
|
|
# Install
|
|
|
|
if [ -n "$do_install" ]; then
|
|
packages=$(find build-results -name "*.rpm" -not -name "*.src.rpm" | grep -vG "$skip")
|
|
rpm -U --force $packages
|
|
|
|
if type firewall-cmd > /dev/null 2> /dev/null; then
|
|
systemctl start firewalld
|
|
firewall-cmd --add-service=cockpit --permanent
|
|
fi
|
|
|
|
# Make sure we clean out the journal
|
|
journalctl --flush
|
|
journalctl --sync || killall systemd-journald
|
|
rm -rf /var/log/journal/*
|
|
rm -rf /var/lib/NetworkManager/dhclient-*.lease
|
|
fi
|
|
|
|
if [ -n "$do_build" ]; then
|
|
su builder -c "/usr/bin/mock --clean"
|
|
fi
|