Pre and post install scripts

You might have remarked by looking at the output of the --install command that some commands are run after the installation, like ldconfig for example. In fact, it is very easy to add scripts to be automatically executed before or after a package's installation.

The preinstall script

The preinstall script should be in ${CONFIGDIR}/preinst, by default /usr/local/etc/urpkg/preinst. The default script that comes with the urpkg tarball does not run any command. It is up to you to change it if you want certain command to be run before any package is installed. Pay attention though, because this script will be invoked with the same privileges you had when you invoked urpkg. They will not be run as the package user. If you want to exclude the preinstall script from being run, you have to use the --no-preinst option.

The postinstall scripts

Every postinstall script should be put in ${CONFIGDIR}/postinst/, by default /usr/local/etc/urpkg/postinst/. Every script here is run after the installation. The scripts are run in an undefined order. By default, ldconfig and a script installing the program's source are run.

The source script is run only if it is passed the source files as an argument. To pass an argument to a postinstall script, use --SCRIPT-arg. For example, if the sources of foo are in a foo.tar.gz file, you would do

    $ sudo urpkg --install --source-arg=foo.tar.gz make install
  

The sources are installed in the package directory, in src/. For a package named foo-1.1 that would be ${PKGDIR}/foo-1.1/src

You can use the --no-postinst option to not run any postinstall script or --exclude-script to exclude a particular one.