From c0f85755bba9c867ae8ce0ba78b832408d55a25a Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Wed, 17 Dec 2008 23:40:09 -0600 Subject: [PATCH] support /var/run/updates-available cache available in jaunty report cpu speed in GHz if we have a calculator --- bin/cpu-freq | 8 +++++++- bin/updates-available | 46 ++++++++++++++++++++++++++++++------------- debian/control | 1 + 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/bin/cpu-freq b/bin/cpu-freq index d777282c..5a03eb06 100755 --- a/bin/cpu-freq +++ b/bin/cpu-freq @@ -1,3 +1,9 @@ #!/bin/sh -grep -m 1 "^cpu MHz" /proc/cpuinfo | sed "s/^.*: //" | sed "s/\..*$/ MHz/" +mhz=`grep -m 1 "^cpu MHz" /proc/cpuinfo | sed "s/^.*: //" | sed "s/\..*$//"` +if [ $mhz -gt 1000 -a -x /usr/bin/bc ]; then + ghz=$(echo "scale=1; $mhz/1000" | bc) + echo "$ghz GHz" +else + echo "$mhz MHz" +fi diff --git a/bin/updates-available b/bin/updates-available index b57b31a5..a2e48beb 100755 --- a/bin/updates-available +++ b/bin/updates-available @@ -1,20 +1,38 @@ #!/bin/sh +print_updates() { + u=$1 + if [ "$u" = "0" ]; then + echo "" + else + echo "$u!" + fi + exit 0 +} + +cache=/var/run/updates-available u= -if [ -x /usr/lib/update-notifier/apt-check ]; then - u=`/usr/lib/update-notifier/apt-check 2>&1 | tail -n 1 | sed "s/;.*$//"` -elif [ -x /usr/bin/apt-get ]; then - u=`/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst` -elif [ -x /usr/bin/yum ]; then - u=`/usr/bin/yum list updates | grep -c "updates"` -else - echo "?" - exit 1 +# If global updates-available cache is present, use it. Available as of jaunty. +if [ -r $cache ]; then + u=`grep -m 1 "^[0-9]" $cache | sed "s/\s.*$//"` + print_updates $u fi -if [ "$u" = "0" ]; then - echo "" -else - echo "$u!" +# If apt-check binary exists, use it +if [ -x /usr/lib/update-notifier/apt-check ]; then + u=`/usr/lib/update-notifier/apt-check 2>&1 | tail -n 1 | sed "s/;.*$//"` + print_updates $u fi -exit 0 + +# If apt-get exists, use it +if [ -x /usr/bin/apt-get ]; then + u=`/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst` +fi + +# If yum exists, use it +if [ -x /usr/bin/yum ]; then + u=`/usr/bin/yum list updates | grep -c "updates"` +fi + +# If we're here, we have no idea +print_updates "?" diff --git a/debian/control b/debian/control index a68822c0..832a919a 100644 --- a/debian/control +++ b/debian/control @@ -11,6 +11,7 @@ Package: screen-profiles Architecture: all Depends: debconf (>= 0.5) | debconf-2.0, screen, gettext-base, debianutils Recommends: update-notifier-common +Suggests: bc Description: a set of useful profiles and a profile-switcher for GNU screen screen-profiles includes a set of profiles for the GNU screen window manager. These profiles are quite useful on server machines which are not running