pkgsrc/mk/pkginstall/install

103 lines
2.6 KiB
Text
Raw Normal View History

# $NetBSD: install,v 1.2 2007/07/18 18:01:03 jlam Exp $
case ${STAGE} in
PRE-INSTALL)
#
# Unpack the helper scriptlets.
#
${SH} ${SELF} ${PKGNAME} UNPACK
#
# Require that necessary users and groups exist or else fail the
# installation of the package.
#
${TEST} ! -x ./+USERGROUP ||
{ ./+USERGROUP ADD ${PKG_METADATA_DIR}
if ./+USERGROUP CHECK-ADD ${PKG_METADATA_DIR}; then
:
else
exit 1
fi; }
#
# Create package directories at pre-install time.
#
if [ "${PKG_INSTALLATION_TYPE}" = "pkgviews" -a \
"${_PKG_CONFIG}" = "yes" -a -n "${CONF_DEPENDS}" ]; then
pkg=`${PKG_ADMIN} -b -d ${DEPOTBASE} -s "" lsbest "${CONF_DEPENDS}"`
sysconfdir=`${PKG_INFO} -B -K ${DEPOTBASE} $pkg | \
${AWK} '/^PKG_SYSCONFDIR=/ { \
gsub("^PKG_SYSCONFDIR=[ ]*", ""); \
print; \
}' \
`
if [ -d $sysconfdir -a ! -d ${PKG_SYSCONFDIR} ]; then
${MKDIR} -p `${DIRNAME} ${PKG_SYSCONFDIR}`
${LN} -sf $sysconfdir ${PKG_SYSCONFDIR}
fi
fi
${TEST} ! -x ./+DIRS ||
./+DIRS ADD ${PKG_METADATA_DIR}
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} ! -x ./+DIRS ||
./+DIRS PERMS ${PKG_METADATA_DIR}
;;
POST-INSTALL)
#
# Rebuild the system run-time library search path database.
#
${TEST} ! -x ./+SHLIBS ||
./+SHLIBS ADD ${PKG_METADATA_DIR}
#
# Copy configuration/support files into place.
#
${TEST} ! -x ./+FILES ||
./+FILES ADD ${PKG_METADATA_DIR}
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} ! -x ./+FILES ||
./+FILES PERMS ${PKG_METADATA_DIR}
#
# Set special permissions on any files/directories that need them.
#
${TEST} ! -x ./+PERMS ||
./+PERMS ${PKG_METADATA_DIR}
#
# Update any fonts databases.
#
${TEST} ! -x ./+FONTS ||
./+FONTS ${PKG_METADATA_DIR}
# Check for any missing bits after we're finished installing.
#
${TEST} ! -x ./+DIRS ||
./+DIRS CHECK-ADD ${PKG_METADATA_DIR}
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} ! -x ./+DIRS ||
./+DIRS CHECK-PERMS ${PKG_METADATA_DIR}
${TEST} ! -x ./+FILES ||
./+FILES CHECK-ADD ${PKG_METADATA_DIR}
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} ! -x ./+FILES ||
./+FILES CHECK-PERMS ${PKG_METADATA_DIR}
;;
VIEW-INSTALL)
#
# Register shells in /etc/shells.
#
${TEST} ! -x ./+SHELL ||
./+SHELL ADD ${PKG_METADATA_DIR}
${TEST} ! -x ./+SHELL ||
./+SHELL CHECK-ADD ${PKG_METADATA_DIR}
#
# Register info files.
#
${TEST} ! -x ./+INFO_FILES ||
./+INFO_FILES ADD ${PKG_METADATA_DIR}
# If ${PKG_SYSCONFBASE} points outside of ${PREFIX}, then add the
# package config files to the proper view.
#
if [ "${_PKG_CONFIG}" = "yes" -a -n "${PKG_SYSCONFDEPOTBASE}" ]; then
${SETENV} PLIST_IGNORE_FILES="${CONF_IGNORE_FILES}" \
${LINKFARM} -t ${PKG_SYSCONFVIEWBASE} -d ${PKG_SYSCONFDEPOTBASE} ${PKGNAME}
fi
;;
esac