[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#384649: please allow dist-upgrade in cron job



Package: apt
Version: 0.6.45
Severity: wishlist
Tags: patch

Attached patch adds an option to allow dist-upgrade in cron job.  Note that:

  - This option detects when a non-stable dist is present in "apt-cache policy",
    and disables the upgrade in that case.  I think it's reasonably safe to do
    automatic dist-upgrades if you're only running stable.

  - My patch adds a big warning saying that this is an experimental feature, to
    ensure noone enables it without knowing the possible implications.

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16-2-amd64-k8
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_US.UTF-8)
--- debian/apt.cron.daily	2006-03-02 13:48:30.000000000 +0100
+++ /etc/cron.daily/apt	2006-08-24 20:05:56.000000000 +0200
@@ -11,6 +11,11 @@
 #  "APT::Periodic::Download-Upgradeable-Packages=0",
 #  - Do "apt-get upgrade --download-only" every n-days (0=disable)
 # 
+#  "APT::Periodic::Upgrade-Packages=0",
+#  - Do "apt-get dist-upgrade" every n-days (0=disable).  THIS IS AN
+#    EXPERIMENTAL FEATURE, USE IT AT YOUR OWN RISK.  It has no effect when
+#    any distribution other than stable is present in sources.list.
+# 
 #  "APT::Periodic::AutocleanInterval"
 #  - Do "apt-get autoclean" every n-days (0=disable)
 #
@@ -144,6 +149,7 @@
 
 UpdateInterval=0
 DownloadUpgradeableInterval=0
+UpgradeInterval=0
 eval $(apt-config shell UpdateInterval APT::Periodic::Update-Package-Lists DownloadUpgradeableInterval APT::Periodic::Download-Upgradeable-Packages)
 AutocleanInterval=$DownloadUpgradeableInterval
 eval $(apt-config shell AutocleanInterval APT::Periodic::Autoclean)
@@ -176,6 +182,18 @@
     update_stamp $DOWNLOAD_UPGRADEABLE_STAMP
 fi
 
+UPGRADE_STAMP=/var/lib/apt/periodic/upgrade-stamp
+if check_stamp $UPGRADE_STAMP $UpgradeInterval; then
+    # Never attempt this on non-stable distributions!
+    tmp="^     release o=\(Debian\|Ubuntu\),a="
+    if apt-cache policy | grep "${tmp}" | sed -e "s/${tmp}//g" -e "s/,.*//g" | grep -v "^stable$" > /dev/null ; then
+      exit 0
+    fi
+    unset tmp
+    apt-get -qq dist-upgrade 2>/dev/null
+    update_stamp $UPGRADE_STAMP
+fi
+
 AUTOCLEAN_STAMP=/var/lib/apt/periodic/autoclean-stamp
 if check_stamp $AUTOCLEAN_STAMP $AutocleanInterval; then
     apt-get -qq autoclean

Reply to: