aptitude has poor exit status behaviour
In the course of scripting some aptitude upgrade activity I've found
that (Etch) aptitude's error handling [cough] falls short of optimum
behaviour. In particular it returns an exit status of zero in various
failure situations, which is unhelpful, to say the least.
For example:
Although it helpfully returns 1 if you tell it nonsense ...
# aptitude hshshsh
Unknown command "hshshsh"
aptitude 0.2.15.9
==> exit status 1
... and 'aptitude update' as non-root fails with 255 ...
$ aptitude update
E: Could not open lock file /var/lib/apt/lists/lock -
open (13 Permission denied)
E: Couldn't lock list directory..are you root?
==> exit status 255
... if you're behind a proxy firewall (such as inside my employer's
network) then various kinds of failure all exit with 0 ...
Here's 'aptitude update' as root but with the required firewall proxy
not specified in /etc/apt/apt.conf :
# aptitude update
Err http://ftp.de.debian.org etch Release.gpg
Could not resolve 'ftp.de.debian.org'
Err http://security.debian.org etch/updates Release.gpg
Could not resolve 'security.debian.org'
Ign http://ftp.de.debian.org etch Release
Ign http://ftp.de.debian.org etch/main Packages/DiffIndex
Err http://ftp.de.debian.org etch/main Packages
Could not resolve 'ftp.de.debian.org'
Ign http://security.debian.org etch/updates Release
Ign http://security.debian.org etch/updates/main Packages/DiffIndex
Ign http://security.debian.org etch/updates/contrib Packages/DiffIndex
Err http://security.debian.org etch/updates/main Packages
Could not resolve 'security.debian.org'
Err http://security.debian.org etch/updates/contrib Packages
Could not resolve 'security.debian.org'
Reading package lists...
==> exit status 0
Here's 'aptitude update' with the firewall proxy specified but an
incorrect username/password :
# aptitude update
Ign http://ftp.de.debian.org etch Release.gpg
Ign http://security.debian.org etch/updates Release.gpg
Ign http://ftp.de.debian.org etch Release
Ign http://security.debian.org etch/updates Release
Ign http://ftp.de.debian.org etch/main Packages/DiffIndex
Ign http://security.debian.org etch/updates/main Packages/DiffIndex
Err http://ftp.de.debian.org etch/main Packages
403 Forbidden
Ign http://security.debian.org etch/updates/contrib Packages/DiffIndex
Err http://security.debian.org etch/updates/main Packages
403 Forbidden
Err http://security.debian.org etch/updates/contrib Packages
403 Forbidden
Reading package lists... Done
==> exit status 0
Here's "aptitude update" with the firewall proxy specified but
the previously valid password has expired :
# aptitude update
Ign http://ftp.de.debian.org etch Release.gpg
Ign http://security.debian.org etch/updates Release.gpg
Ign http://ftp.de.debian.org etch Release
Ign http://security.debian.org etch/updates Release
Ign http://ftp.de.debian.org etch/main Packages/DiffIndex
Ign http://security.debian.org etch/updates/main Packages/DiffIndex
Err http://ftp.de.debian.org etch/main Packages
407 Proxy Authentication Required
Ign http://security.debian.org etch/updates/contrib Packages/DiffIndex
Err http://security.debian.org etch/updates/main Packages
407 Proxy Authentication Required
Err http://security.debian.org etch/updates/contrib Packages
407 Proxy Authentication Required
Reading package lists... Done
==> exit status 0
At least that's what happens with my company's firewall. Surely
'aptitude' should be able to do better than that ?
I did a quick test with 'apt-get' on Sarge, and found it returns exit
status 100 in at least some of these situations (I didn't test all of
them), so there seems to have been some regression here :
# apt-get update
Err http://security.debian.org sarge/updates/main Packages
407 Proxy Authentication Required
Err http://de.samba.org sarge/samba Packages
407 Proxy Authentication Required
[...]
Failed to fetch
http://de.samba.org/samba/ftp/Binary_Packages/Debian/dists
/sarge/samba/binary-i386/Packages.gz
407 Proxy Authentication Required
Reading Package Lists...
E: Some index files failed to download, they have been ignored,
or old ones used instead.
==> exit status 100
I found 3 related bug reports against aptitude, all apparently still open :
http://bugs.debian.org/233129
[wishlist; from Feb.2004; aptitude exits with zero on dialup connection
failure]
http://bugs.debian.org/282408
[minor; from Nov.2004; aptitude exits with zero if installation fails or
is cancelled by the user after downloading packages]
http://bugs.debian.org/445035
[important: from Oct.2007; aptitude exits with zero if installation
fails because nonexistent package requested]
Does anyone think another bug report is called for ?
It looks as though it's known that the error handling behaviour
needs attention but it's not high on anybody's TODO list.
And is there a better list to post this to ? A check shows only
debian-dpkg(-bugs) or debian-qa(-packages) as being likely.
Any comments welcome.
Cheers,
Nick Boyce
Reply to: