]> git.saurik.com Git - apt.git/commitdiff
debian/apt.cron.daily: Check power after wait, patch by manuel-soto (LP: #705269)
authorJulian Andres Klode <jak@debian.org>
Thu, 21 Apr 2011 07:53:37 +0000 (09:53 +0200)
committerJulian Andres Klode <jak@debian.org>
Thu, 21 Apr 2011 07:53:37 +0000 (09:53 +0200)
debian/apt.cron.daily
debian/changelog

index 75986f5f5f52c6f60e61e44e1f09e080abadafc8..69f97a36b9bd81186b7c4ade8359a36820a224e0 100644 (file)
@@ -305,6 +305,26 @@ debug_echo()
     fi
 }
 
+check_power(){
+    # laptop check, on_ac_power returns:
+    #       0 (true)    System is on main power
+    #       1 (false)   System is not on main power
+    #       255 (false) Power status could not be determined
+    # Desktop systems always return 255 it seems
+    if which on_ac_power >/dev/null; then
+        on_ac_power
+        POWER=$?
+        if [ $POWER -eq 1 ]; then
+           debug_echo "exit: system NOT on main power"
+           return 1
+        elif [ $POWER -ne 0 ]; then
+           debug_echo "power status ($POWER) undetermined, continuing"
+        fi
+        debug_echo "system is on main power."
+    fi
+    return 0
+}
+
 # ------------------------ main ----------------------------
 
 # Backup the 7 last versions of APT's extended_states file
@@ -350,22 +370,7 @@ if [ "$VERBOSE" -ge 3 ]; then
     set -x
 fi
 
-# laptop check, on_ac_power returns:
-#       0 (true)    System is on main power
-#       1 (false)   System is not on main power
-#       255 (false) Power status could not be determined
-# Desktop systems always return 255 it seems
-if which on_ac_power >/dev/null; then
-    on_ac_power
-    POWER=$?
-    if [ $POWER -eq 1 ]; then
-       debug_echo "exit: system NOT on main power"
-       exit 0
-    elif [ $POWER -ne 0 ]; then
-       debug_echo "power status ($POWER) undetermined, continuing"
-    fi
-    debug_echo "system is on main power."
-fi
+check_power || exit 0
 
 # check if we can lock the cache and if the cache is clean
 if which apt-get >/dev/null && ! eval apt-get check -f $XAPTOPT $XSTDERR ; then
@@ -416,6 +421,7 @@ do_cache_backup $BackupArchiveInterval
 # sleep random amount of time to avoid hitting the 
 # mirrors at the same time
 random_sleep
+check_power || exit 0
 
 # include default system language so that "apt-get update" will
 # fetch the right translated package descriptions
index 3f9874bcff3c28459a4d2f70dece847ec6079143..fabe455cba49ae5e50a98e212e4a2b2c241619d6 100644 (file)
@@ -2,6 +2,8 @@ apt (0.8.14.2) UNRELEASED; urgency=low
 
   * apt-pkg/depcache.cc:
     - Really release action groups only once (Closes: #622744)
+  * debian/apt.cron.daily:
+    - Check power after wait, patch by manuel-soto (LP: #705269)
 
  -- Julian Andres Klode <jak@debian.org>  Mon, 18 Apr 2011 10:54:11 +0200