-
Notifications
You must be signed in to change notification settings - Fork 0
/
F_00_PRE_00_pkgs_remove_snapd.sh
78 lines (60 loc) · 2.6 KB
/
F_00_PRE_00_pkgs_remove_snapd.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Remove packages
snap list | tail -n +2 | awk '{print $1}' | grep -vE "^bare|^core|^snapd" | xargs -I{} bash -c "echo --- removing {} \(please wait for awhile\) ---; echo; snap remove --purge {}; echo sleep 3 seconds...; sleep 3"
# Remove base packagges
snap list | tail -n +2 | awk '{print $1}' | xargs -I{} bash -c "echo --- removing {} \(please wait for awhile\) ---; snap remove --purge {}; echo; echo sleep 3 seconds...; sleep 3"
# Disable snapd services
systemctl list-unit-files |grep snapd | awk '{print $1}' | xargs systemctl disable --now
sleep 1
# Remove snapd
apt autoremove --purge -y snapd
sleep 1
rm -fr /root/snap
echo "--- check snapd folders ---"
echo "msg should be: (No such file or directory)"
echo ""
file /snap /var/snap /var/lib/snapd /var/cache/snapd /usr/lib/snapd ~/snap
# Avoid ubuntu install snapd back
echo "--- creating file /etc/apt/preferences.d/nosnap.pref ---"
cat <<EOF | tee /etc/apt/preferences.d/nosnap.pref
# To prevent repository packages from triggering the installation of Snap,
# this file forbids snapd from being installed by APT.
# For more information: https://linuxmint-user-guide.readthedocs.io/en/latest/snap.html
Package: snapd
Pin: release a=*
Pin-Priority: -10
EOF
# Avoid systemd config changed
systemctl daemon-reload
echo "Snap removed"
echo "--- apt update again ---"
apt clean
apt update
# ----------------------------------
# APT notes
# ----------------------------------
# apt pref config ref. https://www.debian.org/doc/manuals/apt-howto/ch-apt-get.en.html
# $ man apt_preferences
#
# How APT Interprets Priorities
# Priorities (P) assigned in the APT preferences file must be positive or negative integers. They are interpreted as follows (roughly speaking):
#
# P >= 1000
# causes a version to be installed even if this constitutes a downgrade of the package
#
# 990 <= P < 1000
# causes a version to be installed even if it does not come from the target release, unless the installed version is more recent
#
# 500 <= P < 990
# causes a version to be installed unless there is a version available belonging to the target release or the installed version is more recent
#
# 100 <= P < 500
# causes a version to be installed unless there is a version available belonging to some other distribution or the installed version is more recent
#
# 0 < P < 100
# causes a version to be installed only if there is no installed version of the package
#
# P < 0
# prevents the version from being installed
#
# P = 0
# has undefined behaviour, do not use it.