-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathupdate-check
78 lines (69 loc) · 2.72 KB
/
update-check
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
#!/bin/bash
#set -x
trap 'rm /tmp/{pacmanupdates,aurupdates,ignorepkgs} 2>/dev/null' INT TERM QUIT EXIT
if ! curl -s --max-time 10 google.com >> /dev/null 2>&1; then
exit
elif [[ -e /run/miso/bootmnt ]]; then
exit
fi
nb_pac=$(checkupdates | tee /tmp/pacmanupdates | wc -l)
if [ -x /usr/bin/yay ]; then
nb_aur=$(yay -Qua | tee /tmp/aurupdates | wc -l)
update_command="yay -Syu"
elif [ -x /usr/bin/trizen ]; then
nb_aur=$(trizen -Qua | tee /tmp/aurupdates | wc -l)
update_command="trizen -Syua"
elif [ -x /usr/bin/pacaur ]; then
nb_aur=$(pacaur -Qua | awk '$2 == "aur" {print $3 $4 $5 $6}' | tee /tmp/aurupdates | wc -l)
update_command="pacaur -Syu"
elif [ -x /usr/bin/yaourt ]; then
nb_aur=$(yaourt -Qua | grep "^aur/" | tee /tmp/aurupdates | wc -l)
update_command="yaourt -Syua"
else
nb_aur=0
update_command="sudo pacman -Syu"
fi
if ((nb_pac>0 || nb_aur>0)); then
((nb_aur>0)) && nb_aur="+ ${nb_aur}"
((nb_aur==0)) && unset nb_aur
# Check the Ignore array in pacman.conf
pkgs="$(grep IgnorePkg /etc/pacman.conf | sed -e 's/IgnorePkg =//' -e 's/#.*//')"
grps="$(grep IgnoreGroup /etc/pacman.conf | sed -e 's/IgnoreGroup =//' -e 's/#.*//')"
[[ -n $grps ]] && pkgs="$pkgs $(pacman -Sgq $grps)"
echo $pkgs | sed 's:IgnorePkg = ::g' > /tmp/ignorepkgs
for i in $(cat /tmp/ignorepkgs); do
sed -i -e "/$i/d" /tmp/aurupdates
done
cat /tmp/pacmanupdates
cat /tmp/aurupdates
fi
if [[ -e /var/lib/pacman/sync/core.db ]]; then
# Check if the running kernel is eol
if ! pacman -Ssq "$(mhwd-kernel -li | awk 'NR==1 {print $4}' | tr -d '()')" &> /dev/null; then
msm=$(dunstify -A manjaro-settings-manager,ACCEPT -A true,DECLINE "Your kernel is no longer supported" "Please change kernel with Manjaro Settings Manager")
[[ "$msm" == "manjaro-settings-manager" ]] && manjaro-settings-manager &> /dev/null &
fi
# Branch
if [[ -x /usr/bin/pacman-mirrors ]]; then
branch=$(/usr/bin/pacman-mirrors -G)
capital_branch="$(echo $branch | sed 's/\b[a-z]/\u&/g')"
else
echo "ERROR: 'pacman-mirrors' command not found, is this a valid Manjaro Linux installation?" 1>&2
exit 1
fi
# timestamp update announcements.
last_announcement=$(curl https://forum.manjaro.org/c/announcements/"$branch"-updates.rss 2> /dev/null | awk '/<title>/' | awk -v br="$capital_branch" '/\[br Update\]/{print $3}' | head -n1)
# timestamp of last update
last_update=$(awk '/upgrade/ {print $1}' /var/log/pacman.log | sed 's/\[//' | tail -n1)
if [[ $last_announcement > $last_update ]]; then
answer=$(dunstify -A terminal_update,YES -A true,NO "Update requires user input. Advice in forum announcements." "Run next update in terminal?")
case $answer in
terminal_update)
touch /tmp/.manual_update
;;
*)
true
;;
esac
fi
fi