Skip to content

Commit

Permalink
packaging: bring down the delta between 14.04 and 16.04. (#3835)
Browse files Browse the repository at this point in the history
* packaging: bring down the delta between 14.04 and 16.04.

This is rather aggressive, and needs further testing before we're sure
it's the way to go, but one can hope.

* packaging: new code, new bugs. Fixed them.

* debian: improve package description
  • Loading branch information
chipaca committed Sep 28, 2017
1 parent f96badd commit 67902f1
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 141 deletions.
1 change: 0 additions & 1 deletion packaging/ubuntu-14.04/compat

This file was deleted.

1 change: 1 addition & 0 deletions packaging/ubuntu-14.04/compat
22 changes: 0 additions & 22 deletions packaging/ubuntu-14.04/copyright

This file was deleted.

1 change: 1 addition & 0 deletions packaging/ubuntu-14.04/copyright
4 changes: 0 additions & 4 deletions packaging/ubuntu-14.04/gbp.conf

This file was deleted.

This file was deleted.

3 changes: 1 addition & 2 deletions packaging/ubuntu-14.04/rules
Expand Up @@ -166,8 +166,6 @@ ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
$(MAKE) -C cmd check
endif

# no dh_systemd in trusty

override_dh_install:
# we do not need this in the package, its just needed during build
rm -rf ${CURDIR}/debian/tmp/usr/bin/xgettext-go
Expand All @@ -190,6 +188,7 @@ override_dh_install:
# it's a conf file so we're stuck with it
mv debian/snapd/etc/profile.d/snapd.sh debian/snapd/etc/profile.d/apps-bin-path.sh

# trusty needs this to make /snap rshared
install --mode=0644 debian/snap.mount.service debian/snapd/$(SYSTEMD_UNITS_DESTDIR)

$(MAKE) -C cmd install DESTDIR=$(CURDIR)/debian/tmp
Expand Down
1 change: 1 addition & 0 deletions packaging/ubuntu-14.04/snap-confine.maintscript
1 change: 1 addition & 0 deletions packaging/ubuntu-14.04/snap.mount.service
@@ -1,3 +1,4 @@
# trusty needs this to make /snap rshared
[Unit]
Description=Apply special mount sharing to /snap directory
ConditionPathExists=!/run/systemd/initctl/fifo
Expand Down
3 changes: 0 additions & 3 deletions packaging/ubuntu-14.04/snapd.autoimport.udev

This file was deleted.

1 change: 1 addition & 0 deletions packaging/ubuntu-14.04/snapd.autoimport.udev
4 changes: 0 additions & 4 deletions packaging/ubuntu-14.04/snapd.maintscript

This file was deleted.

1 change: 1 addition & 0 deletions packaging/ubuntu-14.04/snapd.maintscript
1 change: 0 additions & 1 deletion packaging/ubuntu-14.04/snapd.manpages

This file was deleted.

1 change: 1 addition & 0 deletions packaging/ubuntu-14.04/snapd.manpages
37 changes: 18 additions & 19 deletions packaging/ubuntu-14.04/snapd.postrm
Expand Up @@ -4,27 +4,24 @@ set -e

systemctl_stop() {
unit="$1"
if systemctl is-active -q "$unit"; then
echo "Stoping $unit"
for i in $(seq 10); do
if ! systemctl is-active -q "$unit"; then
echo "$unit is stopped."
break
fi
echo "Stoping $unit [attempt $i]"
systemctl stop -q "$unit" || true
fi
sleep .1
done
}

if [ "$1" = "purge" ]; then
mounts=$(systemctl list-unit-files --full | grep '^snap[-.].*\.mount' | cut -f1 -d ' ')
services=$(systemctl list-unit-files --full | grep '^snap[-.].*\.service' | cut -f1 -d ' ')

for unit in $mounts; do
# ensure its really a snap mount unit or systemd unit
if ! grep -q 'What=/var/lib/snapd/snaps/' "/etc/systemd/system/$unit" && ! grep -q 'X-Snappy=yes' "/etc/systemd/system/$unit"; then
echo "Skipping non-snapd systemd unit $unit"
continue
fi
echo "Stopping $unit"
systemctl_stop "$unit"
done
# snap.mount.service is a trusty thing
systemctl_stop snap.mount.service

systemctl stop snap.mount.service || true
units=$(systemctl list-unit-files --full | grep '^snap[-.]' | cut -f1 -d ' ' | grep -vF snap.mount.service || true)
mounts=$(echo "$units" | grep '^snap[-.].*\.mount$' || true)
services=$(echo "$units" | grep '^snap[-.].*\.service$' || true)

for unit in $services $mounts; do
# ensure its really a snap mount unit or systemd unit
Expand All @@ -33,6 +30,9 @@ if [ "$1" = "purge" ]; then
continue
fi

echo "Stopping $unit"
systemctl_stop "$unit"

# if it is a mount unit, we can find the snap name in the mount
# unit (we just ignore unit files)
snap=$(grep 'Where=/snap/' "/etc/systemd/system/$unit"|cut -f3 -d/)
Expand Down Expand Up @@ -86,9 +86,8 @@ if [ "$1" = "purge" ]; then
done
umount -l /run/snapd/ns/ || true

# prepare removal of /snap
umount -l /snap || true
rmdir --ignore-fail-on-non-empty /snap || true
echo "Removing extra snap-confine apparmor rules"
rm -f /etc/apparmor.d/snap.core.*.usr.lib.snapd.snap-confine

echo "Removing snapd cache"
rm -f /var/cache/snapd/*
Expand Down
1 change: 1 addition & 0 deletions packaging/ubuntu-14.04/source
1 change: 0 additions & 1 deletion packaging/ubuntu-14.04/source/format

This file was deleted.

10 changes: 0 additions & 10 deletions packaging/ubuntu-14.04/tests/README.md

This file was deleted.

1 change: 1 addition & 0 deletions packaging/ubuntu-14.04/tests/README.md
3 changes: 0 additions & 3 deletions packaging/ubuntu-14.04/tests/testconfig.json

This file was deleted.

1 change: 1 addition & 0 deletions packaging/ubuntu-14.04/tests/testconfig.json
62 changes: 0 additions & 62 deletions packaging/ubuntu-16.04/rules
Expand Up @@ -162,68 +162,6 @@ ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
$(MAKE) -C cmd check
endif

override_dh_systemd_enable:
# enable auto-import
dh_systemd_enable \
-psnapd \
data/systemd/snapd.autoimport.service
# we want the auto-update timer enabled by default
dh_systemd_enable \
-psnapd \
data/systemd/snapd.refresh.timer
# but the auto-update service disabled
dh_systemd_enable \
--no-enable \
-psnapd \
data/systemd/snapd.refresh.service
# we want the repair timer enabled by default
dh_systemd_enable \
-psnapd \
data/systemd/snapd.snap-repair.timer
# but the repair service disabled
dh_systemd_enable \
--no-enable \
-psnapd \
data/systemd/snapd.snap-repair.service
# enable snapd
dh_systemd_enable \
-psnapd \
data/systemd/snapd.socket
dh_systemd_enable \
-psnapd \
data/systemd/snapd.service
dh_systemd_enable \
-psnapd \
data/systemd/snapd.system-shutdown.service
dh_systemd_enable \
-psnapd \
data/systemd/snapd.core-fixup.service

override_dh_systemd_start:
# we want to start the auto-update timer
dh_systemd_start \
-psnapd \
data/systemd/snapd.refresh.timer
# but not start the service
dh_systemd_start \
--no-start \
-psnapd \
data/systemd/snapd.refresh.service
# start snapd
dh_systemd_start \
-psnapd \
data/systemd/snapd.socket
dh_systemd_start \
-psnapd \
data/systemd/snapd.service
# start autoimport
dh_systemd_start \
-psnapd \
data/systemd/snapd.autoimport.service
dh_systemd_start \
-psnapd \
data/systemd/snapd.core-fixup.service

override_dh_install:
# we do not need this in the package, its just needed during build
rm -rf ${CURDIR}/debian/tmp/usr/bin/xgettext-go
Expand Down
25 changes: 17 additions & 8 deletions packaging/ubuntu-16.04/snapd.postrm
Expand Up @@ -4,22 +4,30 @@ set -e

systemctl_stop() {
unit="$1"
if systemctl is-active -q "$unit"; then
echo "Stoping $unit"
for i in $(seq 10); do
if ! systemctl is-active -q "$unit"; then
echo "$unit is stopped."
break
fi
echo "Stoping $unit [attempt $i]"
systemctl stop -q "$unit" || true
fi
sleep .1
done
}

if [ "$1" = "purge" ]; then
# undo any bind mount to /snap that resulted from LP:#1668659
# (that bug can't happen in trusty -- and doing this would mess up snap.mount.service there)
if grep -q "/snap /snap" /proc/self/mountinfo; then
umount -l /snap || true
fi

mounts=$(systemctl list-unit-files --full | grep '^snap[-.].*\.mount' | cut -f1 -d ' ')
services=$(systemctl list-unit-files --full | grep '^snap[-.].*\.service' | cut -f1 -d ' ')
units=$(systemctl list-unit-files --full | grep '^snap[-.]' | cut -f1 -d ' ' | grep -vF snap.mount.service || true)
mounts=$(echo "$units" | grep '^snap[-.].*\.mount$' || true)
services=$(echo "$units" | grep '^snap[-.].*\.service$' || true)

for unit in $services $mounts; do
# ensure its really a snapp mount unit or systemd unit
# ensure its really a snap mount unit or systemd unit
if ! grep -q 'What=/var/lib/snapd/snaps/' "/etc/systemd/system/$unit" && ! grep -q 'X-Snappy=yes' "/etc/systemd/system/$unit"; then
echo "Skipping non-snapd systemd unit $unit"
continue
Expand All @@ -43,7 +51,8 @@ if [ "$1" = "purge" ]; then
rm -f "/snap/bin/$snap"
rm -f "/snap/bin/$snap".*
# snap mount dir
umount -l "/snap/$snap/$rev" 2> /dev/null || true
# we pass -d (clean up loopback devices) for trusty compatibility
umount -d -l "/snap/$snap/$rev" 2> /dev/null || true
rm -rf "/snap/$snap/$rev"
rm -f "/snap/$snap/current"
# snap data dir
Expand All @@ -53,7 +62,7 @@ if [ "$1" = "purge" ]; then
# opportunistic remove (may fail if there are still revisions left
for d in "/snap/$snap" "/var/snap/$snap"; do
if [ -d "$d" ]; then
rmdir --ignore-fail-on-non-empty "$d"
rmdir --ignore-fail-on-non-empty "$d" || true
fi
done
fi
Expand Down

0 comments on commit 67902f1

Please sign in to comment.