tests,packaging: add package build support for Fedora for our spread setup #3365

Merged
merged 43 commits into from Jun 8, 2017
Commits
Jump to file or symbol
Failed to load files and symbols.
+250 −42
Split
@@ -8,6 +8,20 @@
set -e
SNAP_MOUNT_DIR="/var/lib/snapd/snap"
+
+show_help() {
+ exec cat <<'EOF'
+Usage: snap-mgmt.sh [OPTIONS]
+
+A simple script to cleanup snap installations.
+
+optional arguments:
+ --help Show this help message and exit
+ --snap-mount-dir=<path> Provide a path to be used as $SNAP_MOUNT_DIR
+ --purge Purge all data from $SNAP_MOUNT_DIR
+EOF
+}
@Conan-Kudo

Conan-Kudo May 25, 2017

Contributor

This is not a good idea.. This is not meant to be run by humans, only tools. That's explicitly why it's in %_libexecdir/snapd rather than being in %_bindir.

@morphis

morphis May 29, 2017

Contributor

Actually I don't see a difference if the script is called by a human or just another script. That it is not intended to be called by humans is already encoded by putting it no into %_bindir as you say. Providing a help output and proper command line options makes it just more convenient for developers to know what a script they call from another one does instead of relying on non obvious positional command line options. Hiding these things doesn't help in any case.

@niemeyer

niemeyer May 29, 2017

Contributor

Yeah, I can't find it bad to have actual documentation. Even if called from another tool, it'll be a human touching both ends.

+
SNAP_UNIT_PREFIX="$(systemd-escape -p ${SNAP_MOUNT_DIR})"
systemctl_stop() {
@@ -18,7 +32,7 @@ systemctl_stop() {
fi
}
-if [ "$1" = "purge" ]; then
+purge() {
# undo any bind mount to ${SNAP_MOUNT_DIR} that resulted from LP:#1668659
if grep -q "${SNAP_MOUNT_DIR} ${SNAP_MOUNT_DIR}" /proc/self/mountinfo; then
umount -l "${SNAP_MOUNT_DIR}" || true
@@ -91,5 +105,26 @@ if [ "$1" = "purge" ]; then
rm -rf /var/lib/snapd/seccomp/profiles/*
rm -rf /var/lib/snapd/device/*
rm -rf /var/lib/snapd/assertions/*
+}
-fi
+while [ -n "$1" ]; do
+ case "$1" in
+ --help)
+ show_help
+ exit
+ ;;
+ --snap-mount-dir=*)
+ SNAP_MOUNT_DIR=${1#*=}
+ SNAP_UNIT_PREFIX="$(systemd-escape -p $SNAP_MOUNT_DIR)"
+ shift
+ ;;
+ --purge)
+ purge
+ shift
+ ;;
+ *)
+ echo "Unknown command: $1"
+ exit 1
+ ;;
+ esac
+done
@@ -333,6 +333,13 @@ popd
# Build snap-confine
pushd ./cmd
+# FIXME This is a hack to get rid of a patch we have to ship for the
+# Fedora package at the moment as /usr/lib/rpm/redhat/redhat-hardened-ld
+# accidentially adds -pie for static executables. See
+# https://bugzilla.redhat.com/show_bug.cgi?id=1343892 for a few more
+# details. To prevent this from happening we drop the linker
+# script and define our LDFLAGS manually for now.
+export LDFLAGS="-Wl,-z,relro -z now"
autoreconf --force --install --verbose
# selinux support is not yet available, for now just disable apparmor
# FIXME: add --enable-caps-over-setuid as soon as possible (setuid discouraged!)
@@ -407,6 +414,7 @@ pushd ./data/systemd
%make_install SYSTEMDSYSTEMUNITDIR="%{_unitdir}"
# Remove snappy core specific units
rm -fv %{buildroot}%{_unitdir}/snapd.system-shutdown.service
+rm -fv %{buildroot}%{_unitdir}/snap-repair.*
popd
# Put /var/lib/snapd/snap/bin on PATH
@@ -572,7 +580,7 @@ fi
# Remove all Snappy content if snapd is being fully uninstalled
if [ $1 -eq 0 ]; then
- %{_libexecdir}/snapd/snap-mgmt purge || :
+ %{_libexecdir}/snapd/snap-mgmt --purge || :
@Conan-Kudo

Conan-Kudo May 25, 2017

Contributor

Again, not particularly a fan of this change.

fi
View
@@ -60,6 +60,8 @@ backends:
- debian-unstable-64:
kernel: GRUB 2
workers: 4
+ - fedora-25-64:
+ workers: 1
qemu:
environment:
APT_PROXY: "$(HOST: echo $APT_PROXY)"
@@ -92,6 +94,9 @@ backends:
- debian-9-64:
username: debian
password: debian
+ - fedora-25-64:
+ username: fedora
+ password: fedora
autopkgtest:
type: adhoc
allocate: |
@@ -276,9 +281,17 @@ prepare: |
# (needs to be in spread.yaml directly because there's nothing else on the filesystem yet)
if [ -f current.delta ]; then
tf=$(mktemp)
- # poor-man's "quiet"
- apt-get update >& "$tf" || ( cat "$tf"; exit 1 )
- apt-get install -y xdelta3 curl >& "$tf" || ( cat "$tf"; exit 1 )
+ # NOTE: We can't use tests/lib/pkgdb.sh here as it doesn't exist at
+ # this time when none of the test files is yet in place.
+ case "$SPREAD_SYSTEM" in
+ ubuntu-*|debian-*)
+ apt-get update >& "$tf" || ( cat "$tf"; exit 1 )
+ apt-get install -y xdelta3 curl >& "$tf" || ( cat "$tf"; exit 1 )
+ ;;
+ fedora-*)
+ dnf install --refresh -y xdelta curl &> "$tf" || (cat "$tf"; exit 1)
+ ;;
+ esac
rm -f "$tf"
curl -sS -o - https://codeload.github.com/snapcore/snapd/tar.gz/$DELTA_REF | gunzip > delta-ref.tar
xdelta3 -q -d -s delta-ref.tar current.delta | tar x --strip-components=1
@@ -304,6 +317,7 @@ restore: |
suites:
tests/main/:
summary: Full-system tests for snapd
+ systems: [-fedora-*]
prepare: |
. $TESTSLIB/prepare.sh
if [[ "$SPREAD_SYSTEM" == ubuntu-core-16-* ]]; then
@@ -329,7 +343,7 @@ suites:
summary: completion tests
# ppc64el disabled because of https://bugs.launchpad.net/snappy/+bug/1655594
- systems: [-ubuntu-core-*, -ubuntu-*-ppc64el]
+ systems: [-ubuntu-core-*, -ubuntu-*-ppc64el, -fedora-*]
prepare: |
. $TESTSLIB/prepare.sh
@@ -359,6 +373,7 @@ suites:
tests/regression/:
summary: Regression tests for snapd
+ systems: [-fedora-*]
prepare: |
. $TESTSLIB/prepare.sh
if [[ "$SPREAD_SYSTEM" == ubuntu-core-16-* ]]; then
@@ -377,7 +392,7 @@ suites:
tests/upgrade/:
summary: Tests for snapd upgrade
- systems: [-ubuntu-core-16-*]
+ systems: [-ubuntu-core-16-*, -fedora-*]
restore: |
if [ "$REMOTE_STORE" = staging ]; then
echo "skip upgrade tests while talking to the staging store"
@@ -393,7 +408,7 @@ suites:
tests/unit/:
summary: Suite to run unit tests (non-go and different go runtimes)
- systems: [-ubuntu-core-16-*]
+ systems: [-ubuntu-core-16-*, -fedora-*]
environment:
# env vars required for coverage reporting from a spread task
TRAVIS_BUILD_NUMBER: "$(HOST: echo $TRAVIS_BUILD_NUMBER)"
@@ -405,7 +420,6 @@ suites:
TRAVIS_REPO_SLUG: "$(HOST: echo $TRAVIS_REPO_SLUG)"
TRAVIS_TAG: "$(HOST: echo $TRAVIS_TAG)"
COVERMODE: "$(HOST: echo $COVERMODE)"
-
prepare: |
. $TESTSLIB/prepare.sh
prepare_classic
@@ -420,6 +434,7 @@ suites:
tests/nightly/:
summary: Suite for nightly, expensive, tests
manual: true
+ systems: [-fedora-*]
prepare: |
. $TESTSLIB/prepare.sh
if [[ "$SPREAD_SYSTEM" == ubuntu-core-16-* ]]; then
@@ -438,6 +453,7 @@ suites:
tests/nested/:
summary: Tests for nested images
+ systems: [-fedora-*]
environment:
NESTED_ARCH: "$(HOST: echo ${SPREAD_NESTED_ARCH:-amd64})"
halt-timeout: 2h
View
@@ -13,6 +13,18 @@ install_build_snapd(){
mv sources.list.back /etc/apt/sources.list
apt update
else
- distro_install_local_package "$GOHOME"/snapd_*.deb
+ packages=
+ case "$SPREAD_SYSTEM" in
+ ubuntu-*|debian-*)
+ packages="${GOHOME}/snapd_*.deb"
+ ;;
+ fedora-*)
+ packages="${GOHOME}/snap-confine*.rpm ${GOPATH}/snapd*.rpm"
+ ;;
+ *)
+ exit 1
+ ;;
+ esac
+ distro_install_local_package $packages
fi
}
View
@@ -1,5 +1,12 @@
#!/bin/sh
-
-# Default applies for: Ubuntu, Debian
export SNAPMOUNTDIR=/snap
export LIBEXECDIR=/usr/lib
+
+case "$SPREAD_SYSTEM" in
+ fedora-*)
+ export SNAPMOUNTDIR=/var/lib/snapd/snap
+ export LIBEXECDIR=/usr/libexec
+ ;;
+ *)
+ ;;
+esac
View
@@ -8,6 +8,26 @@ debian_name_package() {
xdelta3|curl|python3-yaml|kpartx|busybox-static)
echo "$1"
;;
+ *)
+ echo $1
+ ;;
+ esac
+}
+
+fedora_name_package() {
@niemeyer

niemeyer May 29, 2017

Contributor

Wonder why inverted these function names are...

@zyga

zyga Jun 8, 2017

Contributor

You must unlearn what you have learned. ;-)

+ case "$1" in
+ xdelta3|jq|curl|python3-yaml)
+ echo $1
+ ;;
+ openvswitch-switch)
+ echo "openvswitch"
+ ;;
+ printer-driver-cups-pdf)
+ echo "cups-pdf"
+ ;;
+ *)
+ echo $1
+ ;;
esac
}
@@ -16,6 +36,9 @@ distro_name_package() {
ubuntu-*|debian-*)
debian_name_package "$1"
;;
+ fedora-*)
+ fedora_name_package $1
+ ;;
*)
echo "ERROR: Unsupported distribution $SPREAD_SYSTEM"
exit 1
@@ -50,6 +73,9 @@ distro_install_local_package() {
# shellcheck disable=SC2086
apt install $flags "$@"
;;
+ fedora-*)
+ dnf -q -y install "$@"
+ ;;
*)
echo "ERROR: Unsupported distribution $SPREAD_SYSTEM"
exit 1
@@ -68,7 +94,10 @@ distro_install_package() {
case "$SPREAD_SYSTEM" in
ubuntu-*|debian-*)
- apt-get install -y "$package_name"
+ quiet apt-get install -y "$package_name"
+ ;;
+ fedora-*)
+ dnf -q -y install -y $package_name
;;
*)
echo "ERROR: Unsupported distribution $SPREAD_SYSTEM"
@@ -91,6 +120,9 @@ distro_purge_package() {
ubuntu-*|debian-*)
quiet apt-get remove -y --purge -y "$package_name"
;;
+ fedora-*)
+ dnf -y -q remove $package_name
+ ;;
*)
echo "ERROR: Unsupported distribution $SPREAD_SYSTEM"
exit 1
@@ -104,6 +136,9 @@ distro_update_package_db() {
ubuntu-*|debian-*)
quiet apt-get update
;;
+ fedora-*)
+ dnf -y -q upgrade
+ ;;
*)
echo "ERROR: Unsupported distribution $SPREAD_SYSTEM"
exit 1
@@ -128,6 +163,9 @@ distro_auto_remove_packages() {
ubuntu-*|debian-*)
quiet apt-get -y autoremove
;;
+ fedora-*)
+ dnf -q -y autoremove
+ ;;
*)
echo "ERROR: Unsupported distribution '$SPREAD_SYSTEM'"
exit 1
@@ -142,6 +180,9 @@ case "$SPREAD_SYSTEM" in
debian-*|ubuntu-*)
DISTRO_BUILD_DEPS=(build-essential curl devscripts expect gdebi-core jq rng-tools git netcat-openbsd)
;;
+ fedora-*)
+ DISTRO_BUILD_DEPS=(mock git expect curl golang rpm-build redhat-lsb-core)
+ ;;
*)
;;
esac
Oops, something went wrong.