| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: INSTALL.ELF,v 1.2 2013/02/17 10:34:31 spz Exp $ | | 1 | # $NetBSD: INSTALL.ELF,v 1.3 2022/01/02 16:15:55 he Exp $ |
2 | | | 2 | |
3 | # Generate a +ROOT_ACTIONS script that runs certain actions that require | | 3 | # Generate a +ROOT_ACTIONS script that runs certain actions that require |
4 | # superuser privileges. | | 4 | # superuser privileges. |
5 | # | | 5 | # |
6 | case "${STAGE},$1" in | | 6 | case "${STAGE},$1" in |
7 | UNPACK,|UNPACK,+ROOT_ACTIONS) | | 7 | UNPACK,|UNPACK,+ROOT_ACTIONS) |
8 | ${CAT} > ./+ROOT_ACTIONS << 'EOF' | | 8 | ${CAT} > ./+ROOT_ACTIONS << 'EOF' |
9 | #!@SH@ | | 9 | #!@SH@ |
10 | # | | 10 | # |
11 | # +ROOT_ACTIONS - run actions requiring superuser privileges | | 11 | # +ROOT_ACTIONS - run actions requiring superuser privileges |
12 | # | | 12 | # |
13 | # Usage: ./+ROOT_ACTIONS ADD|REMOVE [metadatadir] | | 13 | # Usage: ./+ROOT_ACTIONS ADD|REMOVE [metadatadir] |
14 | # | | 14 | # |
| @@ -73,28 +73,35 @@ ADD,0) | | | @@ -73,28 +73,35 @@ ADD,0) |
73 | | | 73 | |
74 | REMOVE,0) | | 74 | REMOVE,0) |
75 | ${SED} -n "/^\# SYMLINK: /{s/^\# SYMLINK: //;p;}" ${SELF} | | | 75 | ${SED} -n "/^\# SYMLINK: /{s/^\# SYMLINK: //;p;}" ${SELF} | |
76 | while read src dst; do | | 76 | while read src dst; do |
77 | case $src in | | 77 | case $src in |
78 | "") continue ;; | | 78 | "") continue ;; |
79 | esac | | 79 | esac |
80 | case $dst in | | 80 | case $dst in |
81 | "") continue ;; | | 81 | "") continue ;; |
82 | [!/]*) dst="${PKG_PREFIX}/$dst" ;; | | 82 | [!/]*) dst="${PKG_PREFIX}/$dst" ;; |
83 | esac | | 83 | esac |
84 | | | 84 | |
85 | if ${TEST} -h "$dst"; then | | 85 | if ${TEST} -h "$dst"; then |
86 | ${ECHO} "${PKGNAME}: removing $dst" | | 86 | lsrc=$(readlink $dst) |
87 | ${RM} -f "$dst" | | 87 | if [ "$lsrc" = ${PKG_PREFIX}/$src -o \ |
| | | 88 | "$lsrc" = $src ] |
| | | 89 | then |
| | | 90 | ${ECHO} "${PKGNAME}: removing $dst" |
| | | 91 | ${RM} -f "$dst" |
| | | 92 | else |
| | | 93 | ${ECHO} "${PKGNAME}: mismatched symlink, skipping removal of $dst" |
| | | 94 | fi |
88 | fi | | 95 | fi |
89 | done | | 96 | done |
90 | ${RM} -f ${ROOT_ACTIONS_COOKIE} | | 97 | ${RM} -f ${ROOT_ACTIONS_COOKIE} |
91 | ;; | | 98 | ;; |
92 | | | 99 | |
93 | ADD,*) | | 100 | ADD,*) |
94 | if ${TEST} ! -f ${ROOT_ACTIONS_COOKIE}; then | | 101 | if ${TEST} ! -f ${ROOT_ACTIONS_COOKIE}; then |
95 | ${CAT} << EOM | | 102 | ${CAT} << EOM |
96 | ============================================================================== | | 103 | ============================================================================== |
97 | Please run the following command with superuser privileges to complete | | 104 | Please run the following command with superuser privileges to complete |
98 | the installation of ${PKGNAME}: | | 105 | the installation of ${PKGNAME}: |
99 | | | 106 | |
100 | cd ${PKG_METADATA_DIR} && ${SELF} ADD | | 107 | cd ${PKG_METADATA_DIR} && ${SELF} ADD |