pkgsrc/pkgtools/pkgtasks/files
jlam 82e37249af Update pkgtools/pkgtasks to 1.15.
Fix bug where "ocaml_findlib" and "shells" tasks were not
preserving the ownership and permissions of existing system files,
e.g., /etc/shells, when updating their contents.
2017-08-23 17:53:19 +00:00
..
build-aux
t
aclocal.m4
AUTHORS
cleanup.subr
compare.subr
configure
configure.ac
COPYING
createfile.subr
directories.subr
dirwalk.subr
echo.subr
files.subr
fonts.subr
groups.subr
icon_themes.subr
info_files.subr
load.subr
lock.subr
makedir.subr
Makefile.am
Makefile.in
maketemp.subr
match.subr
NEWS.md
ocaml_findlib.subr
permissions.subr
platform.subr
postinstall.subr
postremove.subr
preinstall.subr
preremove.subr
quote.subr
random.subr
README.md
refcount.subr
refcount_file.subr
say.subr
shells.subr
shlibs.subr
sort.subr
taskfunc.subr
tee.subr
truthy.subr
unittest.subr
usergroup.subr
usergroup_exists.subr
usergroup_FreeBSD.subr
usergroup_Linux.subr
usergroup_MirBSD.subr
usergroup_mock.subr
usergroup_NetBSD.subr
users.subr
valid_options.subr
version.subr.in
which.subr

Package Tasks

pkgtasks is a shell script library to ease writing POSIX-compliant shell scripts to handle common tasks during installation or removal of a package, e.g.,

  • creating groups and users needed by the package

  • creating and removing directories with special permissions and ownership,

  • copying example config files to their final locations during package installation, and removing them during package removal if they don't differ from the example ones,

  • reminding the user of files that may be customized after package installation.

Package tasks have the property of idempotence -- they may be invoked multiple times, but the result must be the same as when invoked once, e.g., the shells task adds an entry to /etc/shells, but will avoid adding the same entry more than once.

Getting sources

The latest version of pkgtasks is 1.15 and was released on August 23th, 2017.

See the release notes for information about the changes in this and all previous releases.

Documentation

A script may load task modules to define shell functions to perform various tasks. A task module is loaded in a POSIX-compliant shell script by adding the following boilerplate to the script:

# Import the task loader.
: ${TASK_MODULE_DIR:=/usr/pkg/share/pkgtasks-1}
. "${TASK_MODULE_DIR}/load.subr"

# Load task modules.
task_load preinstall

The individual package tasks supported by pkgtasks are:

  • directories: create and remove directories outside of package tree
  • files: copy and remove configuration files
  • fonts: regenerate X11 font indices
  • groups: create groups and warn about groups that may be removed
  • icon_themes: create caches in GTK+ icon theme directories
  • info_files: register and unregister GNU info files
  • ocaml_findlib: update OCaml findlib search paths
  • permissions: check and set modes and permissions on special files
  • shells: register and unregister login shells
  • shlibs: update the shared library cache
  • users: create users and warn about users that may be removed

These package tasks support ${PKG_DESTDIR} to manipulate the correct filesystem paths for a destdir-installed package.

For convenience, these have been composed into larger meta-tasks:

  • preinstall: tasks performed before files are installed
  • preremove: tasks performed before files are removed
  • postinstall: tasks performed after files are installed
  • postremove: tasks performed after files are removed

There are also several utility tasks that may be used to write portable scripts:

  • cleanup: run functions upon improper exit
  • compare: compare two files for equality
  • createfile: create empty files
  • dirwalk: walk a directory tree using depth-first traversal
  • echo: write to standard output through a buffer
  • lock: create or release a lock file
  • makedir: make a directory hierarchy
  • maketemp: make unique, temporary files
  • match: match lines with a fnmatch(3) glob pattern
  • platform: determine the platform (operating system)
  • quote: quote strings for use with shell eval
  • random: generate random numbers (badly)
  • refcount: reference-count system resources
  • say: write to standard output with a tag
  • sort: sort lines from standard input
  • taskfunc: generic function hook for meta-tasks
  • tee: duplicate writes to standard output into files
  • truthy: evaluate truthiness
  • valid_options: check validity of option strings
  • version: compare version strings
  • which: locate a program file in the $PATH

The documentation for each of these tasks is in man-page style in the header comments for each task module.