How to use @preexec to test for installed packages

Miroslav Lachman 000.fbsd at quip.cz
Sat Apr 6 18:49:03 UTC 2019


Matthew Seaman wrote on 2019/04/06 19:00:
> 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.

Then you can add some fake (empty) file to the plist of package A which 
will conflict with package B and then pkg conflict will work as expected.
But I am not sure we should prevent installation of some package just 
because it uses authorized_keys too.

Miroslav Lachman


More information about the freebsd-ports mailing list