]> git.saurik.com Git - apt.git/blobdiff - debian/apt.cron.daily
ensure state-dir exists before coyping cdrom files
[apt.git] / debian / apt.cron.daily
index 6f6dc92a491b2ee8a5dd7e860b497b528f5639ff..2665b65796e9e6a1c07eb88af23d95fc7e0f685a 100644 (file)
@@ -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