How can I get a 'verbose' apt-get exit code?
I believe this is not a case of XY, and you just want to be able to debug apt-get generally speaking. Under such assumptions here is my answer.
From the man apt.conf
:
DEBUG OPTIONS
Enabling options in the Debug:: section will cause debugging information to be sent to the standard error stream of the program utilizing the apt libraries, or enable special program modes that are primarily useful for debugging the behavior of apt.
Hence, you only need to activate the rules for each of the debugging behaviors of apt-get
:
- Debug::pkgProblemResolver: enables output about the decisions made by dist-upgrade, upgrade, install, remove, purge.
- Debug::NoLocking: disables all file locking. This can be used to run some operations (for instance, apt-get -s install) as a non-root user.
- Debug::pkgDPkgPM: prints out the actual command line each time that apt invokes dpkg(1).
Those 3 are the first that the man page recommends, and the first will help you to debug the first error you show. For the second you may need:
- Debug::Acquire::http: Print information related to downloading packages using HTTP. There is also
https
,ftp
,cdrom
.
The man page has many more, you can list them easily using man apt.conf | grep -A5 -i debug
.
All this should be written using the correct syntax and they are accept boolean values:
Debug::*::* "true";
or if you want to use multiple lines:
Debug {
Acquire {
http "true";
ftp "true";
};
NoLocking "true";
};
If you want to run for only for a instance of apt-get you can use the -o
/--option
switch:
sudo apt-get -o Debug::pkgProblemResolver=true -o Debug::Acquire::http=true -f install
Another method is creating your personalized configuration file and load it with the -c
/--config-file
switch:
sudo apt-get -c debug-apt.conf install hello
About changing the exit codes, I believe you can not unless you change the source code. apt-get
is a state of art piece of software, as such it has advanced methods to debug the process without the need of relying of exit codes.