Search code examples
debiandpkgdpkg-buildpackage

Dpkg force stop after preinst


I build my own package and I need to check something on the system before the install process.

So in my dpkg I add a preinst script which is written as follow. As an example I want to check if the arduino-cli command is available:

echo 'Check arduino cli install ...'
if ! command -v arduino-cli &> /dev/null
then
   exit 0
fi

The postinst script seems to be execute. Here is the result of the dpkg execution:

....
dpkg: error processing archive myserver-server_0_amd64.deb (--install):
...

How can I stop the other script ? I thought the exit command should work. https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html


Solution

  • Agreed with what was said in comments.

    Stopping an installation is not the way to go, instead assist the user at the maximum in order to install your package correctly.

    Why asking people to install things manually while you can automate it?

    Thus:

    • Add the dependency to the debian/control file

    OR

    • Add curl dependency to the debian/control file
    • Modify your existing code to install arduino-cli by using
        if ! command -v arduino-cli &> /dev/null
        then
           curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
        fi