Date: Mon, 7 Jun 2010 01:30:41 +0000 From: "b. f." <bf1783@googlemail.com> To: Thomas Rasmussen <thomas@gibfest.dk> Cc: freebsd-ports@freebsd.org Subject: Re: Manually registering dependencies for ports Message-ID: <AANLkTikR1U2fGDRB1aOEv412AjMwabVdh-klCLlMCtiL@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
>Hello, > >I've been wondering about something: When I write a script or webapp that >needs some port to run, like a perl module, I install the needed port and >life is good (tm). A year later when I've completely forgotten about the >script I go do some spring-cleaning of the ports on the server, and I see >some perl module that doesn't have any dependencies, and delete it. Fast >forward a few days when I discover the script doesn't work anymore, cue >face-palm, remove bullet from foot, etc. > >Is there some way I can register a dependency to prevent this ? Like >adding a flag to an installed port to say "something outside of the ports >system depends on this" along with a user specified comment string. A >system like that could result in something like this: > >pkg_delete -x p5-something >pkg_delete: p5-something cant be uninstalled because: "somescript.pl uses >this module, for the love of everything good do not delete it" Yeah, there is. If you don't want to make a local port for your script/program with the module listed as a dependency, then don't muck about +REQUIRED_BY and friends -- that's a pain. Instead, you can use a "package requirements procedure" -- a script or program that is executed before installation/deinstallation, and if it returns non-zero exit status, the installation/deinstallation aborts. You can read about it in pkg_create(1) (look at the -r flag), and pkg_delete(1), of course. For example, say you have a script called /home/foo that requires a port /usr/ports/devel/bar. Add something like the following script as /usr/ports/devel/bar/pkg-req: #!/bin/sh if [ "x$1" = "x" ]; then exit 1; fi if [ "x$2" = "xINSTALL" ]; then exit 0; elif [ "x$2" = "xDEINSTALL" ]; then if [ -f /home/foo ] ; then echo "/home/foo requires this package; aborting deinstallation; use -f to override" exit 1 else exit 0 fi else exit 1 fi When you rebuild and reinstall devel/bar, this script will be added as /var/db/pkg/bar-1.0/+REQUIRE, for example. You can add it manually if bar-1.0 is already installed, and it will take effect when pkg_delete acts on bar-1.0, even without rebuilding. Obviously, you can make this more elaborate: it could examine a list of dependent programs contained in a file that you can edit, and check for each one of them in your PATH, or in specified places. You could edit this list at any time, and the +REQUIRE script would still work. You can keep the script in a location other than /usr/ports/devel/bar/pkg-req, just by using something like: .if${.CURDIR:M*/usr/ports/devel/bar*} PKGREQ="insert full path to script here" .endif in /etc/make.conf, because /usr/ports/Mk/bsd.port.mk will use PKGREQ along with the -r flag in the "do-package" target. You are always free to tie a string around your finger. Just don't tie it too tightly. Regards, b.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTikR1U2fGDRB1aOEv412AjMwabVdh-klCLlMCtiL>