]> git.saurik.com Git - apt.git/blobdiff - debian/apt.cron.daily
Merge remote-tracking branch 'mvo/feature/source-deb822' into debian/experimental...
[apt.git] / debian / apt.cron.daily
index 69f97a36b9bd81186b7c4ade8359a36820a224e0..2616af1dd17fce4b2d94ca0e0d7e3f27726c8ba1 100644 (file)
@@ -8,7 +8,7 @@
 #  Dir "/";
 #  - RootDir for all configuration files
 #
-#  Dir::Cache "var/apt/cache/";
+#  Dir::Cache "var/cache/apt/";
 #  - Set apt package cache directory
 #
 #  Dir::Cache::Archives "archives/";
@@ -197,11 +197,11 @@ check_size_constraints()
                    delta=$(($now-$ctime))
                fi
                if [ $delta -le $MinAge ]; then
-                   debug_echo "skip remove by archive size:  $file, delta=$delta < $MinAgeSec"
+                   debug_echo "skip remove by archive size:  $file, delta=$delta < $MinAge"
                    break
                else
                    # delete oldest file
-                   debug_echo "remove by archive size: $file, delta=$delta >= $MinAgeSec (sec), size=$size >= $MaxSize"
+                   debug_echo "remove by archive size: $file, delta=$delta >= $MinAge (sec), size=$size >= $MaxSize"
                    rm -f $file
                fi
            fi
@@ -289,7 +289,7 @@ random_sleep()
     fi
     if [ -z "$RANDOM" ] ; then
         # A fix for shells that do not have this bash feature.
-       RANDOM=$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -c"1-5")
+       RANDOM=$(( $(dd if=/dev/urandom bs=2 count=1 2> /dev/null | cksum | cut -d' ' -f1) % 32767 ))
     fi
     TIME=$(($RANDOM % $RandomSleep))
     debug_echo "sleeping for $TIME seconds"
@@ -327,12 +327,14 @@ check_power(){
 
 # ------------------------ main ----------------------------
 
-# Backup the 7 last versions of APT's extended_states file
-# shameless copy from dpkg cron
-if cd /var/backups ; then
-    if ! cmp -s apt.extended_states.0 /var/lib/apt/extended_states; then
-       cp -p /var/lib/apt/extended_states apt.extended_states
-       savelog -c 7 apt.extended_states >/dev/null
+if test -r /var/lib/apt/extended_states; then
+    # Backup the 7 last versions of APT's extended_states file
+    # shameless copy from dpkg cron
+    if cd /var/backups ; then
+       if ! cmp -s apt.extended_states.0 /var/lib/apt/extended_states; then
+           cp -p /var/lib/apt/extended_states apt.extended_states
+           savelog -c 7 apt.extended_states >/dev/null
+       fi
     fi
 fi
 
@@ -373,7 +375,7 @@ 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
+if which apt-get >/dev/null && ! eval apt-get check $XAPTOPT $XSTDERR ; then
     debug_echo "error encountered in cron job with \"apt-get check\"."
     exit 0
 fi