summaryrefslogtreecommitdiff
path: root/widgets/system_updatestatus/system_update_status.ubuntu
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/system_updatestatus/system_update_status.ubuntu')
-rwxr-xr-xwidgets/system_updatestatus/system_update_status.ubuntu62
1 files changed, 62 insertions, 0 deletions
diff --git a/widgets/system_updatestatus/system_update_status.ubuntu b/widgets/system_updatestatus/system_update_status.ubuntu
new file mode 100755
index 00000000..23f4345a
--- /dev/null
+++ b/widgets/system_updatestatus/system_update_status.ubuntu
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+# this script must be call from cron
+# please add a cron entry for this script
+# skin flatPlus only read the file "update_status"
+
+
+rm -f ./update_status
+
+# lent code from apticron, thank you!
+
+# Set $DIRCACHE
+eval `/usr/bin/apt-config shell DIRCACHE Dir::Cache`
+
+NOTIFY_HOLDS="0"
+NOTIFY_NEW="1"
+
+# get the list of packages which are pending an upgrade
+PKGNAMES=`/usr/bin/apt-get -q -y --ignore-hold --allow-unauthenticated -s dist-upgrade | \
+ /bin/grep ^Inst | /usr/bin/cut -d\ -f2 | /usr/bin/sort`
+
+# creating the future last_run file
+TMPFILE="$(mktemp -t apticron.XXXXXXXXXX)"
+for p in $PKGNAMES; do
+ echo $p >> $TMPFILE
+done
+
+# workaround to handle apt-get installing packages hold by aptitude. See #137771.
+APTITUDE_HOLDS=`grep "^State: 2" -B 2 /var/lib/aptitude/pkgstates 2>/dev/null |grep "^Package: .*$" |cut -d" " -f 2`
+DSELECT_HOLDS=`dpkg --get-selections |grep "hold$" |cut -f1`
+
+if [ "$NOTIFY_HOLDS" = "0" ]; then
+ # packages hold by aptitude don't go to the upgrading candidates list
+ for p in $APTITUDE_HOLDS; do
+ PKGNAMES=`echo $PKGNAMES |sed "s/\(^\| \)$p\( \|$\)/ /g;s/^ //g"`
+ done
+ # packages hold by dselect don't go to the upgrading candidates list
+ for p in $DSELECT_HOLDS; do
+ PKGNAMES=`echo $PKGNAMES |sed "s/\(^\| \)$p\( \|$\)/ /g;s/^ //g"`
+ done
+fi
+
+if [ "$NOTIFY_NEW" = "0" ]; then
+ # new packages don't go to the upgrading candidates list (see #531002)
+ for p in $PKGNAMES; do
+ if [ -z "`dpkg -s $p 2>/dev/null| grep '^Status: install ok installed'`" ] ; then
+ PKGNAMES=`echo $PKGNAMES |sed "s/\(^\| \)$p\( \|$\)/ /g;s/^ //g"`
+ fi
+ done
+fi
+
+
+PKGPATH="/${DIRCACHE}archives/"
+for PKG in $PKGNAMES ; do
+ VER=`LC_ALL=C /usr/bin/apt-cache policy $PKG | /bin/grep Candidate: | /usr/bin/cut -f 4 -d \ `
+ VERFILE=`echo "$VER" | /bin/sed -e "s/:/%3a/g"`
+ if ls ${PKGPATH}${PKG}_${VERFILE}_*.deb >& /dev/null ; then
+ DEBS="$DEBS ${PKGPATH}${PKG}_${VERFILE}_*.deb"
+ fi
+ echo $PKG $VER >> ./update_status
+done
+