manjaro-update-system.sh 11.3 KB
Newer Older
Philip Müller's avatar
Philip Müller committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
err() {
    ALL_OFF="\e[1;0m"
    BOLD="\e[1;1m"
    RED="${BOLD}\e[1;31m"
	local mesg=$1; shift
	printf "${RED}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
}

msg() {
    ALL_OFF="\e[1;0m"
    BOLD="\e[1;1m"
    GREEN="${BOLD}\e[1;32m"
	local mesg=$1; shift
	printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
}

check_pkgs()
{
	local remove=""

    for pkg in ${packages} ; do
        for rmpkg in $(pacman -Qq | grep ${pkg}) ; do
Philip Müller's avatar
Philip Müller committed
23
            if [[ "${pkg}" == "${rmpkg}" ]] ; then
Philip Müller's avatar
Philip Müller committed
24
25
26
27
28
29
30
31
32
33
               removepkgs="${removepkgs} ${rmpkg}"
            fi
        done
    done

    packages="${removepkgs}"
}

detectDE()
{
Philip Müller's avatar
Philip Müller committed
34
35
    if [[ x"$KDE_FULL_SESSION" = x"true" ]]; then DE=kde;
    elif [[ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]]; then DE=gnome;
Philip Müller's avatar
Philip Müller committed
36
37
    elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1` ; then DE=gnome;
    elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
Philip Müller's avatar
Philip Müller committed
38
    elif [[ x"$DESKTOP_SESSION" = x"LXDE" ]]; then DE=lxde;
Philip Müller's avatar
Philip Müller committed
39
40
41
42
43
    else DE=""
    fi
}

post_upgrade() {
Philip Müller's avatar
Philip Müller committed
44

Stefano Capitani's avatar
Stefano Capitani committed
45
46
47
48
49
50
51
52
	# Revert hardcode fixes before we remove post-upgrade hook r539.f812186-5 upgrade
	if [[ "$(pacman -Qq | grep 'hardcode-fixer' -m1)" == "hardcode-fixer" ]] && \
		[[ "$(vercmp $(pacman -Q | grep 'hardcode-fixer' -m1 | cut -d' ' -f2) 1:r539.f812186-5)" -lt 0 ]]; then
		msg "revert hardcode-fixer changes"
		export LC_ALL=C
		yes | sudo hardcode-fixer -r
	fi

Philip Müller's avatar
Philip Müller committed
53
	# Fix nss 3.51.1-1 upgrade
54
55
56
    if [[ "$(pacman -Qq | grep 'nss' -m1 -x)" == "nss" ]] && \
        [[ "$(vercmp $(pacman -Q | grep 'nss ' -m1 | cut -d' ' -f2) 3.51.1-1)" -lt 0 ]]; then

Philip Müller's avatar
Philip Müller committed
57
		msg "Fixing file conflicts for 'nss' update for you ..."
Philip Müller's avatar
Philip Müller committed
58
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
59
60
61
62
63
		pacman -S nss --noconfirm --overwrite /usr/lib\*/p11-kit-trust.so
	fi

	# Fix lib32-nss 3.51.1-1 upgrade
	if [[ "$(pacman -Qq | grep 'lib32-nss' -m1)" == "lib32-nss" ]] && \
Bernhard Landauer's avatar
Bernhard Landauer committed
64
		[[ "$(vercmp $(pacman -Q | grep 'lib32-nss' -m1 | cut -d' ' -f2) 3.51.1-1)" -lt 0 ]]; then
Philip Müller's avatar
Philip Müller committed
65
		msg "Fixing file conflicts for 'lib32-nss' update for you ..."
Philip Müller's avatar
Philip Müller committed
66
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
67
68
69
70
71
		pacman -S lib32-nss --noconfirm --overwrite /usr/lib\*/p11-kit-trust.so
	fi

	# Fix zn_poly 0.9.2-2 upgrade
	if [[ "$(pacman -Qq | grep 'zn_poly' -m1)" == "zn_poly" ]] && \
Bernhard Landauer's avatar
Bernhard Landauer committed
72
		[[ "$(vercmp $(pacman -Q | grep 'zn_poly' -m1 | cut -d' ' -f2) 0.9.2-2)" -lt 0 ]]; then
Philip Müller's avatar
Philip Müller committed
73
		msg "Fixing file conflicts for 'zn_poly' update for you ..."
Philip Müller's avatar
Philip Müller committed
74
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
75
76
77
		pacman -S zn_poly --noconfirm --overwrite usr/lib/libzn_poly-0.9.so
	fi

Philip Müller's avatar
Philip Müller committed
78
79
	# Fix hplip 3.20.3-2 upgrade
	if [[ "$(pacman -Qq | grep 'hplip' -m1)" == "hplip" ]] && \
Philip Müller's avatar
Philip Müller committed
80
		[[ "$(vercmp $(pacman -Q | grep 'hplip' -m1 | cut -d' ' -f2) 1:3.20.3-2)" -lt 0 ]]; then
Philip Müller's avatar
Philip Müller committed
81
		msg "Fixing file conflicts for 'hplip' update for you ..."
Philip Müller's avatar
Philip Müller committed
82
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
83
84
85
86
87
		pacman -S hplip --noconfirm --overwrite /usr/share/hplip/\*
	fi

	# Fix firewalld 0.8.1-2 upgrade
	if [[ "$(pacman -Qq | grep 'firewalld' -m1)" == "firewalld" ]] && \
Philip Müller's avatar
Philip Müller committed
88
		[[ "$(vercmp $(pacman -Q | grep 'firewalld' -m1 | cut -d' ' -f2) 0.8.1-2)" -lt 0 ]]; then
Philip Müller's avatar
Philip Müller committed
89
		msg "Fixing file conflicts for 'firewalld' update for you ..."
Philip Müller's avatar
Philip Müller committed
90
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
91
92
93
		pacman -S firewalld --noconfirm --overwrite /usr/lib/python3.8/site-packages/firewall/\*
	fi

Philip Müller's avatar
Philip Müller committed
94
95
	# replace gtk3-classic with regular upstream gtk3 unless reinstalled since m-s 20191208-1
	if [[ "$(vercmp $2 20191208)" -lt 0 ]] && \
Philip Müller's avatar
Philip Müller committed
96
97
98
		[[ "$(pacman -Qq | grep 'gtk3-classic' -m1)" == "gtk3-classic" ]]; then
		msg "replacing gkt3-classic with regular gtk3 ..."
		msg "If you want to continue using the -classic or -mushroom version please install from the AUR."
Philip Müller's avatar
Philip Müller committed
99
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
100
		pacman --noconfirm -Syy
Philip Müller's avatar
Philip Müller committed
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
		pacman -Rdd --noconfirm gtk3-classic
		pacman -S --noconfirm gtk3
		if [[ "$(pacman -Qq | grep 'lib32-gtk3-classic' -m1)" == "lib32-gtk3-classic" ]]; then
			pacman -Rdd --noconfirm lib32-gtk3-classic
			pacman -S --noconfirm lib32-gtk3
		fi
	fi

	# adjust file permissions for accountsservice >= 0.6.55
	if [[ "$(pacman -Qq | grep 'accountsservice' -m1)" == "accountsservice" ]] && \
		[[ "$(vercmp $(pacman -Q | grep 'accountsservice' -m1 | cut -d' ' -f2) 0.6.55-1)" == -1 ]]; then
		msg "adjusting file permissions for Accountsservice 0.6.55 ..."
		chmod 700 /var/lib/AccountsService/users/
		chmod 755 /var/lib/AccountsService/icons/
	fi

	# Fix systemd upgrade with systemd 239.303 installed
	if [[ "$(pacman -Qq | grep 'systemd' -m1)" == "systemd" ]] && \
		[[ "$(vercmp $(pacman -Q | grep 'systemd' -m1 | cut -d' ' -f2) 239.6)" -gt 0 ]]; then
		if [[ "$(pacman -Qq | grep 'libidn2' -m1)" == "libidn2" ]] && \
		[[ "$(vercmp $(pacman -Q | grep 'libidn2' -m1 | cut -d' ' -f2) 2.1.0-1)" -lt 0 ]]; then
			msg "Your system has an unsupported systemd package. Downgrading it now ..."
Philip Müller's avatar
Philip Müller committed
123
			rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
124
125
126
			pacman --noconfirm -Syyuu
		fi
	fi
127

Philip Müller's avatar
Philip Müller committed
128
	# Fix dunst upgrading
129
130
131
132
	if [[ "$(pacman -Qq | grep 'dunstify' -m1)" == "dunstify" ]] && \
		[[ "$(vercmp $(pacman -Q | grep 'dunstify' -m1 | cut -d' ' -f2) 1.3.2-1)" -le 0 ]]; then
		if [[ -e "/usr/bin/dunstify" ]]; then
			msg "Removing 'dunstify' to prepare smooth 'dunst' upgrade ..."
Philip Müller's avatar
Philip Müller committed
133
			rm $(pacman-conf DBPath)db.lck &> /dev/null
134
			pacman --noconfirm -Rdd dunstify
Philip Müller's avatar
Philip Müller committed
135
136
137
		fi
	fi

138
	# Fix libutf8proc upgrading
139
140
141
142
143
	if [[ "$(pacman -Qq | grep 'libutf8proc' -m1)" == "libutf8proc" ]] && \
		[[ "$(vercmp $(pacman -Q | grep 'libutf8proc' -m1 | cut -d' ' -f2) 2.1.1-3)" -le 0 ]]; then
		if [[ -e "/usr/lib/libutf8proc.so.2" ]]; then
			msg "Fix libutf8proc upgrade ..."
			rm -f /usr/lib/libutf8proc.so.2
Philip Müller's avatar
Philip Müller committed
144
			rm $(pacman-conf DBPath)db.lck &> /dev/null
145
			pacman --noconfirm -S libutf8proc
146
147
148
		fi
	fi

Philip Müller's avatar
Philip Müller committed
149
	# nvidia legacy changes (may 2018)
Philip Müller's avatar
Philip Müller committed
150
151
	if [[ "$(pacman -Qq | grep 'nvidia-utils' -m1)" == "nvidia-utils" ]]; then
		if [[ "$(pacman -Qq | grep 'mhwd-nvidia-390xx' -m1)" != "mhwd-nvidia-390xx" ]]; then
Philip Müller's avatar
Philip Müller committed
152
			msg "Updating mhwd database"
Philip Müller's avatar
Philip Müller committed
153
			rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
154
155
			pacman --noconfirm -S mhwd-db
		fi
Philip Müller's avatar
Philip Müller committed
156
		if [[ -z "$(mhwd | grep " video-nvidia ")" && -n "$(mhwd-gpu | grep nvidia)" ]]; then
Philip Müller's avatar
Philip Müller committed
157
			msg "Maintaining video driver at version nvidia-390xx"
Philip Müller's avatar
Philip Müller committed
158
			rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
159
160
161
			pacman --noconfirm -Rdd $(pacman -Qq | grep nvidia | grep -v mhwd | grep -v toolkit)
			pacman --noconfirm -S $($(pacman -Qq | grep nvidia | grep -v mhwd | grep -v toolkit) \
			| sed 's|nvidia|nvidia-390xx|g')
Philip Müller's avatar
Philip Müller committed
162
163
164
165
166
167
			rm -r /var/lib/mhwd/local/pci/video-nvidia/
			cp -a /var/lib/mhwd/db/pci/graphic_drivers/nvidia-390xx/ /var/lib/mhwd/local/pci/
		fi
	fi

	# Fix config issue in sddm.conf
Philip Müller's avatar
Philip Müller committed
168
169
	if [[ "$(vercmp $2 20180513)" -eq 0 ]] && \
		[[ -e "/etc/sddm.conf" ]]; then
Philip Müller's avatar
Philip Müller committed
170
171
172
173
174
175
		msg "Fix default path config issue in sddm.conf ..."
		cp /etc/sddm.conf /etc/sddm.conf.pacsave
		sed -i -e 's|^.*DefaultPath.*|DefaultPath=/usr/local/sbin:/usr/local/bin:/usr/bin|' /etc/sddm.conf
	fi

	# Fix js52 upgrading
176
177
178
179
180
	if [[ "$(pacman -Qq | grep 'js52' -m1)" == "js52" ]] && \
		[[ "$(vercmp $(pacman -Q | grep 'js52' -m1 | cut -d' ' -f2) 52.7.3-1)" -le 0 ]]; then
		if [[ -e "/usr/lib/libmozjs-52.so.0" ]]; then
			msg "Fix js52 upgrade ..."
			rm -f /usr/lib/libmozjs-52.so.0
Philip Müller's avatar
Philip Müller committed
181
			rm $(pacman-conf DBPath)db.lck &> /dev/null
182
			pacman --noconfirm -S js52
Philip Müller's avatar
Philip Müller committed
183
184
185
186
		fi
	fi

	# Fix Firefox upgrading
Philip Müller's avatar
Philip Müller committed
187
188
189
190
191
	if [[ "$(pacman -Qq | grep 'firefox' -m1)" == "firefox" ]] && \
		[[ "$(vercmp $(pacman -Q | grep 'firefox' -m1 | cut -d' ' -f2) 59.0.1-0)" -le 0 ]]; then
		if [[ -e "/usr/lib/firefox/distribution/distribution.ini" ]]; then
			msg "Fix firefox upgrade ..."
			rm -f /usr/lib/firefox/distribution/distribution.ini
Philip Müller's avatar
Philip Müller committed
192
193
194
195
		fi
	fi

	# Fix upgrading sddm version is 0.17.0-4 or less
Philip Müller's avatar
Philip Müller committed
196
197
198
	if [[ "$(pacman -Qq | grep 'sddm' -m1)" == "sddm" ]] && \
		[[ "$(vercmp $(pacman -Q | grep 'sddm' -m1 | cut -d' ' -f2) 0.17.0-4)" -le 0 ]]; then
		msg "Fix sddm upgrade ..."
Philip Müller's avatar
Philip Müller committed
199
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
200
201
202
203
204
205
206
207
208
		if [[ -e "/etc/sddm.conf" ]]; then
			mv /etc/sddm.conf /etc/sddm.backup
		fi
		pacman --noconfirm -S sddm
		if [[ -e "/etc/sddm.conf" ]]; then
			mv /etc/sddm.conf /etc/sddm.conf.pacnew
		fi
		if [[ -e "/etc/sddm.backup" ]]; then
			mv /etc/sddm.backup /etc/sddm.conf
Philip Müller's avatar
Philip Müller committed
209
210
211
212
		fi
	fi

	# fix upgrading ca-certificates-utils when version is 20160507-1 or less
Philip Müller's avatar
Philip Müller committed
213
214
215
	if [[ "$(pacman -Qq | grep 'ca-certificates-utils' -m1)" == "ca-certificates-utils" ]] && \
		[[ "$(vercmp $(pacman -Q | grep 'ca-certificates-utils' -m1 | cut -d' ' -f2) 20160507-1)" -le 0 ]]; then
		msg "Fix ca-certificates-utils upgrade ..."
Philip Müller's avatar
Philip Müller committed
216
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
217
218
219
		pacman --noconfirm -Syw ca-certificates-utils
		rm /etc/ssl/certs/ca-certificates.crt &> /dev/null
		pacman --noconfirm -S ca-certificates-utils
Philip Müller's avatar
Philip Müller committed
220
221
222
	fi

	# fix issue with xorg-server
Philip Müller's avatar
Philip Müller committed
223
	if [[ -L "/usr/lib/xorg/modules/extensions/libglx.xorg" ]]; then
Philip Müller's avatar
Philip Müller committed
224
225
226
227
228
		msg "Removing depreciated libglx.so symlink ..."
		rm /usr/lib/xorg/modules/extensions/libglx.so &> /dev/null
	fi

	# fix upgrading mesa when version is 17.0.1-1 or less
Philip Müller's avatar
Philip Müller committed
229
230
231
232
233
234
	if [[ "$(pacman -Qq | grep 'mesa' -m1)" == "mesa" ]] && \
		[[ "$(vercmp $(pacman -Q | grep 'mesa' -m1 | cut -d' ' -f2) 17.0.1-1)" -le 0 ]]; then
		PKG_LIST="mhwd mesa libglvnd"
		if [[ "$(pacman -Qq | grep 'lib32-mesa' -m1)" == "lib32-mesa" ]] && \
			[[ "$(vercmp $(pacman -Q | grep 'lib32-mesa' -m1 | cut -d' ' -f2) 17.0.1-1)" -le 0 ]]; then
			PKG_LIST="${PKG_LIST} lib32-mesa lib32-libglvnd"
Philip Müller's avatar
Philip Müller committed
235
		fi
Philip Müller's avatar
Philip Müller committed
236
		msg "Fix mesa-stack ..."
Philip Müller's avatar
Philip Müller committed
237
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
238
		pacman --noconfirm -S $PKG_LIST --force
Philip Müller's avatar
Philip Müller committed
239
240
	fi

Philip Müller's avatar
Philip Müller committed
241
242
243
244
	# avoid upgrading problems when lib32-libnm-glib46 is installed 
	# and lib32-libnm-glib is not, and we want to install lib32-libnm-glib.
	# ldconfig creates varous symlink in /usr/lib32/ from the lib32-libnm-glib46
	# packages but lib32-libnm-glib provides those files.
Philip Müller's avatar
Philip Müller committed
245
246
	if [[ "$(pacman -Qq | grep 'lib32-libnm-glib' -m1)" != "lib32-libnm-glib" ]]; then
		if [[ "$(pacman -Qq | grep 'lib32-libnm-glib46' -m1)" == "lib32-libnm-glib46" ]]; then
Philip Müller's avatar
Philip Müller committed
247
			rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
248
249
250
251
			pacman --noconfirm --force -S lib32-libnm-glib
		fi
	fi

Philip Müller's avatar
Philip Müller committed
252
253
254
255
	# avoid upgrading problems when lib32-libcurl-{gnutls,compat} is
	# installed and lib32-curl is not, and we want to install lib32-curl.
	# ldconfig creates /usr/lib32/libcurl.so.4 from the lib32-libcurl-{gnutls,compat}
	# packages but lib32-curl provides that file.
Philip Müller's avatar
Philip Müller committed
256
257
258
	if [[ "$(pacman -Qq | grep 'lib32-curl' -m1)" != "lib32-curl" ]]; then
		if [[ "$(pacman -Qq | grep 'lib32-libcurl-gnutls' -m1)" == "lib32-libcurl-gnutls" ]] && \
			[[ "$(vercmp $(pacman -Q | grep 'lib32-libcurl-gnutls' -m1 | cut -d' ' -f2) 7.52.1-1)" -le 0 ]]; then
Philip Müller's avatar
Philip Müller committed
259
			rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
260
			pacman --noconfirm --force -S lib32-curl
Philip Müller's avatar
Philip Müller committed
261
		fi
Philip Müller's avatar
Philip Müller committed
262
263
		if [[ "$(pacman -Qq | grep 'lib32-libcurl-compat' -m1)" == "lib32-libcurl-compat" ]] && \
			[[ "$(vercmp $(pacman -Q | grep 'lib32-libcurl-compat' -m1 | cut -d' ' -f2) 7.52.1-1)" -le 0 ]]; then
Philip Müller's avatar
Philip Müller committed
264
			rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
265
			pacman --noconfirm --force -S lib32-curl
Philip Müller's avatar
Philip Müller committed
266
267
268
269
		fi
	fi

	# fix upgrading ttf-dejavu when version is 2.35-1 or less
Philip Müller's avatar
Philip Müller committed
270
271
272
	if [[ "$(pacman -Qq | grep 'ttf-dejavu' -m1)" == "ttf-dejavu" ]] && \
		[[ "$(vercmp $(pacman -Q | grep 'ttf-dejavu' -m1 | cut -d' ' -f2) 2.35-1)" -le 0 ]]; then
		msg "Fix ttf-dejavu upgrade ..."
Philip Müller's avatar
Philip Müller committed
273
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
274
		pacman --noconfirm --force -S ttf-dejavu
Philip Müller's avatar
Philip Müller committed
275
276
277
278
	fi
	
	# fix xfprogs version
	export LANG=C
Philip Müller's avatar
Philip Müller committed
279
	if [[ -n "$(pacman -Qi | grep 'xfsprogs' -m1 | grep Version | grep 1:3)" ]]; then
Philip Müller's avatar
Philip Müller committed
280
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
281
282
283
		pacman --noconfirm -S xfsprogs
	fi
}