github.com/ethanhsieh/snapd@v0.0.0-20210615102523-3db9b8e4edc5/packaging/ubuntu-16.04/snapd.postinst (about) 1 #!/bin/sh 2 3 set -e 4 5 # "powerpc" is not supported unfortunately, do nothing here# 6 if [ "$DPKG_MAINTSCRIPT_ARCH" = powerpc ]; then 7 exit 0 8 fi 9 10 case "$1" in 11 configure) 12 # ensure /var/lib/snapd/lib/gl is cleared 13 if dpkg --compare-versions "$2" lt-nl "2.0.7"; then 14 ldconfig 15 fi 16 17 # Ensure that we undo the damage done by the snap.mount unit that was present 18 # in snapd 2.31. 19 # 20 # We found that update scripts make systemd stop inactive mount units and this 21 # in turn stops all the units that depend on it so when the snap.mount unit is 22 # stopped all the per-snap mount units gets stopped along with them. The 2.31 23 # release was only out briefly in xenial-proposed and bionic but to keep the 24 # affected users safe let's start all the per-snap mount units so that snaps no 25 # longer appear as broken after update. 26 if dpkg --compare-versions "$2" ge-nl "2.31" && \ 27 dpkg --compare-versions "$2" lt-nl "2.32"; then 28 units=$(systemctl list-unit-files --full | grep '^snap[-.]' | cut -f1 -d ' ' | grep -vF snap.mount.service || true) 29 mounts=$(echo "$units" | grep '^snap[-.].*\.mount$' || true) 30 for unit in $mounts; do 31 # ensure its really a snap mount unit or systemd unit 32 if ! grep -q 'What=/var/lib/snapd/snaps/' "/etc/systemd/system/$unit" && ! grep -q 'X-Snappy=yes' "/etc/systemd/system/$unit"; then 33 echo "Skipping non-snapd systemd unit $unit" 34 continue 35 fi 36 37 echo "Starting $unit" 38 deb-systemd-invoke start "$unit" || true 39 done 40 fi 41 42 # In commit 0dce4704a5d (2017-03-28, snapd v2.23.6) we renamed 43 # /etc/apparmor.d/usr.lib.snap-confine to usr.lib.snap-confine.real 44 # to fix LP: #1673247 - however some people (developers?) still have 45 # the old usr.lib.snap-confine file. This seems to be loaded instead 46 # of the correct usr.lib.snap-confine.real profile. To fix this we 47 # use the rather blunt approach to rename the file forcefully. 48 if test -f /etc/apparmor.d/usr.lib.snapd.snap-confine && test -f /etc/apparmor.d/usr.lib.snapd.snap-confine.real; then 49 mv /etc/apparmor.d/usr.lib.snapd.snap-confine /etc/apparmor.d/usr.lib.snapd.snap-confine.dpkg-bak 50 fi 51 52 # Ensure that the void directory has correct permissions. 53 chmod 111 /var/lib/snapd/void 54 55 # Ubuntu 20.04 had a incorrect seed directory during development. 56 # 57 # This was causing hangs in the postinst when systemctl tries to 58 # start snapd.seeded.service which will wait for snapd to finish 59 # seeding (which will never happen because seeding is broken). 60 # See LP: 1868706 61 # This snippet detect this incorrect seed and disables it. 62 if [ -e /var/lib/snapd/seed/seed.yaml ] && [ "$(snap debug state --is-seeded /var/lib/snapd/state.json)" = "false" ]; then 63 if ! snap debug validate-seed /var/lib/snapd/seed/seed.yaml; then 64 echo "Found incorrect seed, disabling it" 65 mv /var/lib/snapd/seed /var/lib/snapd/seed.disabled 66 fi 67 fi 68 69 # ensure "snap userd" is restarted 70 if dpkg --compare-versions "$2" lt-nl "2.45.2"; then 71 pkill -f "snap userd" || true 72 fi 73 esac 74 75 #DEBHELPER#