1 # $NetBSD: INSTALL.ELF,v 1.1 2007/08/21 22:49:24 jlam Exp $
3 # Generate a +ROOT_ACTIONS script that runs certain actions that require
4 # superuser privileges.
7 UNPACK,|UNPACK,+ROOT_ACTIONS)
8 ${CAT} > ./+ROOT_ACTIONS << 'EOF'
11 # +ROOT_ACTIONS - run actions requiring superuser privileges
13 # Usage: ./+ROOT_ACTIONS ADD|REMOVE [metadatadir]
15 # This script runs certain actions that require superuser privileges.
16 # If such privileges are not available, then simply output a message
17 # asking the user to run this script with the appropriate elevated
20 # Lines starting with "# SYMLINK: " are data read by this script that
21 # name the source paths and corresponding symlink that is managed by
22 # this script. If the symlink path is relative, then it is taken to be
23 # relative to ${PKG_PREFIX}. The source path is always unchanged.
25 # # SYMLINK: /dev/rcd0a ${EMULSUBDIR}/dev/cdrom
42 PKG_METADATA_DIR="${2-${CURDIR}}"
43 : ${PKGNAME=${PKG_METADATA_DIR##*/}}
44 : ${PKG_PREFIX=@PREFIX@}
46 ROOT_ACTIONS_COOKIE="./+ROOT_ACTIONS_done"
52 ${ECHO} "" > ${ROOT_ACTIONS_COOKIE}
53 ${CHMOD} g+w ${ROOT_ACTIONS_COOKIE}
54 ${SED} -n "/^\# SYMLINK: /{s/^\# SYMLINK: //;p;}" ${SELF} |
55 while read src dst; do
58 [!/]*) src="${PKG_PREFIX}/$src" ;;
62 [!/]*) dst="${PKG_PREFIX}/$dst" ;;
65 if ${TEST} ! -f "$dst"; then
66 ${ECHO} "${PKGNAME}: linking $dst -> $src"
67 ${LN} -fs "$src" "$dst"
69 ${ECHO} "${PKGNAME}: $dst already exists"
75 ${SED} -n "/^\# SYMLINK: /{s/^\# SYMLINK: //;p;}" ${SELF} |
76 while read src dst; do
82 [!/]*) dst="${PKG_PREFIX}/$dst" ;;
85 if ${TEST} -h "$dst"; then
86 ${ECHO} "${PKGNAME}: removing $dst"
90 ${RM} -f ${ROOT_ACTIONS_COOKIE}
94 if ${TEST} ! -f ${ROOT_ACTIONS_COOKIE}; then
96 ==============================================================================
97 Please run the following command with superuser privileges to complete
98 the installation of ${PKGNAME}:
100 cd ${PKG_METADATA_DIR} && ${SELF} ADD
102 ==============================================================================
108 if ${TEST} -f ${ROOT_ACTIONS_COOKIE}; then
110 ==============================================================================
111 Please run the following command with superuser privileges to begin the
112 removal of ${PKGNAME}:
114 cd ${PKG_METADATA_DIR} && ${SELF} REMOVE
116 Then, please run pkg_delete(1) again to complete the removal of this
119 ==============================================================================
128 ${SED} -n "/^\# SYMLINK: /p" ${SELF} >> ./+ROOT_ACTIONS
129 ${CHMOD} +x ./+ROOT_ACTIONS
135 ${TEST} ! -x ./+ROOT_ACTIONS ||
136 ./+ROOT_ACTIONS ADD ${PKG_METADATA_DIR}