apt.cron.daily: catch invalid dates due to DST time changes
authorMichael Vogt <michael.vogt@ubuntu.com>
Wed, 8 Apr 2009 20:37:40 +0000 (22:37 +0200)
committerMichael Vogt <michael.vogt@ubuntu.com>
Wed, 8 Apr 2009 20:37:40 +0000 (22:37 +0200)
in the stamp files

debian/apt.cron.daily
debian/changelog

index 32fbafc..5c5ca88 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,
index 94abad0..2b84d16 100644 (file)
@@ -10,8 +10,12 @@ apt (0.7.20.3) UNRELEASED; urgency=low
     - sk.po. Closes: #520403
     - it.po. Closes: #522222
     - sk.po. Closes: #520403
+  
+  [ Jamie Strandboge ]
+  * apt.cron.daily: catch invalid dates due to DST time changes
+    in the stamp files
 
- -- Michael Vogt <mvo@debian.org>  Sun, 08 Feb 2009 11:47:48 +0100
+ -- Michael Vogt <mvo@debian.org>  Wed, 08 Apr 2009 22:37:01 +0200
 
 apt (0.7.20.2) unstable; urgency=medium