Doinst.sh

From SlackWiki
Revision as of 20:09, 28 May 2009 by Dugan (talk | contribs) (Migrated from old wiki)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This script is usually included under ./install within Slackware packages and contains post-install actions.

Usually automatically created by makepkg for cleaning up and recreating symbolic links, advanced packagers may wish to include further configuration instructions here to be executed after files have been extracted from the .tgz package.

Files

Within packages, doinst.sh is located in install/.

After installation, the doinst.sh scripts are placed in /var/log/scripts, and renamed into the package name.

Examples

Handling symbolic links

The package 'udev-064-i486-2' (from Slackware 10.2), contains a doinst.sh script which includes the following:

( cd etc/hotplug.d/default ; rm -rf 10-udev.hotplug )
( cd etc/hotplug.d/default ; ln -sf /sbin/udevsend 10-udev.hotplug )
( cd usr/man/man8 ; rm -rf udevsend.8.gz )
( cd usr/man/man8 ; ln -sf udevd.8.gz udevsend.8.gz )

Thus, during installation of this package, it will delete 'etc/hotplug.d/default/10-udev.hotplug' and 'usr/man/man8/udevsend.8.gz', then immediately recreate them using symbolic links.

This part of doinst.sh scripts is the most common, and is almost always generated by makepkg automatically during the creation of the package. In fact, 'makepkg' strongly suggests handling symbolic links using the doinst.sh script this way.

Configuration Files

The package 'vim-7.0.109-i486-1' (from Slackware 11.0), contains a doinst.sh script which includes the following:

config() {
 NEW="$1"
 OLD="$(dirname $NEW)/$(basename $NEW .new)"
 # If there's no config file by that name, mv it over:
 if [ ! -r $OLD ]; then
   mv $NEW $OLD
 elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then # toss the redundant copy
   rm $NEW
 fi
 # Otherwise, we leave the .new copy for the admin to consider...
}
config usr/share/vim/vimrc.new

The config() function checks whether the configuration file in the package (vimrc) already exists on the system, or is exactly the same as the new one included in the package; if it exists and is not the same as the package's copy, it will not overwrite the old one but instead will be copied with a .new file extension (vimrc.new).

This is a common, and the preferred, way of dealing with configuration files in Slackware packages.

See Also