From a4cfb3c53d7c5dbd7904ccacb1c3f65773ef0c6f Mon Sep 17 00:00:00 2001 From: Martin Schirrmacher Date: Sun, 9 Nov 2014 16:49:57 +0100 Subject: add main menu widgets --- widgets/system_updatestatus/README | 8 +++ widgets/system_updatestatus/system_update_status | 17 ++++++ .../system_update_status.ubuntu | 62 ++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 widgets/system_updatestatus/README create mode 100755 widgets/system_updatestatus/system_update_status create mode 100755 widgets/system_updatestatus/system_update_status.ubuntu (limited to 'widgets/system_updatestatus') diff --git a/widgets/system_updatestatus/README b/widgets/system_updatestatus/README new file mode 100644 index 00000000..3bcf7289 --- /dev/null +++ b/widgets/system_updatestatus/README @@ -0,0 +1,8 @@ +This widget provide information about available updates of the system. + +Since the command usually needs long time to execute this is not called from skin flatPlus. +You have to call the command from the system via cron or at system start. +For example call the command from cron.daily. + +The command can provide to output files: "updates" and "security_updates". The file "security_updates" is optional. + diff --git a/widgets/system_updatestatus/system_update_status b/widgets/system_updatestatus/system_update_status new file mode 100755 index 00000000..50bdc037 --- /dev/null +++ b/widgets/system_updatestatus/system_update_status @@ -0,0 +1,17 @@ +#!/bin/bash + +APTCHECK=/usr/lib/update-notifier/apt-check + +rm -f updates security_updates + +if [ ! -f ${APTCHECK} ] +then + exit +fi + +RET=$(${APTCHECK} 2>&1) + +# updates +echo $RET | cut -d";" -f1 > updates +# security updates +echo $RET | cut -d";" -f2 > security_updates 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 + -- cgit v1.2.3