When creating a PKGBUILD file one can execute hooks at pre_install(), post_install(), etc.
I now have a custom arch linux pacman package that I need some custom checks done before it is installed to determine if it is safe to install or not.
I would like to run my test in the pre_istall() script and have pacman abort the installation if I say so in the script.
So, how can this be accomplished? So far all I have accomplished is getting an error message in the log but pacman continues with the istall...
You could call a command, which returns a non-zero exit-code, to cancel the build process. The simplest command I could think of is
sh -c "exit 1"
, since justexit 1
results in an immediate exit without any proper cleanup.Here is a simple example that checks if a file exists and cancels the build process if not:
However, galaux is right. Usually such checks should happen upstream.