I'm interesting in avoiding the installation of the content of a debian package when a file is present in the system, eg. /usr/local/bin/token.
I'd like than the debian package will look for the token in the pre-installation phase (preinst?) and decide to install or not the content afterwards, maybe I could just delete the content to avoid copying anything.
If the
preinst
script exits with an error (non-zero exit code),dpkg
calls thepostrm
script withabort-install
as argument, according to the Debian wiki. So you can test for the file's existence inpreinst
before anything is done, do anexit 1
, if it exists, and do nothing inpostrm
if called withabort-install
and the file exists (since thepostrm
for must be certain that the install failed due to the existence of that file).