]> git.saurik.com Git - apt.git/blobdiff - debian/apt.cron.daily
* apt-pkg/deb/debsystem.cc:
[apt.git] / debian / apt.cron.daily
index 3cf1e28f1605584752bc2e958d0fcacd8f081939..8c0e4c416f79c9b277b54c0d14454a099b0f1dd5 100644 (file)
@@ -14,6 +14,9 @@
 #  Dir::Cache::Archive "archives/";
 #  - Set package archive directory
 #
+#  APT::Periodic::Enable "1";
+#  - Enable the update/upgrade script (0=disable)
+#
 #  APT::Periodic::BackupArchiveInterval "0";
 #  - Backup after n-days if archive contents changed.(0=disable)
 #
 #    
 #  APT::Periodic::Download-Upgradeable-Packages "0";
 #  - Do "apt-get upgrade --download-only" every n-days (0=disable)
-# 
+#
+#  APT::Periodic::Download-Upgradeable-Packages-Debdelta "1";
+#  - Use debdelta-upgrade to download updates if available (0=disable)
+#
 #  APT::Periodic::Unattended-Upgrade "0";
 #  - Run the "unattended-upgrade" security upgrade script 
 #    every n-days (0=disabled)
@@ -314,17 +320,32 @@ debug_echo()
 
 # ------------------------ 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
+    fi
+fi
+
 # check apt-config exstance
 if ! which apt-config >/dev/null ; then
        exit 0
 fi
 
+# check if the user really wants to do something
+AutoAptEnable=1  # default is yes
+eval $(apt-config shell AutoAptEnable APT::Periodic::Enable)
+
+if [ $AutoAptEnable -eq 0 ]; then
+    exit 0
+fi
+
 # Set VERBOSE mode from  apt-config (or inherit from environment)
+VERBOSE=0
 eval $(apt-config shell VERBOSE APT::Periodic::Verbose)
 debug_echo "verbose level $VERBOSE"
-if [ -z "$VERBOSE" ]; then
-    VERBOSE="0"
-fi
 if [ "$VERBOSE" -le 2 ]; then
     # quiet for 0,1,2
     XSTDOUT=">/dev/null"
@@ -360,7 +381,7 @@ if which on_ac_power >/dev/null; then
 fi
 
 # check if we can lock the cache and if the cache is clean
-if which apt-get >/dev/null && ! apt-get check $XAPTOPT $XSTDERR ; then
+if which apt-get >/dev/null && ! eval apt-get check -f $XAPTOPT $XSTDERR ; then
     debug_echo "error encountered in cron job with \"apt-get check\"."
     exit 0
 fi
@@ -386,12 +407,19 @@ eval $(apt-config shell AutocleanInterval APT::Periodic::AutocleanInterval)
 BackupArchiveInterval=0
 eval $(apt-config shell BackupArchiveInterval APT::Periodic::BackupArchiveInterval)
 
-# check if we actually have to do anything
+Debdelta=1
+eval $(apt-config shell Debdelta APT::Periodic::Download-Upgradeable-Packages-Debdelta)
+
+# check if we actually have to do anything that requires locking the cache
 if [ $UpdateInterval -eq 0 ] &&
    [ $DownloadUpgradeableInterval -eq 0 ] &&
    [ $UnattendedUpgradeInterval -eq 0 ] &&
    [ $BackupArchiveInterval -eq 0 ] &&
    [ $AutocleanInterval -eq 0 ]; then
+
+    # check cache size
+    check_size_constraints
+
     exit 0
 fi
 
@@ -403,6 +431,7 @@ do_cache_backup $BackupArchiveInterval
 random_sleep
 
 # update package lists
+UPDATED=0
 UPDATE_STAMP=/var/lib/apt/periodic/update-stamp
 if check_stamp $UPDATE_STAMP $UpdateInterval; then
     if eval apt-get $XAPTOPT -y update $XSTDERR; then
@@ -417,6 +446,7 @@ if check_stamp $UPDATE_STAMP $UpdateInterval; then
            debug_echo "dbus signal not send (command not available)"
        fi
        update_stamp $UPDATE_STAMP
+       UPDATED=1
     else
        debug_echo "download updated metadata (error)"
     fi
@@ -426,7 +456,10 @@ fi
        
 # download all upgradeable packages (if it is requested)
 DOWNLOAD_UPGRADEABLE_STAMP=/var/lib/apt/periodic/download-upgradeable-stamp
-if check_stamp $DOWNLOAD_UPGRADEABLE_STAMP $DownloadUpgradeableInterval; then
+if [ $UPDATED -eq 1 ] && check_stamp $DOWNLOAD_UPGRADEABLE_STAMP $DownloadUpgradeableInterval; then
+    if [ $Debdelta -eq 1 ]; then
+        debdelta-upgrade >/dev/null 2>&1 || true
+    fi
     if  eval apt-get $XAPTOPT -y -d dist-upgrade $XSTDERR; then
        update_stamp $DOWNLOAD_UPGRADEABLE_STAMP
        debug_echo "download upgradable (success)"
@@ -439,7 +472,7 @@ fi
 
 # auto upgrade all upgradeable packages
 UPGRADE_STAMP=/var/lib/apt/periodic/upgrade-stamp
-if which unattended-upgrade >/dev/null && check_stamp $UPGRADE_STAMP $UnattendedUpgradeInterval; then
+if [ $UPDATED -eq 1 ] && which unattended-upgrade >/dev/null && check_stamp $UPGRADE_STAMP $UnattendedUpgradeInterval; then
     if unattended-upgrade $XUUPOPT; then
        update_stamp $UPGRADE_STAMP
        debug_echo "unattended-upgrade (success)"