manjaro-update-system.sh 18.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
    else DE=""
    fi
}

Philip Müller's avatar
Philip Müller committed
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
install_nvidia()
{
    msg "Installing Nvidia drivers for you ..."
    mhwd -a pci nonfree 0300
    mhwd -a pci nonfree 0302
    mhwd -a pci nonfree 0380
}

install_free()
{
    msg "Installing free drivers for you ..."
    mhwd -a pci free 0300
    mhwd -a pci free 0302
    mhwd -a pci free 0380
}

Philip Müller's avatar
Philip Müller committed
59
post_upgrade() {
Philip Müller's avatar
Philip Müller committed
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
	# enabling os-prober by default
	input="/etc/default/grub"
	checked=false
	msg "Checking for 'os-prober' setup ..."
	var=$(grep "GRUB_DISABLE_OS_PROBER" $input)
        if [[ $var =~ ^GRUB_DISABLE_OS_PROBER=true ]]; then
	      printf "    'os-prober' was already disabled by the user.\n    We don't change those settings.\n"
	      checked=true
	fi    
	if [[ $var =~ ^GRUB_DISABLE_OS_PROBER=false ]]; then
	      printf "    'os-prober' was already enabled by the user.\n"
	      checked=true
	fi
	if [[ $var =~ ^#GRUB_DISABLE_OS_PROBER=false ]]; then
	      printf "    'os-prober' is disabled by default on this system.\n    Your system won't detect other Operating Systems.\n    For enabling it, uncomment the following in '/etc/default/grub':\n    #GRUB_DISABLE_OS_PROBER=false\n"
              checked=true
	fi
	if [[ $checked == false ]]; then
	      printf "    We will reenable 'os-prober' for you ...\n"
	      printf "\n# Uncomment this option to enable os-prober execution in the grub-mkconfig command\n" >> "$input"
	      printf "GRUB_DISABLE_OS_PROBER=false\n" >> "$input"
	      update-grub
	fi	
Philip Müller's avatar
Philip Müller committed
83
	# nvidia legacy changes (Dec 2020)
Philip Müller's avatar
Philip Müller committed
84 85 86 87 88 89 90 91 92
	if [[ "$(pacman -Qq | grep 'mhwd-db' -m1 -x)" == "mhwd-db" ]] && \
        [[ "$(vercmp $(pacman -Q | grep 'mhwd-db ' -m1 | cut -d' ' -f2) 0.6.5-7)" -lt 0 ]]; then
           msg "Checking if MHWD is needing an update ..."
	   rm $(pacman-conf DBPath)db.lck &> /dev/null
	   pacman -Syy &> /dev/null
	   pacman -S mhwd mhwd-db --noconfirm
	fi
	if [[ ! -e /var/lib/mhwd/db/2020-12-30-update ]]; then
        msg "Checking if graphic drivers need an update ..."	   
Philip Müller's avatar
Philip Müller committed
93 94 95 96
	install_kernel=false
	# remove EOL kernels first
	if [[ "$(pacman -Qq | grep 'linux57' -m1 -x)" == "linux57" ]]; then
	        msg "Removing EOL kernel 5.7.x"
Philip Müller's avatar
Philip Müller committed
97
		pacman -Rcn linux57 --noconfirm
Philip Müller's avatar
Philip Müller committed
98 99 100 101
		install_kernel=true
	fi
	if [[ "$(pacman -Qq | grep 'linux58' -m1 -x)" == "linux58" ]]; then
	        msg "Removing EOL kernel 5.8.x"
Philip Müller's avatar
Philip Müller committed
102
		pacman -Rcn linux58 --noconfirm
Philip Müller's avatar
Philip Müller committed
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
		install_kernel=true
	fi
	if [[ $install_kernel == "true" ]]; then
	if [[ "$(pacman -Qq | grep 'linux54' -m1 -x)" == "linux54" ]]; then
		msg "5.4.x detected. Skipping installing ..."
	else
		msg "Installing 5.4 LTS kernel"
		pacman -S linux54 --noconfirm
	fi
	if [[ "$(pacman -Qq | grep 'linux510' -m1 -x)" == "linux510" ]]; then
		msg "5.10.x detected. Skipping installing ..."
	else
		msg "Installing 5.10 LTS kernel"
		pacman -S linux510 --noconfirm
	fi
	fi
Philip Müller's avatar
Philip Müller committed
119
	if [[ -d /var/lib/mhwd/local/pci/video-nvidia-340xx ]]; then
Philip Müller's avatar
Philip Müller committed
120
		msg "Maintaining video driver nvidia-340xx"
Philip Müller's avatar
Philip Müller committed
121
		rm -r /var/lib/mhwd/local/pci/video-nvidia-340xx
Philip Müller's avatar
Philip Müller committed
122 123
		pacman -Rdd $(pacman -Qq | grep 340xx) --noconfirm
		install_free
Philip Müller's avatar
Philip Müller committed
124
	fi
Philip Müller's avatar
Philip Müller committed
125
	if [[ -d /var/lib/mhwd/local/pci/video-nvidia-418xx ]]; then
Philip Müller's avatar
Philip Müller committed
126
		msg "Maintaining video driver nvidia-418xx"
Philip Müller's avatar
Philip Müller committed
127
		rm -r /var/lib/mhwd/local/pci/video-nvidia-418xx
Philip Müller's avatar
Philip Müller committed
128 129
		pacman -Rdd $(pacman -Qq | grep 418xx) --noconfirm		
		install_nvidia
Philip Müller's avatar
Philip Müller committed
130
	fi	
Philip Müller's avatar
Philip Müller committed
131
	if [[ -d /var/lib/mhwd/local/pci/video-nvidia-430xx ]]; then
Philip Müller's avatar
Philip Müller committed
132
		msg "Maintaining video driver nvidia-430xx"
Philip Müller's avatar
Philip Müller committed
133
		rm -r /var/lib/mhwd/local/pci/video-nvidia-430xx
Philip Müller's avatar
Philip Müller committed
134 135
		pacman -Rdd $(pacman -Qq | grep 430xx) --noconfirm		
		install_nvidia
Philip Müller's avatar
Philip Müller committed
136
	fi
Philip Müller's avatar
Philip Müller committed
137
	if [[ -d /var/lib/mhwd/local/pci/video-nvidia-435xx ]]; then
Philip Müller's avatar
Philip Müller committed
138
		msg "Maintaining video driver nvidia-435xx"
Philip Müller's avatar
Philip Müller committed
139
		rm -r /var/lib/mhwd/local/pci/video-nvidia-435xx
Philip Müller's avatar
Philip Müller committed
140 141
		pacman -Rdd $(pacman -Qq | grep 435xx) --noconfirm		
		install_nvidia
Philip Müller's avatar
Philip Müller committed
142
	fi
Philip Müller's avatar
Philip Müller committed
143
	if [[ -d /var/lib/mhwd/local/pci/video-nvidia-440xx ]]; then
Philip Müller's avatar
Philip Müller committed
144
		msg "Maintaining video driver nvidia-440xx"
Philip Müller's avatar
Philip Müller committed
145
		rm -r /var/lib/mhwd/local/pci/video-nvidia-440xx
Philip Müller's avatar
Philip Müller committed
146 147
		pacman -Rdd $(pacman -Qq | grep 440xx) --noconfirm		
		install_nvidia
Philip Müller's avatar
Philip Müller committed
148
	fi
Philip Müller's avatar
Philip Müller committed
149
	if [[ -d /var/lib/mhwd/local/pci/video-nvidia-450xx ]]; then
Philip Müller's avatar
Philip Müller committed
150
		msg "Maintaining video driver nvidia-450xx"
Philip Müller's avatar
Philip Müller committed
151
		rm -r /var/lib/mhwd/local/pci/video-nvidia-450xx
Philip Müller's avatar
Philip Müller committed
152 153
		pacman -Rdd $(pacman -Qq | grep 450xx) --noconfirm		
		install_nvidia
Philip Müller's avatar
Philip Müller committed
154
	fi
Philip Müller's avatar
Philip Müller committed
155
	if [[ -d /var/lib/mhwd/local/pci/video-nvidia-455xx ]]; then
Philip Müller's avatar
Philip Müller committed
156
		msg "Maintaining video driver nvidia-455xx"
Philip Müller's avatar
Philip Müller committed
157
		rm -r /var/lib/mhwd/local/pci/video-nvidia-455xx
Philip Müller's avatar
Philip Müller committed
158 159
		pacman -Rdd $(pacman -Qq | grep 455xx) --noconfirm		
		install_nvidia
Philip Müller's avatar
Philip Müller committed
160
	fi
Philip Müller's avatar
Philip Müller committed
161
	if [[ -d /var/lib/mhwd/local/pci/video-hybrid-intel-nvidia-340xx-bumblebee ]]; then
Philip Müller's avatar
Philip Müller committed
162
		msg "Maintaining video driver hybrid-intel-nvidia-340xx-bumblebee"
Philip Müller's avatar
Philip Müller committed
163
		rm -r /var/lib/mhwd/local/pci/video-hybrid-intel-nvidia-340xx-bumblebee
Philip Müller's avatar
Philip Müller committed
164 165
		pacman -Rdd $(pacman -Qq | grep 340xx) --noconfirm		
		install_free
Philip Müller's avatar
Philip Müller committed
166
	fi
Philip Müller's avatar
Philip Müller committed
167
	if [[ -d /var/lib/mhwd/local/pci/video-hybrid-intel-nvidia-418xx-bumblebee ]]; then
Philip Müller's avatar
Philip Müller committed
168
		msg "Maintaining video driver hybrid-intel-nvidia-418xx-bumblebee"
Philip Müller's avatar
Philip Müller committed
169
		rm -r /var/lib/mhwd/local/pci/video-hybrid-intel-nvidia-418xx-bumblebee
Philip Müller's avatar
Philip Müller committed
170
		pacman -Rdd $(pacman -Qq | grep 418xx) --noconfirm		
Philip Müller's avatar
Philip Müller committed
171
		msg "Installing free drivers for you ..."
Philip Müller's avatar
Philip Müller committed
172
		install_free
Philip Müller's avatar
Philip Müller committed
173
	fi
Philip Müller's avatar
Philip Müller committed
174
	if [[ -d /var/lib/mhwd/local/pci/video-hybrid-intel-nvidia-430xx-bumblebee ]]; then
Philip Müller's avatar
Philip Müller committed
175
		msg "Maintaining video driver hybrid-intel-nvidia-430xx-bumblebee"
Philip Müller's avatar
Philip Müller committed
176
		rm -r /var/lib/mhwd/local/pci/video-hybrid-intel-nvidia-430xx-bumblebee
Philip Müller's avatar
Philip Müller committed
177
		pacman -Rdd $(pacman -Qq | grep 430xx) --noconfirm			
Philip Müller's avatar
Philip Müller committed
178
		msg "Installing free drivers for you ..."
Philip Müller's avatar
Philip Müller committed
179
		install_free
Philip Müller's avatar
Philip Müller committed
180
	fi
Philip Müller's avatar
Philip Müller committed
181
	if [[ -d /var/lib/mhwd/local/pci/video-hybrid-intel-nvidia-435xx-prime ]]; then
Philip Müller's avatar
Philip Müller committed
182
		msg "Maintaining video driver hybrid-intel-nvidia-435xx-prime"
Philip Müller's avatar
Philip Müller committed
183
		rm -r /var/lib/mhwd/local/pci/video-hybrid-intel-nvidia-435xx-prime
Philip Müller's avatar
Philip Müller committed
184 185
		pacman -Rdd $(pacman -Qq | grep 435xx) --noconfirm		
		install_nvidia
Philip Müller's avatar
Philip Müller committed
186
	fi
Philip Müller's avatar
Philip Müller committed
187
	if [[ -d /var/lib/mhwd/local/pci/video-hybrid-intel-nvidia-440xx-prime ]]; then
Philip Müller's avatar
Philip Müller committed
188
		msg "Maintaining video driver hybrid-intel-nvidia-440xx-prime"
Philip Müller's avatar
Philip Müller committed
189
		rm -r /var/lib/mhwd/local/pci/video-hybrid-intel-nvidia-440xx-prime
Philip Müller's avatar
Philip Müller committed
190 191
		pacman -Rdd $(pacman -Qq | grep 440xx) --noconfirm		
		install_nvidia
Philip Müller's avatar
Philip Müller committed
192
	fi
Philip Müller's avatar
Philip Müller committed
193
	if [[ -d /var/lib/mhwd/local/pci/video-hybrid-intel-nvidia-450xx-prime ]]; then
Philip Müller's avatar
Philip Müller committed
194
		msg "Maintaining video driver hybrid-intel-nvidia-450xx-prime"
Philip Müller's avatar
Philip Müller committed
195
		rm -r /var/lib/mhwd/local/pci/video-hybrid-intel-nvidia-450xx-prime
Philip Müller's avatar
Philip Müller committed
196 197
		pacman -Rdd $(pacman -Qq | grep 450xx) --noconfirm		
		install_nvidia
Philip Müller's avatar
Philip Müller committed
198
	fi
Philip Müller's avatar
Philip Müller committed
199
	if [[ -d /var/lib/mhwd/local/pci/video-hybrid-intel-nvidia-455xx-prime ]]; then
Philip Müller's avatar
Philip Müller committed
200
		msg "Maintaining video driver hybrid-intel-nvidia-455xx-prime"
Philip Müller's avatar
Philip Müller committed
201
		rm -r /var/lib/mhwd/local/pci/video-hybrid-intel-nvidia-455xx-prime
Philip Müller's avatar
Philip Müller committed
202 203
		pacman -Rdd $(pacman -Qq | grep 455xx) --noconfirm		
		install_nvidia
Philip Müller's avatar
Philip Müller committed
204
	fi
Philip Müller's avatar
Philip Müller committed
205
	if [[ -d /var/lib/mhwd/local/pci/video-hybrid-amd-nvidia-435xx-prime ]]; then
Philip Müller's avatar
Philip Müller committed
206
		msg "Maintaining video driver hybrid-amd-nvidia-435xx-prime"
Philip Müller's avatar
Philip Müller committed
207
		rm -r /var/lib/mhwd/local/pci/video-hybrid-amd-nvidia-435xx-prime
Philip Müller's avatar
Philip Müller committed
208 209
		pacman -Rdd $(pacman -Qq | grep 435xx) --noconfirm		
		install_nvidia
Philip Müller's avatar
Philip Müller committed
210
	fi
Philip Müller's avatar
Philip Müller committed
211
	if [[ -d /var/lib/mhwd/local/pci/video-hybrid-amd-nvidia-440xx-prime ]]; then
Philip Müller's avatar
Philip Müller committed
212
		msg "Maintaining video driver hybrid-amd-nvidia-440xx-prime"
Philip Müller's avatar
Philip Müller committed
213
		rm -r /var/lib/mhwd/local/pci/video-hybrid-amd-nvidia-440xx-prime
Philip Müller's avatar
Philip Müller committed
214 215
		pacman -Rdd $(pacman -Qq | grep 440xx) --noconfirm		
		install_nvidia
Philip Müller's avatar
Philip Müller committed
216
	fi
Philip Müller's avatar
Philip Müller committed
217
	if [[ -d /var/lib/mhwd/local/pci/video-hybrid-amd-nvidia-450xx-prime ]]; then
Philip Müller's avatar
Philip Müller committed
218
		msg "Maintaining video driver hybrid-amd-nvidia-450xx-prime"
Philip Müller's avatar
Philip Müller committed
219
		rm -r /var/lib/mhwd/local/pci/video-hybrid-amd-nvidia-450xx-prime
Philip Müller's avatar
Philip Müller committed
220 221
		pacman -Rdd $(pacman -Qq | grep 450xx) --noconfirm		
		install_nvidia
Philip Müller's avatar
Philip Müller committed
222
	fi
Philip Müller's avatar
Philip Müller committed
223
	if [[ -d /var/lib/mhwd/local/pci/video-hybrid-amd-nvidia-455xx-prime ]]; then
Philip Müller's avatar
Philip Müller committed
224
		msg "Maintaining video driver hybrid-amd-nvidia-455xx-prime"
Philip Müller's avatar
Philip Müller committed
225
		rm -r /var/lib/mhwd/local/pci/video-hybrid-amd-nvidia-455xx-prime
Philip Müller's avatar
Philip Müller committed
226 227
		pacman -Rdd $(pacman -Qq | grep 455xx) --noconfirm		
		install_nvidia
Philip Müller's avatar
Philip Müller committed
228
	fi
Philip Müller's avatar
Philip Müller committed
229 230
	touch /var/lib/mhwd/db/2020-12-30-update
	fi
Philip Müller's avatar
Philip Müller committed
231
										
Stefano Capitani's avatar
Stefano Capitani committed
232 233 234
	# 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
Philip Müller's avatar
Philip Müller committed
235 236 237 238
		msg "update hardcode-fixer to latest version"
		rm $(pacman-conf DBPath)db.lck &> /dev/null
		pacman --noconfirm -Syy
		pacman -S --noconfirm hardcode-fixer
Stefano Capitani's avatar
Stefano Capitani committed
239 240 241 242 243
		msg "revert hardcode-fixer changes"
		export LC_ALL=C
		yes | sudo hardcode-fixer -r
	fi

Philip Müller's avatar
Philip Müller committed
244
	# Fix nss 3.51.1-1 upgrade
Philip Müller's avatar
Philip Müller committed
245
	if [[ "$(pacman -Qq | grep 'nss' -m1 -x)" == "nss" ]] && \
246 247
        [[ "$(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
248
		msg "Fixing file conflicts for 'nss' update for you ..."
Philip Müller's avatar
Philip Müller committed
249
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
250 251 252 253 254
		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
255
		[[ "$(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
256
		msg "Fixing file conflicts for 'lib32-nss' update for you ..."
Philip Müller's avatar
Philip Müller committed
257
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
258 259 260 261 262
		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
263
		[[ "$(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
264
		msg "Fixing file conflicts for 'zn_poly' update for you ..."
Philip Müller's avatar
Philip Müller committed
265
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
266 267 268
		pacman -S zn_poly --noconfirm --overwrite usr/lib/libzn_poly-0.9.so
	fi

Philip Müller's avatar
Philip Müller committed
269 270
	# Fix hplip 3.20.3-2 upgrade
	if [[ "$(pacman -Qq | grep 'hplip' -m1)" == "hplip" ]] && \
Philip Müller's avatar
Philip Müller committed
271
		[[ "$(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
272
		msg "Fixing file conflicts for 'hplip' update for you ..."
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 275 276 277 278
		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
279
		[[ "$(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
280
		msg "Fixing file conflicts for 'firewalld' update for you ..."
Philip Müller's avatar
Philip Müller committed
281
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
282 283 284
		pacman -S firewalld --noconfirm --overwrite /usr/lib/python3.8/site-packages/firewall/\*
	fi

Philip Müller's avatar
Philip Müller committed
285 286
	# 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
287 288 289
		[[ "$(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
290
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
291
		pacman --noconfirm -Syy
Philip Müller's avatar
Philip Müller committed
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
		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
314
			rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
315 316 317
			pacman --noconfirm -Syyuu
		fi
	fi
318

Philip Müller's avatar
Philip Müller committed
319
	# Fix dunst upgrading
320 321 322 323
	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
324
			rm $(pacman-conf DBPath)db.lck &> /dev/null
325
			pacman --noconfirm -Rdd dunstify
Philip Müller's avatar
Philip Müller committed
326 327 328
		fi
	fi

329
	# Fix libutf8proc upgrading
330 331 332 333 334
	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
335
			rm $(pacman-conf DBPath)db.lck &> /dev/null
336
			pacman --noconfirm -S libutf8proc
337 338 339
		fi
	fi

Philip Müller's avatar
Philip Müller committed
340
	# Fix config issue in sddm.conf
Philip Müller's avatar
Philip Müller committed
341 342
	if [[ "$(vercmp $2 20180513)" -eq 0 ]] && \
		[[ -e "/etc/sddm.conf" ]]; then
Philip Müller's avatar
Philip Müller committed
343 344 345 346 347 348
		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
349 350 351 352 353
	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
354
			rm $(pacman-conf DBPath)db.lck &> /dev/null
355
			pacman --noconfirm -S js52
Philip Müller's avatar
Philip Müller committed
356 357 358 359
		fi
	fi

	# Fix Firefox upgrading
Philip Müller's avatar
Philip Müller committed
360 361 362 363 364
	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
365 366 367 368
		fi
	fi

	# Fix upgrading sddm version is 0.17.0-4 or less
Philip Müller's avatar
Philip Müller committed
369 370 371
	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
372
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
373 374 375 376 377 378 379 380 381
		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
382 383 384 385
		fi
	fi

	# fix upgrading ca-certificates-utils when version is 20160507-1 or less
Philip Müller's avatar
Philip Müller committed
386 387 388
	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
389
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
390 391 392
		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
393 394 395
	fi

	# fix issue with xorg-server
Philip Müller's avatar
Philip Müller committed
396
	if [[ -L "/usr/lib/xorg/modules/extensions/libglx.xorg" ]]; then
Philip Müller's avatar
Philip Müller committed
397 398 399 400 401
		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
402 403 404 405 406 407
	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
408
		fi
Philip Müller's avatar
Philip Müller committed
409
		msg "Fix mesa-stack ..."
Philip Müller's avatar
Philip Müller committed
410
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
411
		pacman --noconfirm -S $PKG_LIST --force
Philip Müller's avatar
Philip Müller committed
412 413
	fi

Philip Müller's avatar
Philip Müller committed
414 415 416 417
	# 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
418 419
	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
420
			rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
421 422 423 424
			pacman --noconfirm --force -S lib32-libnm-glib
		fi
	fi

Philip Müller's avatar
Philip Müller committed
425 426 427 428
	# 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
429 430 431
	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
432
			rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
433
			pacman --noconfirm --force -S lib32-curl
Philip Müller's avatar
Philip Müller committed
434
		fi
Philip Müller's avatar
Philip Müller committed
435 436
		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
437
			rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
438
			pacman --noconfirm --force -S lib32-curl
Philip Müller's avatar
Philip Müller committed
439 440 441 442
		fi
	fi

	# fix upgrading ttf-dejavu when version is 2.35-1 or less
Philip Müller's avatar
Philip Müller committed
443 444 445
	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
446
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
447
		pacman --noconfirm --force -S ttf-dejavu
Philip Müller's avatar
Philip Müller committed
448 449 450 451
	fi
	
	# fix xfprogs version
	export LANG=C
Philip Müller's avatar
Philip Müller committed
452
	if [[ -n "$(pacman -Qi | grep 'xfsprogs' -m1 | grep Version | grep 1:3)" ]]; then
Philip Müller's avatar
Philip Müller committed
453
		rm $(pacman-conf DBPath)db.lck &> /dev/null
Philip Müller's avatar
Philip Müller committed
454 455
		pacman --noconfirm -S xfsprogs
	fi
Philip Müller's avatar
Philip Müller committed
456
	
Philip Müller's avatar
Philip Müller committed
457 458 459
	if [[ ! -e $(pacman-conf DBPath)db.lck ]]; then
	    touch $(pacman-conf DBPath)db.lck
	fi    
Philip Müller's avatar
Philip Müller committed
460
}