On Fri, 23 May 2008 10:03:44 -0300 Otavio Salvador wrote:

> Francesco Poli <[EMAIL PROTECTED]> writes:
> 
> > On Thu, 22 May 2008 17:49:15 -0300 Otavio Salvador wrote:
> >
> >> Do you mind to refresh your patch against current apt so I can apply
> >> it for next upload?
> >
> > Where "current apt" means apt/0.7.13, right?
> 
> Yes. Please.

Mmmmh, I've just read the script in apt/0.7.13: it doesn't seem to
perform the intended actions, when it finds the cache locked...
What it currently does is:
 * if the cache is locked, it exits successfully
 * if the cache is _not_ locked, waits some time (why? the cache is
accessible, it should go on as quickly as possible!), then it checks
again the cache and exits unsuccessfully if it's locked (wow! the cache
was accessible _before_, but now, after some time, it's locked, so that
we can exit unsuccessfully!)

In other words, unless I am really mistaken, it seems the behavior is
just the opposite of the intended one.


Anyway, the attached patch should apply cleanly to apt/0.7.13, should
fix the above-described misbehavior and should implement my proposal.

Rationale:
If /etc/cron.daily/apt has something to do on the system, then, when
the cache cannot be locked, the script waits for some time and
rechecks.  If the cache is found locked again, then the script cannot
do its job and it exits with errors.
If /etc/cron.daily/apt has absolutely nothing to do on the system, it
does not need to check whether the cache can be locked.

Please consider applying my patch.


Legal details:
I don't know if my patch constitutes a contribution creative enough to
be copyrighted, but anyway, should it turn out to be actually
copyrighted, I hereby release it under the same terms of
/etc/cron.daily/apt, that is to say, under the terms of the GNU General
Public License (GPL), version 2 or later, as published by the Free
Software Foundation.


-- 
 http://frx.netsons.org/doc/index.html#nanodocs
 The nano-document series is here!
..................................................... Francesco Poli .
 GnuPG key fpr == C979 F34B 27CE 5CD8 DC12  31B5 78F4 279B DD6D FCF4
diff -ruN apt-0.7.13/etc/cron.daily/apt apt-0.7.13-patched/etc/cron.daily/apt
--- apt-0.7.13/etc/cron.daily/apt	2008-05-02 17:14:22.000000000 +0200
+++ apt-0.7.13-patched/etc/cron.daily/apt	2008-05-23 23:41:37.000000000 +0200
@@ -192,19 +192,21 @@
     fi
 fi
 
-# check if we can lock the cache and if the cache is clean
-# There's a reasonable chance that someone is already running an apt
-# frontend that has locked the cache, so exit quietly if it is locked.
-if ! apt-get check -q -q 2>/dev/null; then
-    exit 0
-fi
-
-# sleep random amount of time
-random_sleep
-
-# check again if we can access the cache
-if ! apt-get check -q -q 2>/dev/null; then
-    exit 1
+# if needed...
+if [ ! $UpdateInterval -eq 0 ] ||
+   [ ! $DownloadUpgradeableInterval -eq 0 ] ||
+   [ ! $UnattendedUpgradeInterval -eq 0 ] ||
+   [ ! $AutocleanInterval -eq 0 ]; then
+    # check if we can lock the cache and if the cache is clean
+    if ! apt-get check -q -q 2>/dev/null; then
+        # sleep random amount of time
+        random_sleep
+        # check again
+        if ! apt-get check -q -q 2>/dev/null; then
+            echo "$0: could not lock the APT cache"
+            exit 1
+        fi
+    fi
 fi
 
 UPDATE_STAMP=/var/lib/apt/periodic/update-stamp

Attachment: pgpO6zzdeUPeL.pgp
Description: PGP signature

Reply via email to