pkgsrc/mk/pkginstall/files

446 lines
11 KiB
Text
Raw Normal View History

# $NetBSD: files,v 1.4 2007/07/12 19:41:46 jlam Exp $
#
# Generate a +FILES script that reference counts config files that are
# required for the proper functioning of the package.
#
case "${STAGE},$1" in
UNPACK,|UNPACK,+FILES)
${CAT} > ./+FILES << 'EOF'
#!@SH@
#
# +FILES - reference-counted configuration file management script
#
First try at fixing a deficiency in the package +INSTALL scripts, where they don't verify that any pre-existing config files and directories have the correct permissions. For example, if you are upgrading a package to a newer version and the config files and directories used by the package need to have different permissions than in previous versions of the package, then the new package may fail to work because it can't access pre-existing files and directories. This commit improves on this by doing the following: (1) Teach the +FILES and +DIRS scriptlets two new actions "PERMS" and "CHECK-PERMS". "PERMS" fixes permissions on existing files and directories. "CHECK-PERMS" will verify those same bits and warn the user when they are wrong. The "CHECK-PERMS" actions for the two scriptlets are run immediately after the "ADD" actions. (2) Add a new variable PKG_CONFIG_PERMS that controls whether the "PERMS" action will automatically fix permissions. PKG_CONFIG_PERMS is only consulted if PKG_CONFIG is "yes". PKG_CONFIG_PERMS can be set in the shell environment when running pkg_add, e.g.: export PKG_CONFIG=yes export PKG_CONFIG_PERMS=yes pkg_add /path/to/binary/package.tgz The default value of PKG_CONFIG_PERMS embedded into the +INSTALL script may also be set in /etc/mk.conf. This value defaults to "no", so that by default, the +INSTALL script will not modify or destroy any existing configuration files or directories. The +INSTALL script will now always warn you if there are files or directories whose permissions differ from what the package is expecting to use, and if PKG_CONFIG_PERMS is set to "yes", then it will go ahead and fix those permissions for you automatically.
2006-04-25 21:54:39 +02:00
# Usage: ./+FILES ADD|REMOVE|PERMS [metadatadir]
# ./+FILES VIEW-REMOVE depotdir viewdir
First try at fixing a deficiency in the package +INSTALL scripts, where they don't verify that any pre-existing config files and directories have the correct permissions. For example, if you are upgrading a package to a newer version and the config files and directories used by the package need to have different permissions than in previous versions of the package, then the new package may fail to work because it can't access pre-existing files and directories. This commit improves on this by doing the following: (1) Teach the +FILES and +DIRS scriptlets two new actions "PERMS" and "CHECK-PERMS". "PERMS" fixes permissions on existing files and directories. "CHECK-PERMS" will verify those same bits and warn the user when they are wrong. The "CHECK-PERMS" actions for the two scriptlets are run immediately after the "ADD" actions. (2) Add a new variable PKG_CONFIG_PERMS that controls whether the "PERMS" action will automatically fix permissions. PKG_CONFIG_PERMS is only consulted if PKG_CONFIG is "yes". PKG_CONFIG_PERMS can be set in the shell environment when running pkg_add, e.g.: export PKG_CONFIG=yes export PKG_CONFIG_PERMS=yes pkg_add /path/to/binary/package.tgz The default value of PKG_CONFIG_PERMS embedded into the +INSTALL script may also be set in /etc/mk.conf. This value defaults to "no", so that by default, the +INSTALL script will not modify or destroy any existing configuration files or directories. The +INSTALL script will now always warn you if there are files or directories whose permissions differ from what the package is expecting to use, and if PKG_CONFIG_PERMS is set to "yes", then it will go ahead and fix those permissions for you automatically.
2006-04-25 21:54:39 +02:00
# ./+FILES CHECK-ADD|CHECK-REMOVE|CHECK-PERMS [metadatadir]
#
# This script supports two actions, ADD and REMOVE, that will add or
# remove the configuration files needed by the package associated with
# <metadatadir>. The CHECK-ADD action will check whether any files
# needed by the package are missing, and print an informative message
# noting those files. The CHECK-REMOVE action will check whether
# any files needed by the package still exist, and print an informative
# message noting those files. The CHECK-ADD and CHECK-REMOVE actions
# return non-zero if they detect either missing or existing files,
# respectively. The VIEW-REMOVE action will remove from <viewdir> the
First try at fixing a deficiency in the package +INSTALL scripts, where they don't verify that any pre-existing config files and directories have the correct permissions. For example, if you are upgrading a package to a newer version and the config files and directories used by the package need to have different permissions than in previous versions of the package, then the new package may fail to work because it can't access pre-existing files and directories. This commit improves on this by doing the following: (1) Teach the +FILES and +DIRS scriptlets two new actions "PERMS" and "CHECK-PERMS". "PERMS" fixes permissions on existing files and directories. "CHECK-PERMS" will verify those same bits and warn the user when they are wrong. The "CHECK-PERMS" actions for the two scriptlets are run immediately after the "ADD" actions. (2) Add a new variable PKG_CONFIG_PERMS that controls whether the "PERMS" action will automatically fix permissions. PKG_CONFIG_PERMS is only consulted if PKG_CONFIG is "yes". PKG_CONFIG_PERMS can be set in the shell environment when running pkg_add, e.g.: export PKG_CONFIG=yes export PKG_CONFIG_PERMS=yes pkg_add /path/to/binary/package.tgz The default value of PKG_CONFIG_PERMS embedded into the +INSTALL script may also be set in /etc/mk.conf. This value defaults to "no", so that by default, the +INSTALL script will not modify or destroy any existing configuration files or directories. The +INSTALL script will now always warn you if there are files or directories whose permissions differ from what the package is expecting to use, and if PKG_CONFIG_PERMS is set to "yes", then it will go ahead and fix those permissions for you automatically.
2006-04-25 21:54:39 +02:00
# links to the configuration files in <depotdir>. The PERMS action
# will correct any ownership or permission discrepancies between the
# existing files and the data in this script, and the CHECK-PERMS
# action will check whether any files have the wrong ownership or
# permission and print an informative message noting those files. The
# CHECK-PERMS action will return non-zero if it detects files with
# wrong ownership or permissions.
#
# Lines starting with "# FILE: " are data read by this script that
# name the files that this package requires to exist to function
# correctly, along with the locations of the example files, e.g.
#
# # FILE: /etc/bar.conf c /example/bar.conf
# # FILE: /etc/baz/conf c /example/baz.conf 0600 foo-user foo-group
#
# For each FILE entry, if the file path is relative, then it is taken to
# be relative to ${PKG_PREFIX}.
#
# The second field in each FILE entry is a set of flags with the following
# meaning:
#
# c file is copied into place
# f ignore ${PKG_CONFIG}
# r file is an rc.d script (consider ${PKG_RCD_SCRIPTS})
#
First try at fixing a deficiency in the package +INSTALL scripts, where they don't verify that any pre-existing config files and directories have the correct permissions. For example, if you are upgrading a package to a newer version and the config files and directories used by the package need to have different permissions than in previous versions of the package, then the new package may fail to work because it can't access pre-existing files and directories. This commit improves on this by doing the following: (1) Teach the +FILES and +DIRS scriptlets two new actions "PERMS" and "CHECK-PERMS". "PERMS" fixes permissions on existing files and directories. "CHECK-PERMS" will verify those same bits and warn the user when they are wrong. The "CHECK-PERMS" actions for the two scriptlets are run immediately after the "ADD" actions. (2) Add a new variable PKG_CONFIG_PERMS that controls whether the "PERMS" action will automatically fix permissions. PKG_CONFIG_PERMS is only consulted if PKG_CONFIG is "yes". PKG_CONFIG_PERMS can be set in the shell environment when running pkg_add, e.g.: export PKG_CONFIG=yes export PKG_CONFIG_PERMS=yes pkg_add /path/to/binary/package.tgz The default value of PKG_CONFIG_PERMS embedded into the +INSTALL script may also be set in /etc/mk.conf. This value defaults to "no", so that by default, the +INSTALL script will not modify or destroy any existing configuration files or directories. The +INSTALL script will now always warn you if there are files or directories whose permissions differ from what the package is expecting to use, and if PKG_CONFIG_PERMS is set to "yes", then it will go ahead and fix those permissions for you automatically.
2006-04-25 21:54:39 +02:00
AWK="@AWK@"
CAT="@CAT@"
CP="@CP@"
CHGRP="@CHGRP@"
CHMOD="@CHMOD@"
CHOWN="@CHOWN@"
CMP="@CMP@"
ECHO="@ECHO@"
GREP="@GREP@"
First try at fixing a deficiency in the package +INSTALL scripts, where they don't verify that any pre-existing config files and directories have the correct permissions. For example, if you are upgrading a package to a newer version and the config files and directories used by the package need to have different permissions than in previous versions of the package, then the new package may fail to work because it can't access pre-existing files and directories. This commit improves on this by doing the following: (1) Teach the +FILES and +DIRS scriptlets two new actions "PERMS" and "CHECK-PERMS". "PERMS" fixes permissions on existing files and directories. "CHECK-PERMS" will verify those same bits and warn the user when they are wrong. The "CHECK-PERMS" actions for the two scriptlets are run immediately after the "ADD" actions. (2) Add a new variable PKG_CONFIG_PERMS that controls whether the "PERMS" action will automatically fix permissions. PKG_CONFIG_PERMS is only consulted if PKG_CONFIG is "yes". PKG_CONFIG_PERMS can be set in the shell environment when running pkg_add, e.g.: export PKG_CONFIG=yes export PKG_CONFIG_PERMS=yes pkg_add /path/to/binary/package.tgz The default value of PKG_CONFIG_PERMS embedded into the +INSTALL script may also be set in /etc/mk.conf. This value defaults to "no", so that by default, the +INSTALL script will not modify or destroy any existing configuration files or directories. The +INSTALL script will now always warn you if there are files or directories whose permissions differ from what the package is expecting to use, and if PKG_CONFIG_PERMS is set to "yes", then it will go ahead and fix those permissions for you automatically.
2006-04-25 21:54:39 +02:00
LS="@LS@"
MKDIR="@MKDIR@"
MV="@MV@"
PWD_CMD="@PWD_CMD@"
RM="@RM@"
RMDIR="@RMDIR@"
SED="@SED@"
SORT="@SORT@"
TEST="@TEST@"
TRUE="@TRUE@"
SELF=$0
ACTION=$1
: ${PKG_PREFIX=@PREFIX@}
case "${PKG_CONFIG:-@PKG_CONFIG@}" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
_PKG_CONFIG=yes
;;
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
_PKG_CONFIG=no
;;
esac
First try at fixing a deficiency in the package +INSTALL scripts, where they don't verify that any pre-existing config files and directories have the correct permissions. For example, if you are upgrading a package to a newer version and the config files and directories used by the package need to have different permissions than in previous versions of the package, then the new package may fail to work because it can't access pre-existing files and directories. This commit improves on this by doing the following: (1) Teach the +FILES and +DIRS scriptlets two new actions "PERMS" and "CHECK-PERMS". "PERMS" fixes permissions on existing files and directories. "CHECK-PERMS" will verify those same bits and warn the user when they are wrong. The "CHECK-PERMS" actions for the two scriptlets are run immediately after the "ADD" actions. (2) Add a new variable PKG_CONFIG_PERMS that controls whether the "PERMS" action will automatically fix permissions. PKG_CONFIG_PERMS is only consulted if PKG_CONFIG is "yes". PKG_CONFIG_PERMS can be set in the shell environment when running pkg_add, e.g.: export PKG_CONFIG=yes export PKG_CONFIG_PERMS=yes pkg_add /path/to/binary/package.tgz The default value of PKG_CONFIG_PERMS embedded into the +INSTALL script may also be set in /etc/mk.conf. This value defaults to "no", so that by default, the +INSTALL script will not modify or destroy any existing configuration files or directories. The +INSTALL script will now always warn you if there are files or directories whose permissions differ from what the package is expecting to use, and if PKG_CONFIG_PERMS is set to "yes", then it will go ahead and fix those permissions for you automatically.
2006-04-25 21:54:39 +02:00
case "${PKG_CONFIG_PERMS:-@PKG_CONFIG_PERMS@}" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
_PKG_CONFIG_PERMS=yes
;;
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
_PKG_CONFIG_PERMS=no
;;
esac
case "${PKG_RCD_SCRIPTS:-@PKG_RCD_SCRIPTS@}" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
_PKG_RCD_SCRIPTS=yes
;;
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
_PKG_RCD_SCRIPTS=no
;;
esac
case $ACTION in
VIEW-REMOVE)
DEPOTDIR="$2"
VIEWDIR="$3"
First try at fixing a deficiency in the package +INSTALL scripts, where they don't verify that any pre-existing config files and directories have the correct permissions. For example, if you are upgrading a package to a newer version and the config files and directories used by the package need to have different permissions than in previous versions of the package, then the new package may fail to work because it can't access pre-existing files and directories. This commit improves on this by doing the following: (1) Teach the +FILES and +DIRS scriptlets two new actions "PERMS" and "CHECK-PERMS". "PERMS" fixes permissions on existing files and directories. "CHECK-PERMS" will verify those same bits and warn the user when they are wrong. The "CHECK-PERMS" actions for the two scriptlets are run immediately after the "ADD" actions. (2) Add a new variable PKG_CONFIG_PERMS that controls whether the "PERMS" action will automatically fix permissions. PKG_CONFIG_PERMS is only consulted if PKG_CONFIG is "yes". PKG_CONFIG_PERMS can be set in the shell environment when running pkg_add, e.g.: export PKG_CONFIG=yes export PKG_CONFIG_PERMS=yes pkg_add /path/to/binary/package.tgz The default value of PKG_CONFIG_PERMS embedded into the +INSTALL script may also be set in /etc/mk.conf. This value defaults to "no", so that by default, the +INSTALL script will not modify or destroy any existing configuration files or directories. The +INSTALL script will now always warn you if there are files or directories whose permissions differ from what the package is expecting to use, and if PKG_CONFIG_PERMS is set to "yes", then it will go ahead and fix those permissions for you automatically.
2006-04-25 21:54:39 +02:00
${TEST} -n "${DEPOTDIR}" -a -n "${VIEWDIR}" || exit 0
;;
*)
CURDIR=`${PWD_CMD}`
PKG_METADATA_DIR="${2-${CURDIR}}"
: ${PKGNAME=${PKG_METADATA_DIR##*/}}
: ${PKG_DBDIR=${PKG_METADATA_DIR%/*}}
: ${PKG_REFCOUNT_DBDIR=${PKG_DBDIR}.refcount}
PKG_REFCOUNT_FILES_DBDIR="${PKG_REFCOUNT_DBDIR}/files"
;;
esac
exitcode=0
case $ACTION in
ADD)
${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -u |
while read file f_flags f_eg f_mode f_user f_group; do
case $file in
"") continue ;;
[!/]*) file="${PKG_PREFIX}/$file" ;;
esac
case $f_flags in
*c*) ;;
*) continue ;;
esac
case $f_eg in
"") continue ;;
[!/]*) f_eg="${PKG_PREFIX}/$f_eg" ;;
esac
shadow_dir="${PKG_REFCOUNT_FILES_DBDIR}$file"
perms="$shadow_dir/+PERMISSIONS"
preexist="$shadow_dir/+PREEXISTING"
token="$shadow_dir/${PKGNAME}"
if ${TEST} ! -d "$shadow_dir"; then
${MKDIR} $shadow_dir
${TEST} ! -f "$file" ||
${ECHO} "${PKGNAME}" > $preexist
fi
if ${TEST} -f "$token" && \
${GREP} "^${PKG_METADATA_DIR}$" $token >/dev/null; then
:
else
${ECHO} "${PKG_METADATA_DIR}" >> $token
fi
case $f_mode$f_user$f_group in
"") ;;
*) ${ECHO} "$f_mode $f_user $f_group" > $perms ;;
esac
if ${TEST} ! -f "$file" -a ! -f "$f_eg"; then
:
else
case "$f_flags:$_PKG_CONFIG:$_PKG_RCD_SCRIPTS" in
*f*:*:*|[!r]:yes:*|[!r][!r]:yes:*|[!r][!r][!r]:yes:*|*r*:yes:yes)
if ${TEST} -f "$file"; then
${ECHO} "${PKGNAME}: $file already exists"
elif ${TEST} -f "$f_eg"; then
${ECHO} "${PKGNAME}: copying $f_eg to $file"
${CP} $f_eg $file
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
fi
;;
esac
fi
done
;;
REMOVE)
${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru |
while read file f_flags f_eg f_mode f_user f_group; do
case $file in
"") continue ;;
[!/]*) file="${PKG_PREFIX}/$file" ;;
esac
case $f_flags in
*c*) ;;
*) continue ;;
esac
case $f_eg in
"") continue ;;
[!/]*) f_eg="${PKG_PREFIX}/$f_eg" ;;
esac
shadow_dir="${PKG_REFCOUNT_FILES_DBDIR}$file"
perms="$shadow_dir/+PERMISSIONS"
preexist="$shadow_dir/+PREEXISTING"
token="$shadow_dir/${PKGNAME}"
tokentmp="$token.tmp.$$"
if ${TEST} -f "$token" && \
${GREP} "^${PKG_METADATA_DIR}$" $token >/dev/null; then
${CAT} "$token" | ${GREP} -v "^${PKG_METADATA_DIR}$" > $tokentmp
case `${CAT} $tokentmp | ${SED} -n "$="` in
"")
if ${TEST} -f "$preexist"; then
:
elif ${TEST} -f "$file" -a -f "$f_eg" && \
${CMP} -s "$file" "$f_eg"; then
case "$f_flags:$_PKG_CONFIG:$_PKG_RCD_SCRIPTS" in
*f*:*:*|[!r]:yes:*|[!r][!r]:yes:*|[!r][!r][!r]:yes:*|*r*:yes:yes)
${RM} -f "$file"
;;
esac
fi
${RM} -f $perms $preexist $token $token.tmp.*
${RMDIR} -p $shadow_dir 2>/dev/null || ${TRUE}
;;
*)
${MV} -f $tokentmp $token
;;
esac
fi
done
;;
First try at fixing a deficiency in the package +INSTALL scripts, where they don't verify that any pre-existing config files and directories have the correct permissions. For example, if you are upgrading a package to a newer version and the config files and directories used by the package need to have different permissions than in previous versions of the package, then the new package may fail to work because it can't access pre-existing files and directories. This commit improves on this by doing the following: (1) Teach the +FILES and +DIRS scriptlets two new actions "PERMS" and "CHECK-PERMS". "PERMS" fixes permissions on existing files and directories. "CHECK-PERMS" will verify those same bits and warn the user when they are wrong. The "CHECK-PERMS" actions for the two scriptlets are run immediately after the "ADD" actions. (2) Add a new variable PKG_CONFIG_PERMS that controls whether the "PERMS" action will automatically fix permissions. PKG_CONFIG_PERMS is only consulted if PKG_CONFIG is "yes". PKG_CONFIG_PERMS can be set in the shell environment when running pkg_add, e.g.: export PKG_CONFIG=yes export PKG_CONFIG_PERMS=yes pkg_add /path/to/binary/package.tgz The default value of PKG_CONFIG_PERMS embedded into the +INSTALL script may also be set in /etc/mk.conf. This value defaults to "no", so that by default, the +INSTALL script will not modify or destroy any existing configuration files or directories. The +INSTALL script will now always warn you if there are files or directories whose permissions differ from what the package is expecting to use, and if PKG_CONFIG_PERMS is set to "yes", then it will go ahead and fix those permissions for you automatically.
2006-04-25 21:54:39 +02:00
PERMS)
${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru |
while read file f_flags f_eg f_mode f_user f_group; do
case $_PKG_CONFIG:$_PKG_CONFIG_PERMS in
yes:yes) ;;
First try at fixing a deficiency in the package +INSTALL scripts, where they don't verify that any pre-existing config files and directories have the correct permissions. For example, if you are upgrading a package to a newer version and the config files and directories used by the package need to have different permissions than in previous versions of the package, then the new package may fail to work because it can't access pre-existing files and directories. This commit improves on this by doing the following: (1) Teach the +FILES and +DIRS scriptlets two new actions "PERMS" and "CHECK-PERMS". "PERMS" fixes permissions on existing files and directories. "CHECK-PERMS" will verify those same bits and warn the user when they are wrong. The "CHECK-PERMS" actions for the two scriptlets are run immediately after the "ADD" actions. (2) Add a new variable PKG_CONFIG_PERMS that controls whether the "PERMS" action will automatically fix permissions. PKG_CONFIG_PERMS is only consulted if PKG_CONFIG is "yes". PKG_CONFIG_PERMS can be set in the shell environment when running pkg_add, e.g.: export PKG_CONFIG=yes export PKG_CONFIG_PERMS=yes pkg_add /path/to/binary/package.tgz The default value of PKG_CONFIG_PERMS embedded into the +INSTALL script may also be set in /etc/mk.conf. This value defaults to "no", so that by default, the +INSTALL script will not modify or destroy any existing configuration files or directories. The +INSTALL script will now always warn you if there are files or directories whose permissions differ from what the package is expecting to use, and if PKG_CONFIG_PERMS is set to "yes", then it will go ahead and fix those permissions for you automatically.
2006-04-25 21:54:39 +02:00
*) continue ;;
esac
case $file in
"") continue ;;
[!/]*) file="${PKG_PREFIX}/$file" ;;
esac
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
;;
VIEW-REMOVE)
${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru |
while read file f_flags f_eg f_mode f_user f_group; do
case $file in
${DEPOTDIR}/*) link="${VIEWDIR}/${file#${DEPOTDIR}/}" ;;
[!/]*) link="${VIEWDIR}/$file" ;;
*) continue ;;
esac
dir="${link%[^/]*}"
if ${TEST} -h "$link"; then
${RM} -f $link
${RMDIR} -p $dir 2>/dev/null || ${TRUE}
fi
done
;;
CHECK-ADD)
${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru |
{ while read file f_flags f_eg f_mode f_user f_group; do
case $file in
"") continue ;;
[!/]*) file="${PKG_PREFIX}/$file" ;;
esac
${TEST} ! -f "$file" || continue
case $f_flags in
*c*) ;;
*) continue ;;
esac
case $f_eg in
"") continue ;;
[!/]*) f_eg="${PKG_PREFIX}/$f_eg" ;;
esac
case "$printed_header" in
yes) ;;
*) printed_header=yes
${ECHO} "==========================================================================="
${ECHO} "The following files should be created for ${PKGNAME}:"
;;
esac
${ECHO} ""
case $f_mode:$f_user:$f_group in
::)
${ECHO} " $file"
;;
[!:]*::)
${ECHO} " $file (m=$f_mode)"
;;
[!:]*:[!:]*:)
${ECHO} " $file (m=$f_mode, o=$f_user)"
;;
[!:]*:[!:]*:[!:]*)
${ECHO} " $file (m=$f_mode, o=$f_user, g=$f_group)"
;;
esac
${TEST} ! -f "$f_eg" || ${ECHO} " [$f_eg]"
done
case "$printed_header" in
yes) ${ECHO} ""
${ECHO} "==========================================================================="
exit 1
;;
esac; }
${TEST} $? -eq 0 || exitcode=1
;;
CHECK-REMOVE)
${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru |
{ while read file f_flags f_eg f_mode f_user f_group; do
case $file in
"") continue ;;
[!/]*) file="${PKG_PREFIX}/$file" ;;
esac
${TEST} -f "$file" || continue
shadow_dir="${PKG_REFCOUNT_FILES_DBDIR}$file"
${TEST} ! -d "$shadow_dir" || continue # refcount isn't zero
case "$printed_header" in
yes) ;;
*) printed_header=yes
${ECHO} "==========================================================================="
2005-04-10 13:01:29 +02:00
${ECHO} "The following files are no longer being used by ${PKGNAME},"
${ECHO} "and they can be removed if no other packages are using them:"
${ECHO} ""
;;
esac
${ECHO} " $file"
done
case "$printed_header" in
yes) ${ECHO} ""
${ECHO} "==========================================================================="
exit 1
;;
esac; }
${TEST} $? -eq 0 || exitcode=1
;;
First try at fixing a deficiency in the package +INSTALL scripts, where they don't verify that any pre-existing config files and directories have the correct permissions. For example, if you are upgrading a package to a newer version and the config files and directories used by the package need to have different permissions than in previous versions of the package, then the new package may fail to work because it can't access pre-existing files and directories. This commit improves on this by doing the following: (1) Teach the +FILES and +DIRS scriptlets two new actions "PERMS" and "CHECK-PERMS". "PERMS" fixes permissions on existing files and directories. "CHECK-PERMS" will verify those same bits and warn the user when they are wrong. The "CHECK-PERMS" actions for the two scriptlets are run immediately after the "ADD" actions. (2) Add a new variable PKG_CONFIG_PERMS that controls whether the "PERMS" action will automatically fix permissions. PKG_CONFIG_PERMS is only consulted if PKG_CONFIG is "yes". PKG_CONFIG_PERMS can be set in the shell environment when running pkg_add, e.g.: export PKG_CONFIG=yes export PKG_CONFIG_PERMS=yes pkg_add /path/to/binary/package.tgz The default value of PKG_CONFIG_PERMS embedded into the +INSTALL script may also be set in /etc/mk.conf. This value defaults to "no", so that by default, the +INSTALL script will not modify or destroy any existing configuration files or directories. The +INSTALL script will now always warn you if there are files or directories whose permissions differ from what the package is expecting to use, and if PKG_CONFIG_PERMS is set to "yes", then it will go ahead and fix those permissions for you automatically.
2006-04-25 21:54:39 +02:00
CHECK-PERMS)
tmpdir="./.pkginstall.$$"
First try at fixing a deficiency in the package +INSTALL scripts, where they don't verify that any pre-existing config files and directories have the correct permissions. For example, if you are upgrading a package to a newer version and the config files and directories used by the package need to have different permissions than in previous versions of the package, then the new package may fail to work because it can't access pre-existing files and directories. This commit improves on this by doing the following: (1) Teach the +FILES and +DIRS scriptlets two new actions "PERMS" and "CHECK-PERMS". "PERMS" fixes permissions on existing files and directories. "CHECK-PERMS" will verify those same bits and warn the user when they are wrong. The "CHECK-PERMS" actions for the two scriptlets are run immediately after the "ADD" actions. (2) Add a new variable PKG_CONFIG_PERMS that controls whether the "PERMS" action will automatically fix permissions. PKG_CONFIG_PERMS is only consulted if PKG_CONFIG is "yes". PKG_CONFIG_PERMS can be set in the shell environment when running pkg_add, e.g.: export PKG_CONFIG=yes export PKG_CONFIG_PERMS=yes pkg_add /path/to/binary/package.tgz The default value of PKG_CONFIG_PERMS embedded into the +INSTALL script may also be set in /etc/mk.conf. This value defaults to "no", so that by default, the +INSTALL script will not modify or destroy any existing configuration files or directories. The +INSTALL script will now always warn you if there are files or directories whose permissions differ from what the package is expecting to use, and if PKG_CONFIG_PERMS is set to "yes", then it will go ahead and fix those permissions for you automatically.
2006-04-25 21:54:39 +02:00
${MKDIR} -p $tmpdir 2>/dev/null || exit 1
${CHMOD} 0700 $tmpdir
First try at fixing a deficiency in the package +INSTALL scripts, where they don't verify that any pre-existing config files and directories have the correct permissions. For example, if you are upgrading a package to a newer version and the config files and directories used by the package need to have different permissions than in previous versions of the package, then the new package may fail to work because it can't access pre-existing files and directories. This commit improves on this by doing the following: (1) Teach the +FILES and +DIRS scriptlets two new actions "PERMS" and "CHECK-PERMS". "PERMS" fixes permissions on existing files and directories. "CHECK-PERMS" will verify those same bits and warn the user when they are wrong. The "CHECK-PERMS" actions for the two scriptlets are run immediately after the "ADD" actions. (2) Add a new variable PKG_CONFIG_PERMS that controls whether the "PERMS" action will automatically fix permissions. PKG_CONFIG_PERMS is only consulted if PKG_CONFIG is "yes". PKG_CONFIG_PERMS can be set in the shell environment when running pkg_add, e.g.: export PKG_CONFIG=yes export PKG_CONFIG_PERMS=yes pkg_add /path/to/binary/package.tgz The default value of PKG_CONFIG_PERMS embedded into the +INSTALL script may also be set in /etc/mk.conf. This value defaults to "no", so that by default, the +INSTALL script will not modify or destroy any existing configuration files or directories. The +INSTALL script will now always warn you if there are files or directories whose permissions differ from what the package is expecting to use, and if PKG_CONFIG_PERMS is set to "yes", then it will go ahead and fix those permissions for you automatically.
2006-04-25 21:54:39 +02:00
${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru |
{ while read file f_flags f_eg f_mode f_user f_group; do
case $file in
"") continue ;;
[!/]*) file="${PKG_PREFIX}/$file" ;;
esac
${TEST} -f "$file" || continue
case $f_mode:$f_user:$f_group in
::) continue ;;
esac
perms=`${LS} -l $file | ${AWK} '{ print $1":"$3":"$4 }'`
testpath="$tmpdir/file_perms"
${ECHO} > $testpath
${CHMOD} $f_mode $testpath 2>/dev/null
longmode=`${LS} -l $testpath | ${AWK} '{ print $1 }'`
First try at fixing a deficiency in the package +INSTALL scripts, where they don't verify that any pre-existing config files and directories have the correct permissions. For example, if you are upgrading a package to a newer version and the config files and directories used by the package need to have different permissions than in previous versions of the package, then the new package may fail to work because it can't access pre-existing files and directories. This commit improves on this by doing the following: (1) Teach the +FILES and +DIRS scriptlets two new actions "PERMS" and "CHECK-PERMS". "PERMS" fixes permissions on existing files and directories. "CHECK-PERMS" will verify those same bits and warn the user when they are wrong. The "CHECK-PERMS" actions for the two scriptlets are run immediately after the "ADD" actions. (2) Add a new variable PKG_CONFIG_PERMS that controls whether the "PERMS" action will automatically fix permissions. PKG_CONFIG_PERMS is only consulted if PKG_CONFIG is "yes". PKG_CONFIG_PERMS can be set in the shell environment when running pkg_add, e.g.: export PKG_CONFIG=yes export PKG_CONFIG_PERMS=yes pkg_add /path/to/binary/package.tgz The default value of PKG_CONFIG_PERMS embedded into the +INSTALL script may also be set in /etc/mk.conf. This value defaults to "no", so that by default, the +INSTALL script will not modify or destroy any existing configuration files or directories. The +INSTALL script will now always warn you if there are files or directories whose permissions differ from what the package is expecting to use, and if PKG_CONFIG_PERMS is set to "yes", then it will go ahead and fix those permissions for you automatically.
2006-04-25 21:54:39 +02:00
case $f_mode:$f_user:$f_group in
:[!:]*:)
case "$perms" in
*:$f_user:*) continue ;;
esac
;;
:[!:]*:[!:]*)
case "$perms" in
*:$f_user:$f_group) continue ;;
esac
;;
2006-12-15 14:15:06 +01:00
[!:]*::)
First try at fixing a deficiency in the package +INSTALL scripts, where they don't verify that any pre-existing config files and directories have the correct permissions. For example, if you are upgrading a package to a newer version and the config files and directories used by the package need to have different permissions than in previous versions of the package, then the new package may fail to work because it can't access pre-existing files and directories. This commit improves on this by doing the following: (1) Teach the +FILES and +DIRS scriptlets two new actions "PERMS" and "CHECK-PERMS". "PERMS" fixes permissions on existing files and directories. "CHECK-PERMS" will verify those same bits and warn the user when they are wrong. The "CHECK-PERMS" actions for the two scriptlets are run immediately after the "ADD" actions. (2) Add a new variable PKG_CONFIG_PERMS that controls whether the "PERMS" action will automatically fix permissions. PKG_CONFIG_PERMS is only consulted if PKG_CONFIG is "yes". PKG_CONFIG_PERMS can be set in the shell environment when running pkg_add, e.g.: export PKG_CONFIG=yes export PKG_CONFIG_PERMS=yes pkg_add /path/to/binary/package.tgz The default value of PKG_CONFIG_PERMS embedded into the +INSTALL script may also be set in /etc/mk.conf. This value defaults to "no", so that by default, the +INSTALL script will not modify or destroy any existing configuration files or directories. The +INSTALL script will now always warn you if there are files or directories whose permissions differ from what the package is expecting to use, and if PKG_CONFIG_PERMS is set to "yes", then it will go ahead and fix those permissions for you automatically.
2006-04-25 21:54:39 +02:00
case "$perms" in
$longmode:*:*) continue ;;
esac
;;
[!:]*:[!:]*:)
case "$perms" in
$longmode:$f_user:*) continue ;;
esac
;;
[!:]*:[!:]*:[!:]*)
case "$perms" in
$longmode:$f_user:$f_group) continue ;;
esac
;;
esac
case "$printed_header" in
yes) ;;
*) printed_header=yes
${ECHO} "==========================================================================="
${ECHO} "The following files are used by ${PKGNAME} and have"
${ECHO} "the wrong ownership and/or permissions:"
${ECHO} ""
;;
esac
case $f_mode:$f_user:$f_group in
[!:]*::)
${ECHO} " $file (m=$f_mode)"
;;
[!:]*:[!:]*:)
${ECHO} " $file (m=$f_mode, o=$f_user)"
;;
[!:]*:[!:]*:[!:]*)
${ECHO} " $file (m=$f_mode, o=$f_user, g=$f_group)"
;;
esac
done
case "$printed_header" in
yes) ${ECHO} ""
${ECHO} "==========================================================================="
exit 1
;;
esac; }
${RM} -fr $tmpdir
First try at fixing a deficiency in the package +INSTALL scripts, where they don't verify that any pre-existing config files and directories have the correct permissions. For example, if you are upgrading a package to a newer version and the config files and directories used by the package need to have different permissions than in previous versions of the package, then the new package may fail to work because it can't access pre-existing files and directories. This commit improves on this by doing the following: (1) Teach the +FILES and +DIRS scriptlets two new actions "PERMS" and "CHECK-PERMS". "PERMS" fixes permissions on existing files and directories. "CHECK-PERMS" will verify those same bits and warn the user when they are wrong. The "CHECK-PERMS" actions for the two scriptlets are run immediately after the "ADD" actions. (2) Add a new variable PKG_CONFIG_PERMS that controls whether the "PERMS" action will automatically fix permissions. PKG_CONFIG_PERMS is only consulted if PKG_CONFIG is "yes". PKG_CONFIG_PERMS can be set in the shell environment when running pkg_add, e.g.: export PKG_CONFIG=yes export PKG_CONFIG_PERMS=yes pkg_add /path/to/binary/package.tgz The default value of PKG_CONFIG_PERMS embedded into the +INSTALL script may also be set in /etc/mk.conf. This value defaults to "no", so that by default, the +INSTALL script will not modify or destroy any existing configuration files or directories. The +INSTALL script will now always warn you if there are files or directories whose permissions differ from what the package is expecting to use, and if PKG_CONFIG_PERMS is set to "yes", then it will go ahead and fix those permissions for you automatically.
2006-04-25 21:54:39 +02:00
${TEST} $? -eq 0 || exitcode=1
;;
*)
First try at fixing a deficiency in the package +INSTALL scripts, where they don't verify that any pre-existing config files and directories have the correct permissions. For example, if you are upgrading a package to a newer version and the config files and directories used by the package need to have different permissions than in previous versions of the package, then the new package may fail to work because it can't access pre-existing files and directories. This commit improves on this by doing the following: (1) Teach the +FILES and +DIRS scriptlets two new actions "PERMS" and "CHECK-PERMS". "PERMS" fixes permissions on existing files and directories. "CHECK-PERMS" will verify those same bits and warn the user when they are wrong. The "CHECK-PERMS" actions for the two scriptlets are run immediately after the "ADD" actions. (2) Add a new variable PKG_CONFIG_PERMS that controls whether the "PERMS" action will automatically fix permissions. PKG_CONFIG_PERMS is only consulted if PKG_CONFIG is "yes". PKG_CONFIG_PERMS can be set in the shell environment when running pkg_add, e.g.: export PKG_CONFIG=yes export PKG_CONFIG_PERMS=yes pkg_add /path/to/binary/package.tgz The default value of PKG_CONFIG_PERMS embedded into the +INSTALL script may also be set in /etc/mk.conf. This value defaults to "no", so that by default, the +INSTALL script will not modify or destroy any existing configuration files or directories. The +INSTALL script will now always warn you if there are files or directories whose permissions differ from what the package is expecting to use, and if PKG_CONFIG_PERMS is set to "yes", then it will go ahead and fix those permissions for you automatically.
2006-04-25 21:54:39 +02:00
${ECHO} "Usage: ./+FILES ADD|REMOVE|PERMS [metadatadir]"
${ECHO} " ./+FILES VIEW-REMOVE depotdir viewdir"
First try at fixing a deficiency in the package +INSTALL scripts, where they don't verify that any pre-existing config files and directories have the correct permissions. For example, if you are upgrading a package to a newer version and the config files and directories used by the package need to have different permissions than in previous versions of the package, then the new package may fail to work because it can't access pre-existing files and directories. This commit improves on this by doing the following: (1) Teach the +FILES and +DIRS scriptlets two new actions "PERMS" and "CHECK-PERMS". "PERMS" fixes permissions on existing files and directories. "CHECK-PERMS" will verify those same bits and warn the user when they are wrong. The "CHECK-PERMS" actions for the two scriptlets are run immediately after the "ADD" actions. (2) Add a new variable PKG_CONFIG_PERMS that controls whether the "PERMS" action will automatically fix permissions. PKG_CONFIG_PERMS is only consulted if PKG_CONFIG is "yes". PKG_CONFIG_PERMS can be set in the shell environment when running pkg_add, e.g.: export PKG_CONFIG=yes export PKG_CONFIG_PERMS=yes pkg_add /path/to/binary/package.tgz The default value of PKG_CONFIG_PERMS embedded into the +INSTALL script may also be set in /etc/mk.conf. This value defaults to "no", so that by default, the +INSTALL script will not modify or destroy any existing configuration files or directories. The +INSTALL script will now always warn you if there are files or directories whose permissions differ from what the package is expecting to use, and if PKG_CONFIG_PERMS is set to "yes", then it will go ahead and fix those permissions for you automatically.
2006-04-25 21:54:39 +02:00
${ECHO} " ./+FILES CHECK-ADD|CHECK-REMOVE|CHECK-PERMS [metadatadir]"
;;
esac
exit $exitcode
EOF
${SED} -n "/^\# FILE: /p" ${SELF} >> ./+FILES
${CHMOD} +x ./+FILES
;;
esac