forked from anticapitalista/apt-notifier
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmx-updater_reload
executable file
·59 lines (48 loc) · 1.73 KB
/
mx-updater_reload
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
#!/bin/bash
apt-get update
echo
# prepare pinned package handling
AptPref_Opts=""
AptPreferences=""
PinnedPreferences=""
[ "${PATH%%/sbin*}" = "$PATH" ] && PATH="$PATH:/sbin:/usr/sbin"
if grep -sq "^Package" /var/lib/synaptic/preferences && which synaptic >/dev/null; then
PinnedPreferences=/var/lib/synaptic/preferences
fi
if [ -n "$PinnedPreferences" ] && [ -r "$PinnedPreferences" ]; then
eval $(apt-config shell AptPreferences Dir::Etc::preferences)
[ -n "${AptPreferences%%/*}" ] && AptPreferences=/etc/apt/${AptPreferences}
if [ ! -e ${AptPreferences} ]; then
AptPref_Opts=" -o Dir::Etc::preferences=${PinnedPreferences}"
else
tmp_apt_pref=$(mktemp -t apt_tmp_preferences.XXXXXXXXXXXX)
chmod 644 $tmp_apt_pref
trap "rm -f $tmp_apt_pref" EXIT
cat ${AptPreferences} >> $tmp_apt_pref
echo "" >> $tmp_apt_pref
cat $PinnedPreferences >> $tmp_apt_pref
AptPref_Opts=" -o Dir::Etc::preferences=${tmp_apt_pref}"
fi
fi
# UpgradeType: dist-upgrade or upgrade
UpgradeCounts=""
DistUpgradeCounts=""
UpgradeType=$(grep -m1 ^UpgradeType /home/"$(logname)"/.config/apt-notifierrc 2>/dev/null | cut -f2 -d= )
case $UpgradeType in
upgrade) Count=$(LANG=C apt-get -s $AptPref_Opts upgrade | grep -c '^Inst ')
;;
*) Count=$(LANG=C apt-get -s $AptPref_Opts dist-upgrade | grep -c '^Inst ')
;;
esac
case $Count in
0) UpdatesMsg=$(/usr/bin/gettext -d apt-notifier "0 updates available")
;;
1) UpdatesMsg=$(/usr/bin/gettext -d apt-notifier "1 new update available")
;;
*) #UpdatesMsg="`/usr/bin/gettext -d apt-notifier -s $Count \"$n new updates available\"`" # doesn't work?
UpdatesMsg=$(/usr/bin/gettext -d apt-notifier -s $Count "Updates") # so use this
;;
esac
echo $UpdatesMsg
echo
exit