[gnome-shell] Handle previously installed dpkgs



commit 7995f75cfbc54811490fac8ab95ee065d00c3bb7
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Wed Apr 1 16:56:50 2009 -0400

    Handle previously installed dpkgs
    
    Checking return code of dpkg --status doesn't handle removed files
    properly. Get the text status of the package instead and make sure
    that it is 'installed'.
    
    http://bugzilla.gnome.org/show_bug.cgi?id=577456
---
 tools/build/gnome-shell-build-setup.sh |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/tools/build/gnome-shell-build-setup.sh b/tools/build/gnome-shell-build-setup.sh
index cf00c8f..9c182ea 100755
--- a/tools/build/gnome-shell-build-setup.sh
+++ b/tools/build/gnome-shell-build-setup.sh
@@ -41,6 +41,20 @@ fi
 # when running in Xephyr mode, and we should probably change it to use
 # less lame things.
 
+# Can this be simplified? Obvious ways don't handle handle packages
+# that have been installed then removed. ('purged' status, e.g.)
+dpkg_is_installed() {
+    status=`dpkg-query --show --showformat='${Status}' $1 2>/dev/null`
+    if [ $? = 0 ] ; then
+	set $status
+        if [ "$3" = installed ] ; then
+             return 0
+        fi
+    fi
+
+    return 1
+}
+
 if test x$system = xUbuntu -o x$system = xDebian ; then
   reqd=""
   for pkg in \
@@ -50,7 +64,7 @@ if test x$system = xUbuntu -o x$system = xDebian ; then
     libgnomeui-dev librsvg2-dev libwnck-dev libgl1-mesa-dev \
     mesa-common-dev python2.5-dev libreadline5-dev xulrunner-1.9-dev \
     ; do
-      if ! dpkg --status $pkg > /dev/null 2>&1; then
+      if ! dpkg_is_installed $pkg; then
         reqd="$pkg $reqd"
       fi
   done



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]