I am building a deb that uses debconf to ask if the user really wants to install it (simple boolean template). What is the best way to exit out of the install gracefully, so that at a later time the user could apt-get install pkg-name
and be presented with a fresh config menu?
My current solution is to check the value in the preinst
script like below:
db_get pkg-name/confirm_install
if [ "$RET" = "false" ]; then
db_purge
exit 1
fi
The exit 1
is necessary to keep apt-get
from continuing and thinking the package installed, and the db_purge allows the user to reinstall with a clean debconf db. However, it throws a nasty error:
dpkg: error processing pkg-name (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
pkg-name
E: Sub-process /usr/bin/dpkg returned an error code (1)
Is there a better way to handle exiting an install from inside a deb maintainer script?
I do not believe that there is. From dpkg's point of view, the user asked for the package to be installed, and if that ends up not happening it needs to give as much explanation as possible to show that it didn't happen and why not.
It may be a possibility for you, instead, to allow the package to finish installing cleanly but without enabling whatever extra behavior the package provides, until the user runs a special "reconfigure" script (or the standard dpkg-reconfigure $yourpkg
).