141 lines
3.2 KiB
Text
141 lines
3.2 KiB
Text
|
# $NetBSD: INSTALL.a.out,v 1.1 2007/08/21 22:49:25 jlam Exp $
|
||
|
|
||
|
# Generate a +ROOT_ACTIONS script that runs certain actions that require
|
||
|
# superuser privileges.
|
||
|
#
|
||
|
case "${STAGE},$1" in
|
||
|
UNPACK,|UNPACK,+ROOT_ACTIONS)
|
||
|
${CAT} > ./+ROOT_ACTIONS << 'EOF'
|
||
|
#!@SH@
|
||
|
#
|
||
|
# +ROOT_ACTIONS - run actions requiring superuser privileges
|
||
|
#
|
||
|
# Usage: ./+ROOT_ACTIONS ADD|REMOVE [metadatadir]
|
||
|
#
|
||
|
# This script runs certain actions that require superuser privileges.
|
||
|
# If such privileges are not available, then simply output a message
|
||
|
# asking the user to run this script with the appropriate elevated
|
||
|
# privileges.
|
||
|
#
|
||
|
|
||
|
CAT="@CAT@"
|
||
|
CHMOD="@CHMOD@"
|
||
|
CP="@CP@"
|
||
|
ECHO="@ECHO@"
|
||
|
GREP="@GREP@"
|
||
|
ID="@ID@"
|
||
|
PWD_CMD="@PWD_CMD@"
|
||
|
RM="@RM@"
|
||
|
TEST="@TEST@"
|
||
|
TOUCH="@TOUCH@"
|
||
|
|
||
|
SELF=$0
|
||
|
ACTION=$1
|
||
|
|
||
|
CURDIR=`${PWD_CMD}`
|
||
|
PKG_METADATA_DIR="${2-${CURDIR}}"
|
||
|
: ${PKGNAME=${PKG_METADATA_DIR##*/}}
|
||
|
: ${PKG_PREFIX=@PREFIX@}
|
||
|
|
||
|
EMULDIR="${PKG_PREFIX}/@EMULSUBDIR@"
|
||
|
OPSYS_EMULDIR="@OPSYS_EMULDIR@"
|
||
|
|
||
|
ROOT_ACTIONS_COOKIE="./+ROOT_ACTIONS_done"
|
||
|
EUID=`${ID} -u`
|
||
|
|
||
|
exitcode=0
|
||
|
case $ACTION,$EUID in
|
||
|
ADD,0)
|
||
|
${ECHO} "" > ${ROOT_ACTIONS_COOKIE}
|
||
|
${CHMOD} g+w ${ROOT_ACTIONS_COOKIE}
|
||
|
${SED} -n "/^\# LDCONFIG: /{s/^\# LDCONFIG: //;p;}" ${SELF} |
|
||
|
while read dir; do
|
||
|
case $dir in
|
||
|
/*) continue ;;
|
||
|
*) dir="${PKG_PREFIX}/$dir" ;;
|
||
|
esac
|
||
|
${TEST} -d "$dir" || continue
|
||
|
|
||
|
ldsoconf="/etc/ld.so.conf"
|
||
|
${TEST} -f "$ldsoconf" || continue
|
||
|
if ${GREP} "^$dir" $ldsoconf >/dev/null; then
|
||
|
:
|
||
|
else
|
||
|
${ECHO} "${PKGNAME}: adding $dir to $ldsoconf"
|
||
|
${TOUCH} $ldsoconf
|
||
|
${CP} $ldsoconf $ldsoconf.pkgsrc."$$"
|
||
|
{ ${CAT} $ldsoconf.pkgsrc."$$"; ${ECHO} "$dir"; } > $ldsoconf
|
||
|
${RM} $ldsoconf.pkgsrc."$$"
|
||
|
fi
|
||
|
done
|
||
|
${ECHO} "${PKGNAME}: creating a.out runtime link editor directory cache."
|
||
|
@LDCONFIG_ADD_CMD@
|
||
|
;;
|
||
|
|
||
|
ADD,*)
|
||
|
if ${TEST} ! -f ${ROOT_ACTIONS_COOKIE}; then
|
||
|
${CAT} << EOM
|
||
|
==============================================================================
|
||
|
Please run the following command with superuser privileges to complete
|
||
|
the installation of ${PKGNAME}:
|
||
|
|
||
|
cd ${PKG_METADATA_DIR} && ${SELF} ADD
|
||
|
|
||
|
==============================================================================
|
||
|
EOM
|
||
|
fi
|
||
|
;;
|
||
|
|
||
|
REMOVE,0)
|
||
|
${SED} -n "/^\# LDCONFIG: /{s/^\# LDCONFIG: //;p;}" ${SELF} |
|
||
|
{ while read dir; do
|
||
|
case $dir in
|
||
|
/*) continue ;;
|
||
|
*) dir="${PKG_PREFIX}/$dir" ;;
|
||
|
esac
|
||
|
${TEST} -d "$dir" || continue
|
||
|
|
||
|
ldsoconf="/etc/ld.so.conf"
|
||
|
${TEST} -f "$ldsoconf" || continue
|
||
|
if ${GREP} "^$dir" $ldsoconf >/dev/null; then
|
||
|
case "$printed_header" in
|
||
|
yes) ;;
|
||
|
*) printed_header=yes
|
||
|
${ECHO} "==========================================================================="
|
||
|
${ECHO} "The following lines can be removed from $ldsoconf:"
|
||
|
${ECHO} ""
|
||
|
;;
|
||
|
esac
|
||
|
${ECHO} " $dir"
|
||
|
fi
|
||
|
done
|
||
|
case "$printed_header" in
|
||
|
yes) ${ECHO} ""
|
||
|
${ECHO} "==========================================================================="
|
||
|
exit 1
|
||
|
;;
|
||
|
esac; }
|
||
|
${RM} -f ${ROOT_ACTIONS_COOKIE}
|
||
|
;;
|
||
|
esac
|
||
|
exit $exitcode
|
||
|
|
||
|
EOF
|
||
|
${CHMOD} +x ./+ROOT_ACTIONS
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
# LDCONFIG: @EMULSUBDIRSLASH@usr/X11R6/lib
|
||
|
# LDCONFIG: @EMULSUBDIRSLASH@usr/lib
|
||
|
|
||
|
EMULDIR="${PKG_PREFIX}/@EMULSUBDIR@"
|
||
|
OPSYS_EMULDIR="@OPSYS_EMULDIR@"
|
||
|
|
||
|
case "${STAGE}" in
|
||
|
POST-INSTALL)
|
||
|
# Run any actions that require root privileges.
|
||
|
${TEST} ! -x ./+ROOT_ACTIONS ||
|
||
|
./+ROOT_ACTIONS ADD ${PKG_METADATA_DIR}
|
||
|
;;
|
||
|
esac
|