How to use @preexec to test for installed packages

Matthew Seaman matthew at FreeBSD.org
Sat Apr 6 17:01:03 UTC 2019


On 06/04/2019 14:58, Matthias Fechner wrote:

> as pkg cannot handle CONFLICTS_INSTALL I tried now to implement this as
> a preinstall command using @preexec in pkg-plist.
> 
> The command should check if a package is installed and stop the
> installation or continue if the package is not installed.
> 
> I tried it with the following command:
> @preexec `/usr/sbin/pkg -N info -e gogs`; if [ $? -eq 0 ]; then echo
> "Gitlab cannot be installed together with gogs as both of them modify
> .ssh/authorized_keys" && exit 1; else echo "Gogs not installed,
> continue."; fi
> 
> But it does not work.
> Now matter if gogs is installed or not.
> If I execute the same line in a shell script, it works fine.
> 
> Anyone an idea?

pkg(8) does handle the most common reason for packages conflicting at
install time -- file name clashes.  Indeed, it does this automatically
with no need of input from porters or maintainers, although it is usual
to add CONFLICTS_INSTALL lines to port Makefiles to document clashes
discovered this way.

However, where there are other reasons for packages to conflict at
install time, then you are correct that pkg doesn't handle this.
There's simply no mechanism to include information about package
conflicts into pkg metadata.

Now, it shouldn't be beyond the bounds of possibility to include this as
input that the pkg solver could use, but it may require quite a deep
dive into the bowels of pkg code.  I doubt that using @preexec commands
in the pkg-plist is going to be very satisfactory -- the end result is
that pkg will end up trying to install conflicting packages and then
abort in the middle of installation, which could well result in an
inconsistent pkg database and user frustration.

 	Cheers,

	Matthew

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 963 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-ports/attachments/20190406/257650d0/attachment.sig>


More information about the freebsd-ports mailing list