pkgsrc/mk/pkginstall/perms
jlam 83f1c3afae * Add a user-settable variable to tune the default verbosity of the
+INSTALL and +DEINSTALL scripts:

  PKGINSTALL_VERBOSE
	A list of scriptlets that will be verbose and output a message
	noting the actions taken.

	* "all" is a special value that implies all of the other items
	* "fonts" for +FONTS
	* "info-files" for +INFO_FILES

	Default value: "all" for PKG_DEVELOPERs, empty otherwise.

* Be "one-liner brief" when doing the default actions.  For example,
  the info files output now looks like:

	gmake-3.81: registering info file /usr/pkg/info/make.info

  We retain the current verbosity for the CHECK-* actions.
2007-07-12 19:41:46 +00:00

86 lines
1.9 KiB
Text

# $NetBSD: perms,v 1.3 2007/07/12 19:41:46 jlam Exp $
#
# Generate a +PERMS script that sets the special permissions on files
# and directories used by the package.
#
case "${STAGE},$1" in
UNPACK,|UNPACK,+PERMS)
${CAT} > ./+PERMS << 'EOF'
#!@SH@
#
# +PERMS - special file and directory permissions management script
#
# Usage: ./+PERMS [metadatadir]
#
# This script sets special permissions on files and directories needed
# by the package associated with <metadatadir>.
#
# Lines starting with "# PERMS: " are data read by this script that
# name the files and directories required to have special permissions
# in order for this package to function correctly.
#
# # PERMS: /usr/pkg/bin/lppasswd 4711 lp sys
# # PERMS: /usr/pkg/etc/pwd.db 0600
#
# For each PERMS entry, if the file path is relative, then it is taken to
# be relative to ${PKG_PREFIX}.
#
CHGRP="@CHGRP@"
CHMOD="@CHMOD@"
CHOWN="@CHOWN@"
ECHO="@ECHO@"
PWD_CMD="@PWD_CMD@"
SED="@SED@"
SORT="@SORT@"
TEST="@TEST@"
SELF=$0
CURDIR=`${PWD_CMD}`
PKG_METADATA_DIR="${1-${CURDIR}}"
: ${PKGNAME=${PKG_METADATA_DIR##*/}}
: ${PKG_PREFIX=@PREFIX@}
${SED} -n "/^\# PERMS: /{s/^\# PERMS: //;p;}" ${SELF} | ${SORT} -u |
while read file f_mode f_user f_group; do
case $file in
"") continue ;;
[!/]*) file="${PKG_PREFIX}/$file" ;;
esac
${TEST} -f "$file" || continue
filemsg=
case $f_mode/$f_user/$f_group in
//)
filemsg="$file"
;;
[!/]*//)
filemsg="$file (m=$f_mode)"
;;
[!/]*/[!/]*/)
filemsg="$file (o=$f_user, m=$f_mode)"
;;
[!/]*/[!/]*/[!/]*)
filemsg="$file (o=$f_user, g=$f_group, m=$f_mode)"
;;
esac
${ECHO} "${PKGNAME}: setting permissions on $filemsg"
case $f_user in
"") ;;
*) ${CHOWN} $f_user $file ;;
esac
case $f_group in
"") ;;
*) ${CHGRP} $f_group $file ;;
esac
case $f_mode in
"") ;;
*) ${CHMOD} $f_mode $file ;;
esac
done
EOF
${SED} -n "/^\# PERMS: /p" ${SELF} >> ./+PERMS
${CHMOD} +x ./+PERMS
;;
esac