]> git.saurik.com Git - apt.git/blobdiff - debian/apt.cron.daily
add a segfault handler to MMap to show the Cache-Limit message, which
[apt.git] / debian / apt.cron.daily
index c358ef012a789fcbedbcbe789727928e677d35fe..5c5ca88c79e8d4fb31740638ae350dec203a240d 100644 (file)
@@ -50,8 +50,25 @@ check_stamp()
     fi
 
     # compare midnight today to midnight the day the stamp was updated
-    stamp=$(date --date=$(date -r $stamp --iso-8601) +%s)
-    now=$(date --date=$(date --iso-8601) +%s)
+    stamp_file="$stamp"
+    stamp=$(date --date=$(date -r $stamp_file --iso-8601) +%s 2>/dev/null)
+    if [ "$?" != "0" ]; then
+        # Due to some timezones returning 'invalid date' for midnight on
+        # certain dates (eg America/Sao_Paulo), if date returns with error
+        # remove the stamp file and return 0. See coreutils bug:
+        # http://lists.gnu.org/archive/html/bug-coreutils/2007-09/msg00176.html
+        rm -f "$stamp_file"
+        return 0
+    fi
+
+    now=$(date --date=$(date --iso-8601) +%s 2>/dev/null)
+    if [ "$?" != "0" ]; then
+        # As above, due to some timezones returning 'invalid date' for midnight
+        # on certain dates (eg America/Sao_Paulo), if date returns with error
+        # return 0.
+        return 0
+    fi
+
     delta=$(($now-$stamp))
 
     # intervall is in days,
@@ -147,7 +164,7 @@ check_size_constraints()
     fi
 }
 
-# sleep for a random intervall of time (default 30min)
+# sleep for a random interval of time (default 30min)
 # (some code taken from cron-apt, thanks)
 random_sleep()
 {