-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Subject: /etc/cron.daily/apt should enforce MaxAge/MaxSize regardless of 
AutocleanInterval
Package: apt
Version: 0.7.14
Severity: normal
Tags: patch


I want to keep debs in the APT cache for one month, regardless of whether
they are still available for download or whether I have them installed. So
I'm setting APT::Archives::MaxAge to "30" but not setting
APT::Periodic::AutocleanInterval . However, not setting the latter currently
skips the checks enforcing the former (or MaxSize).

The attached patch fixes this, and also makes random_sleep() only sleep at
all if we're going to hit the mirrors.


- -- Package-specific info:

- -- apt-config dump --

APT "";
APT::Architecture "powerpc";
APT::Build-Essential "";
APT::Build-Essential:: "build-essential";
APT::Install-Recommends "1";
APT::Install-Suggests "0";
APT::Acquire "";
APT::Acquire::Translation "environment";
APT::Authentication "";
APT::Authentication::TrustCDROM "true";
APT::NeverAutoRemove "";
APT::NeverAutoRemove:: "^linux-image.*";
APT::NeverAutoRemove:: "^linux-restricted-modules.*";
APT::Get "";
APT::Get::Show-Upgraded "true";
APT::Cache-Limit "33554432";
APT::Archives "";
APT::Archives::MaxAge "30";
Dir "/";
Dir::State "var/lib/apt/";
Dir::State::lists "lists/";
Dir::State::cdroms "cdroms.list";
Dir::State::userstatus "status.user";
Dir::State::status "/var/lib/dpkg/status";
Dir::Cache "var/cache/apt/";
Dir::Cache::archives "archives/";
Dir::Cache::srcpkgcache "srcpkgcache.bin";
Dir::Cache::pkgcache "pkgcache.bin";
Dir::Etc "etc/apt/";
Dir::Etc::sourcelist "sources.list";
Dir::Etc::sourceparts "sources.list.d";
Dir::Etc::vendorlist "vendors.list";
Dir::Etc::vendorparts "vendors.list.d";
Dir::Etc::main "apt.conf";
Dir::Etc::parts "apt.conf.d";
Dir::Etc::preferences "preferences";
Dir::Bin "";
Dir::Bin::methods "/usr/lib/apt/methods";
Dir::Bin::dpkg "/usr/bin/dpkg";
Dir::Log "var/log/apt";
Dir::Log::Terminal "term.log";
aptitude "";
aptitude::Delete-Unused-Pattern "^linux-image.*$";
DPkg "";
DPkg::Pre-Install-Pkgs "";
DPkg::Pre-Install-Pkgs:: "/usr/sbin/apt-listbugs apt || exit 10";
DPkg::Pre-Install-Pkgs:: "/usr/bin/apt-listchanges --apt || test $? -ne 10";
DPkg::Pre-Install-Pkgs:: "/usr/sbin/dpkg-preconfigure --apt || true";
DPkg::Tools "";
DPkg::Tools::Options "";
DPkg::Tools::Options::/usr/sbin/apt-listbugs "";
DPkg::Tools::Options::/usr/sbin/apt-listbugs::Version "2";
DPkg::Tools::Options::/usr/bin/apt-listchanges "";
DPkg::Tools::Options::/usr/bin/apt-listchanges::Version "2";
DPkg::Post-Invoke "";
DPkg::Post-Invoke:: "if [ -x /usr/bin/debsums ]; then /usr/bin/debsums 
--generate=nocheck -sp /var/cache/apt/archives; fi";
DPkg::Post-Invoke:: "if [ -x /usr/sbin/localepurge ] && [ $(ps w -p $PPID | 
grep -c remove) != 1 ]; then /usr/sbin/localepurge; else exit 0; fi";
DPkg::# "Post-Invoke";
DPkg::#:: "--force-confmiss";
DPkg::#:: "mount -o remount,rw /boot";
DPkg::#:: "mount -o remount,ro /boot";

- -- /etc/apt/preferences --

Package: *
Pin: release a=experimental
Pin-Priority: 102

Package: *
Pin: release o=Ubuntu
Pin-Priority: 101

Package: *
Pin: release l=Secondlife
Pin-Priority: 101

- -- (/etc/apt/sources.list present, but not submitted) --


- -- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable'), (102, 'experimental'), (101, 
'hardy-security'), (101, 'hardy'), (101, 'gutsy-security')
Architecture: powerpc (ppc)

Kernel: Linux 2.6.26.5
Locale: LANG=de_CH.UTF-8, LC_CTYPE=de_CH.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages apt depends on:
ii  debian-archive-keyring   2008.04.16+nmu1 GnuPG archive keys of the Debian a
ii  libc6                    2.7-13          GNU C Library: Shared libraries
ii  libgcc1                  1:4.3.2-1       GCC support library
ii  libstdc++6               4.3.2-1         The GNU Standard C++ Library v3

apt recommends no packages.

Versions of packages apt suggests:
ii  apt-doc                      0.7.14      Documentation for APT
ii  aptitude                     0.4.11.10-1 terminal-based package manager
ii  bzip2                        1.0.5-1     high-quality block-sorting file co
ii  dpkg-dev                     1.14.22     Debian package development tools
ii  lzma                         4.43-14     Compression method of 7z format in
ii  synaptic                     0.62.1      Graphical package manager

- -- no debconf information

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iD8DBQFI5eONWoGvjmrbsgARAu7WAJ40R2pGb4AsIfWDo+fyRJ7CMe3KqQCgl/XB
YOMHPSswiWp9DlfDrgDlvv8=
=jemx
-----END PGP SIGNATURE-----
--- /etc/cron.daily/apt.dpkg-dist       2008-10-03 09:48:01.000000000 +0200
+++ /etc/cron.daily/apt 2008-10-03 10:13:01.000000000 +0200
@@ -79,14 +79,10 @@ update_stamp()
 check_size_constraints()
 {
     # min-age in days
-    MaxAge=0
     MinAge=2
-    MaxSize=0
     CacheDir="var/cache/apt"
     CacheArchive="archives/"
-    eval $(apt-config shell MaxAge APT::Archives::MaxAge)
     eval $(apt-config shell MinAge APT::Archives::MinAge)
-    eval $(apt-config shell MaxSize APT::Archives::MaxSize)
     eval $(apt-config shell Dir Dir)
     eval $(apt-config shell CacheDir Dir::Cache)
     eval $(apt-config shell CacheArchive Dir::Cache::archives)
@@ -151,6 +147,11 @@ check_size_constraints()
 # (some code taken from cron-apt, thanks)
 random_sleep()
 {
+   if [ $UpdateInterval -eq 0 ] &&
+      [ $DownloadUpgradeableInterval -eq 0 ] &&
+      [ $UnattendedUpgradeInterval -eq 0 ]; then
+        return
+    fi
     RandomSleep=1800
     eval $(apt-config shell RandomSleep APT::Periodic::RandomSleep)
     if [ $RandomSleep -eq 0 ]; then
@@ -177,12 +178,18 @@ AutocleanInterval=$DownloadUpgradeableIn
 eval $(apt-config shell AutocleanInterval APT::Periodic::AutocleanInterval)
 UnattendedUpgradeInterval=0
 eval $(apt-config shell UnattendedUpgradeInterval 
APT::Periodic::Unattended-Upgrade)
+MaxAge=0
+eval $(apt-config shell MaxAge APT::Archives::MaxAge)
+MaxSize=0
+eval $(apt-config shell MaxSize APT::Archives::MaxSize)
 
 # check if we actually have to do anything
 if [ $UpdateInterval -eq 0 ] &&
    [ $DownloadUpgradeableInterval -eq 0 ] &&
    [ $UnattendedUpgradeInterval -eq 0 ] &&
-   [ $AutocleanInterval -eq 0 ]; then
+   [ $AutocleanInterval -eq 0 ] &&
+   [ $MaxAge -eq 0 ] &&
+   [ $MaxSize -eq 0 ]; then
     exit 0
 fi
 

Reply via email to