82e37249af
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. |
||
---|---|---|
.. | ||
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 treefiles
: copy and remove configuration filesfonts
: regenerate X11 font indicesgroups
: create groups and warn about groups that may be removedicon_themes
: create caches in GTK+ icon theme directoriesinfo_files
: register and unregister GNU info filesocaml_findlib
: update OCaml findlib search pathspermissions
: check and set modes and permissions on special filesshells
: register and unregister login shellsshlibs
: update the shared library cacheusers
: 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 installedpreremove
: tasks performed before files are removedpostinstall
: tasks performed after files are installedpostremove
: 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 exitcompare
: compare two files for equalitycreatefile
: create empty filesdirwalk
: walk a directory tree using depth-first traversalecho
: write to standard output through a bufferlock
: create or release a lock filemakedir
: make a directory hierarchymaketemp
: make unique, temporary filesmatch
: match lines with a fnmatch(3) glob patternplatform
: determine the platform (operating system)quote
: quote strings for use with shell evalrandom
: generate random numbers (badly)refcount
: reference-count system resourcessay
: write to standard output with a tagsort
: sort lines from standard inputtaskfunc
: generic function hook for meta-taskstee
: duplicate writes to standard output into filestruthy
: evaluate truthinessvalid_options
: check validity of option stringsversion
: compare version stringswhich
: 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.