| @@ -1,447 +1,445 @@ | | | @@ -1,447 +1,445 @@ |
1 | # $NetBSD: files,v 1.7 2012/04/17 11:55:33 wiz Exp $ | | 1 | # $NetBSD: files,v 1.8 2012/04/21 10:22:32 wiz Exp $ |
2 | # | | 2 | # |
3 | # Generate a +FILES script that reference counts config files that are | | 3 | # Generate a +FILES script that reference counts config files that are |
4 | # required for the proper functioning of the package. | | 4 | # required for the proper functioning of the package. |
5 | # | | 5 | # |
6 | case "${STAGE},$1" in | | 6 | case "${STAGE},$1" in |
7 | UNPACK,|UNPACK,+FILES) | | 7 | UNPACK,|UNPACK,+FILES) |
8 | ${CAT} > ./+FILES << 'EOF' | | 8 | ${CAT} > ./+FILES << 'EOF' |
9 | #!@SH@ | | 9 | #!@SH@ |
10 | # | | 10 | # |
11 | # +FILES - reference-counted configuration file management script | | 11 | # +FILES - reference-counted configuration file management script |
12 | # | | 12 | # |
13 | # Usage: ./+FILES ADD|REMOVE|PERMS [metadatadir] | | 13 | # Usage: ./+FILES ADD|REMOVE|PERMS [metadatadir] |
14 | # ./+FILES VIEW-REMOVE depotdir viewdir | | 14 | # ./+FILES VIEW-REMOVE depotdir viewdir |
15 | # ./+FILES CHECK-ADD|CHECK-REMOVE|CHECK-PERMS [metadatadir] | | 15 | # ./+FILES CHECK-ADD|CHECK-REMOVE|CHECK-PERMS [metadatadir] |
16 | # | | 16 | # |
17 | # This script supports two actions, ADD and REMOVE, that will add or | | 17 | # This script supports two actions, ADD and REMOVE, that will add or |
18 | # remove the configuration files needed by the package associated with | | 18 | # remove the configuration files needed by the package associated with |
19 | # <metadatadir>. The CHECK-ADD action will check whether any files | | 19 | # <metadatadir>. The CHECK-ADD action will check whether any files |
20 | # needed by the package are missing, and print an informative message | | 20 | # needed by the package are missing, and print an informative message |
21 | # noting those files. The CHECK-REMOVE action will check whether | | 21 | # noting those files. The CHECK-REMOVE action will check whether |
22 | # any files needed by the package still exist, and print an informative | | 22 | # any files needed by the package still exist, and print an informative |
23 | # message noting those files. The CHECK-ADD and CHECK-REMOVE actions | | 23 | # message noting those files. The CHECK-ADD and CHECK-REMOVE actions |
24 | # return non-zero if they detect either missing or existing files, | | 24 | # return non-zero if they detect either missing or existing files, |
25 | # respectively. The VIEW-REMOVE action will remove from <viewdir> the | | 25 | # respectively. The VIEW-REMOVE action will remove from <viewdir> the |
26 | # links to the configuration files in <depotdir>. The PERMS action | | 26 | # links to the configuration files in <depotdir>. The PERMS action |
27 | # will correct any ownership or permission discrepancies between the | | 27 | # will correct any ownership or permission discrepancies between the |
28 | # existing files and the data in this script, and the CHECK-PERMS | | 28 | # existing files and the data in this script, and the CHECK-PERMS |
29 | # action will check whether any files have the wrong ownership or | | 29 | # action will check whether any files have the wrong ownership or |
30 | # permission and print an informative message noting those files. The | | 30 | # permission and print an informative message noting those files. The |
31 | # CHECK-PERMS action will return non-zero if it detects files with | | 31 | # CHECK-PERMS action will return non-zero if it detects files with |
32 | # wrong ownership or permissions. | | 32 | # wrong ownership or permissions. |
33 | # | | 33 | # |
34 | # Lines starting with "# FILE: " are data read by this script that | | 34 | # Lines starting with "# FILE: " are data read by this script that |
35 | # name the files that this package requires to exist to function | | 35 | # name the files that this package requires to exist to function |
36 | # correctly, along with the locations of the example files, e.g. | | 36 | # correctly, along with the locations of the example files, e.g. |
37 | # | | 37 | # |
38 | # # FILE: /etc/bar.conf c /example/bar.conf | | 38 | # # FILE: /etc/bar.conf c /example/bar.conf |
39 | # # FILE: /etc/baz/conf c /example/baz.conf 0600 foo-user foo-group | | 39 | # # FILE: /etc/baz/conf c /example/baz.conf 0600 foo-user foo-group |
40 | # | | 40 | # |
41 | # For each FILE entry, if the file path is relative, then it is taken to | | 41 | # For each FILE entry, if the file path is relative, then it is taken to |
42 | # be relative to ${PKG_PREFIX}. | | 42 | # be relative to ${PKG_PREFIX}. |
43 | # | | 43 | # |
44 | # The second field in each FILE entry is a set of flags with the following | | 44 | # The second field in each FILE entry is a set of flags with the following |
45 | # meaning: | | 45 | # meaning: |
46 | # | | 46 | # |
47 | # c file is copied into place | | 47 | # c file is copied into place |
48 | # f ignore ${PKG_CONFIG} | | 48 | # f ignore ${PKG_CONFIG} |
49 | # r file is an rc.d script (consider ${PKG_RCD_SCRIPTS}) | | 49 | # r file is an rc.d script (consider ${PKG_RCD_SCRIPTS}) |
50 | # | | 50 | # |
51 | AWK="@AWK@" | | 51 | AWK="@AWK@" |
52 | CAT="@CAT@" | | 52 | CAT="@CAT@" |
53 | CP="@CP@" | | 53 | CP="@CP@" |
54 | CHGRP="@CHGRP@" | | 54 | CHGRP="@CHGRP@" |
55 | CHMOD="@CHMOD@" | | 55 | CHMOD="@CHMOD@" |
56 | CHOWN="@CHOWN@" | | 56 | CHOWN="@CHOWN@" |
57 | CMP="@CMP@" | | 57 | CMP="@CMP@" |
58 | ECHO="@ECHO@" | | 58 | ECHO="@ECHO@" |
59 | GREP="@GREP@" | | 59 | GREP="@GREP@" |
60 | LS="@LS@" | | 60 | LS="@LS@" |
61 | MKDIR="@MKDIR@" | | 61 | MKDIR="@MKDIR@" |
62 | MV="@MV@" | | 62 | MV="@MV@" |
63 | PWD_CMD="@PWD_CMD@" | | 63 | PWD_CMD="@PWD_CMD@" |
64 | RM="@RM@" | | 64 | RM="@RM@" |
65 | RMDIR="@RMDIR@" | | 65 | RMDIR="@RMDIR@" |
66 | SED="@SED@" | | 66 | SED="@SED@" |
67 | SORT="@SORT@" | | 67 | SORT="@SORT@" |
68 | TEST="@TEST@" | | 68 | TEST="@TEST@" |
69 | TRUE="@TRUE@" | | 69 | TRUE="@TRUE@" |
70 | | | 70 | |
71 | SELF=$0 | | 71 | SELF=$0 |
72 | ACTION=$1 | | 72 | ACTION=$1 |
73 | | | 73 | |
74 | : ${PKG_PREFIX=@PREFIX@} | | 74 | : ${PKG_PREFIX=@PREFIX@} |
75 | | | 75 | |
76 | case "${PKG_CONFIG:-@PKG_CONFIG@}" in | | 76 | case "${PKG_CONFIG:-@PKG_CONFIG@}" in |
77 | [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) | | 77 | [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) |
78 | _PKG_CONFIG=yes | | 78 | _PKG_CONFIG=yes |
79 | ;; | | 79 | ;; |
80 | [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) | | 80 | [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) |
81 | _PKG_CONFIG=no | | 81 | _PKG_CONFIG=no |
82 | ;; | | 82 | ;; |
83 | esac | | 83 | esac |
84 | case "${PKG_CONFIG_PERMS:-@PKG_CONFIG_PERMS@}" in | | 84 | case "${PKG_CONFIG_PERMS:-@PKG_CONFIG_PERMS@}" in |
85 | [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) | | 85 | [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) |
86 | _PKG_CONFIG_PERMS=yes | | 86 | _PKG_CONFIG_PERMS=yes |
87 | ;; | | 87 | ;; |
88 | [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) | | 88 | [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) |
89 | _PKG_CONFIG_PERMS=no | | 89 | _PKG_CONFIG_PERMS=no |
90 | ;; | | 90 | ;; |
91 | esac | | 91 | esac |
92 | case "${PKG_RCD_SCRIPTS:-@PKG_RCD_SCRIPTS@}" in | | 92 | case "${PKG_RCD_SCRIPTS:-@PKG_RCD_SCRIPTS@}" in |
93 | [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) | | 93 | [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) |
94 | _PKG_RCD_SCRIPTS=yes | | 94 | _PKG_RCD_SCRIPTS=yes |
95 | ;; | | 95 | ;; |
96 | [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) | | 96 | [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) |
97 | _PKG_RCD_SCRIPTS=no | | 97 | _PKG_RCD_SCRIPTS=no |
98 | ;; | | 98 | ;; |
99 | esac | | 99 | esac |
100 | | | 100 | |
101 | case $ACTION in | | 101 | case $ACTION in |
102 | VIEW-REMOVE) | | 102 | VIEW-REMOVE) |
103 | DEPOTDIR="$2" | | 103 | DEPOTDIR="$2" |
104 | VIEWDIR="$3" | | 104 | VIEWDIR="$3" |
105 | ${TEST} -n "${DEPOTDIR}" -a -n "${VIEWDIR}" || exit 0 | | 105 | ${TEST} -n "${DEPOTDIR}" -a -n "${VIEWDIR}" || exit 0 |
106 | ;; | | 106 | ;; |
107 | *) | | 107 | *) |
108 | CURDIR=`${PWD_CMD}` | | 108 | CURDIR=`${PWD_CMD}` |
109 | PKG_METADATA_DIR="${2-${CURDIR}}" | | 109 | PKG_METADATA_DIR="${2-${CURDIR}}" |
110 | : ${PKGNAME=${PKG_METADATA_DIR##*/}} | | 110 | : ${PKGNAME=${PKG_METADATA_DIR##*/}} |
111 | : ${PKG_DBDIR=${PKG_METADATA_DIR%/*}} | | 111 | : ${PKG_DBDIR=${PKG_METADATA_DIR%/*}} |
112 | : ${PKG_REFCOUNT_DBDIR=${PKG_DBDIR}.refcount} | | 112 | : ${PKG_REFCOUNT_DBDIR=${PKG_DBDIR}.refcount} |
113 | PKG_REFCOUNT_FILES_DBDIR="${PKG_REFCOUNT_DBDIR}/files" | | 113 | PKG_REFCOUNT_FILES_DBDIR="${PKG_REFCOUNT_DBDIR}/files" |
114 | ;; | | 114 | ;; |
115 | esac | | 115 | esac |
116 | | | 116 | |
117 | exitcode=0 | | 117 | exitcode=0 |
118 | case $ACTION in | | 118 | case $ACTION in |
119 | ADD) | | 119 | ADD) |
120 | ${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -u | | | 120 | ${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -u | |
121 | while read file f_flags f_eg f_mode f_user f_group; do | | 121 | while read file f_flags f_eg f_mode f_user f_group; do |
122 | case $file in | | 122 | case $file in |
123 | "") continue ;; | | 123 | "") continue ;; |
124 | [!/]*) file="${PKG_PREFIX}/$file" ;; | | 124 | [!/]*) file="${PKG_PREFIX}/$file" ;; |
125 | esac | | 125 | esac |
126 | case $f_flags in | | 126 | case $f_flags in |
127 | *c*) ;; | | 127 | *c*) ;; |
128 | *) continue ;; | | 128 | *) continue ;; |
129 | esac | | 129 | esac |
130 | case $f_eg in | | 130 | case $f_eg in |
131 | "") continue ;; | | 131 | "") continue ;; |
132 | [!/]*) f_eg="${PKG_PREFIX}/$f_eg" ;; | | 132 | [!/]*) f_eg="${PKG_PREFIX}/$f_eg" ;; |
133 | esac | | 133 | esac |
134 | | | 134 | |
135 | shadow_dir="${PKG_REFCOUNT_FILES_DBDIR}$file" | | 135 | shadow_dir="${PKG_REFCOUNT_FILES_DBDIR}$file" |
136 | perms="$shadow_dir/+PERMISSIONS" | | 136 | perms="$shadow_dir/+PERMISSIONS" |
137 | preexist="$shadow_dir/+PREEXISTING" | | 137 | preexist="$shadow_dir/+PREEXISTING" |
138 | token="$shadow_dir/${PKGNAME}" | | 138 | token="$shadow_dir/${PKGNAME}" |
139 | if ${TEST} ! -d "$shadow_dir"; then | | 139 | if ${TEST} ! -d "$shadow_dir"; then |
140 | ${MKDIR} $shadow_dir | | 140 | ${MKDIR} $shadow_dir |
141 | ${TEST} ! -f "$file" || | | 141 | ${TEST} ! -f "$file" || |
142 | ${ECHO} "${PKGNAME}" > $preexist | | 142 | ${ECHO} "${PKGNAME}" > $preexist |
143 | fi | | 143 | fi |
144 | if ${TEST} -f "$token" && \ | | 144 | if ${TEST} -f "$token" && \ |
145 | ${GREP} "^${PKG_METADATA_DIR}$" $token >/dev/null; then | | 145 | ${GREP} "^${PKG_METADATA_DIR}$" $token >/dev/null; then |
146 | : | | 146 | : |
147 | else | | 147 | else |
148 | ${ECHO} "${PKG_METADATA_DIR}" >> $token | | 148 | ${ECHO} "${PKG_METADATA_DIR}" >> $token |
149 | fi | | 149 | fi |
150 | | | 150 | |
151 | case $f_mode$f_user$f_group in | | 151 | case $f_mode$f_user$f_group in |
152 | "") ;; | | 152 | "") ;; |
153 | *) ${ECHO} "$f_mode $f_user $f_group" > $perms ;; | | 153 | *) ${ECHO} "$f_mode $f_user $f_group" > $perms ;; |
154 | esac | | 154 | esac |
155 | if ${TEST} ! -f "$file" -a ! -f "$f_eg" -a ! -c "$f_eg"; then | | 155 | if ${TEST} ! -f "$file" -a ! -f "$f_eg" -a ! -c "$f_eg"; then |
156 | : | | 156 | : |
157 | else | | 157 | else |
158 | case "$f_flags:$_PKG_CONFIG:$_PKG_RCD_SCRIPTS" in | | 158 | case "$f_flags:$_PKG_CONFIG:$_PKG_RCD_SCRIPTS" in |
159 | *f*:*:*|[!r]:yes:*|[!r][!r]:yes:*|[!r][!r][!r]:yes:*|*r*:yes:yes) | | 159 | *f*:*:*|[!r]:yes:*|[!r][!r]:yes:*|[!r][!r][!r]:yes:*|*r*:yes:yes) |
160 | if ${TEST} -f "$file"; then | | 160 | if ${TEST} -f "$file"; then |
161 | ${ECHO} "${PKGNAME}: $file already exists" | | 161 | ${ECHO} "${PKGNAME}: $file already exists" |
162 | elif ${TEST} -h "$file"; then | | | |
163 | ${ECHO} "${PKGNAME}: $file is a symlink" | | | |
164 | elif ${TEST} -f "$f_eg" -o -c "$f_eg"; then | | 162 | elif ${TEST} -f "$f_eg" -o -c "$f_eg"; then |
165 | ${ECHO} "${PKGNAME}: copying $f_eg to $file" | | 163 | ${ECHO} "${PKGNAME}: copying $f_eg to $file" |
166 | ${CP} $f_eg $file | | 164 | ${CP} $f_eg $file |
167 | case $f_user in | | 165 | case $f_user in |
168 | "") ;; | | 166 | "") ;; |
169 | *) ${CHOWN} $f_user $file ;; | | 167 | *) ${CHOWN} $f_user $file ;; |
170 | esac | | 168 | esac |
171 | case $f_group in | | 169 | case $f_group in |
172 | "") ;; | | 170 | "") ;; |
173 | *) ${CHGRP} $f_group $file ;; | | 171 | *) ${CHGRP} $f_group $file ;; |
174 | esac | | 172 | esac |
175 | case $f_mode in | | 173 | case $f_mode in |
176 | "") ;; | | 174 | "") ;; |
177 | *) ${CHMOD} $f_mode $file ;; | | 175 | *) ${CHMOD} $f_mode $file ;; |
178 | esac | | 176 | esac |
179 | fi | | 177 | fi |
180 | ;; | | 178 | ;; |
181 | esac | | 179 | esac |
182 | fi | | 180 | fi |
183 | done | | 181 | done |
184 | ;; | | 182 | ;; |
185 | | | 183 | |
186 | REMOVE) | | 184 | REMOVE) |
187 | ${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru | | | 185 | ${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru | |
188 | while read file f_flags f_eg f_mode f_user f_group; do | | 186 | while read file f_flags f_eg f_mode f_user f_group; do |
189 | case $file in | | 187 | case $file in |
190 | "") continue ;; | | 188 | "") continue ;; |
191 | [!/]*) file="${PKG_PREFIX}/$file" ;; | | 189 | [!/]*) file="${PKG_PREFIX}/$file" ;; |
192 | esac | | 190 | esac |
193 | case $f_flags in | | 191 | case $f_flags in |
194 | *c*) ;; | | 192 | *c*) ;; |
195 | *) continue ;; | | 193 | *) continue ;; |
196 | esac | | 194 | esac |
197 | case $f_eg in | | 195 | case $f_eg in |
198 | "") continue ;; | | 196 | "") continue ;; |
199 | [!/]*) f_eg="${PKG_PREFIX}/$f_eg" ;; | | 197 | [!/]*) f_eg="${PKG_PREFIX}/$f_eg" ;; |
200 | esac | | 198 | esac |
201 | | | 199 | |
202 | shadow_dir="${PKG_REFCOUNT_FILES_DBDIR}$file" | | 200 | shadow_dir="${PKG_REFCOUNT_FILES_DBDIR}$file" |
203 | perms="$shadow_dir/+PERMISSIONS" | | 201 | perms="$shadow_dir/+PERMISSIONS" |
204 | preexist="$shadow_dir/+PREEXISTING" | | 202 | preexist="$shadow_dir/+PREEXISTING" |
205 | token="$shadow_dir/${PKGNAME}" | | 203 | token="$shadow_dir/${PKGNAME}" |
206 | tokentmp="$token.tmp.$$" | | 204 | tokentmp="$token.tmp.$$" |
207 | if ${TEST} -f "$token" && \ | | 205 | if ${TEST} -f "$token" && \ |
208 | ${GREP} "^${PKG_METADATA_DIR}$" $token >/dev/null; then | | 206 | ${GREP} "^${PKG_METADATA_DIR}$" $token >/dev/null; then |
209 | ${CAT} "$token" | ${GREP} -v "^${PKG_METADATA_DIR}$" > $tokentmp | | 207 | ${CAT} "$token" | ${GREP} -v "^${PKG_METADATA_DIR}$" > $tokentmp |
210 | case `${CAT} $tokentmp | ${SED} -n "$="` in | | 208 | case `${CAT} $tokentmp | ${SED} -n "$="` in |
211 | "") | | 209 | "") |
212 | if ${TEST} -f "$preexist"; then | | 210 | if ${TEST} -f "$preexist"; then |
213 | : | | 211 | : |
214 | elif ${TEST} -f "$file" -a \( -f "$f_eg" -o -c "$f_eg" \) && \ | | 212 | elif ${TEST} -f "$file" -a \( -f "$f_eg" -o -c "$f_eg" \) && \ |
215 | ${CMP} -s "$file" "$f_eg"; then | | 213 | ${CMP} -s "$file" "$f_eg"; then |
216 | case "$f_flags:$_PKG_CONFIG:$_PKG_RCD_SCRIPTS" in | | 214 | case "$f_flags:$_PKG_CONFIG:$_PKG_RCD_SCRIPTS" in |
217 | *f*:*:*|[!r]:yes:*|[!r][!r]:yes:*|[!r][!r][!r]:yes:*|*r*:yes:yes) | | 215 | *f*:*:*|[!r]:yes:*|[!r][!r]:yes:*|[!r][!r][!r]:yes:*|*r*:yes:yes) |
218 | ${RM} -f "$file" | | 216 | ${RM} -f "$file" |
219 | ;; | | 217 | ;; |
220 | esac | | 218 | esac |
221 | fi | | 219 | fi |
222 | ${RM} -f $perms $preexist $token $token.tmp.* | | 220 | ${RM} -f $perms $preexist $token $token.tmp.* |
223 | ${RMDIR} -p $shadow_dir 2>/dev/null || ${TRUE} | | 221 | ${RMDIR} -p $shadow_dir 2>/dev/null || ${TRUE} |
224 | ;; | | 222 | ;; |
225 | *) | | 223 | *) |
226 | ${MV} -f $tokentmp $token | | 224 | ${MV} -f $tokentmp $token |
227 | ;; | | 225 | ;; |
228 | esac | | 226 | esac |
229 | fi | | 227 | fi |
230 | done | | 228 | done |
231 | ;; | | 229 | ;; |
232 | | | 230 | |
233 | PERMS) | | 231 | PERMS) |
234 | ${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru | | | 232 | ${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru | |
235 | while read file f_flags f_eg f_mode f_user f_group; do | | 233 | while read file f_flags f_eg f_mode f_user f_group; do |
236 | case $_PKG_CONFIG:$_PKG_CONFIG_PERMS in | | 234 | case $_PKG_CONFIG:$_PKG_CONFIG_PERMS in |
237 | yes:yes) ;; | | 235 | yes:yes) ;; |
238 | *) continue ;; | | 236 | *) continue ;; |
239 | esac | | 237 | esac |
240 | case $file in | | 238 | case $file in |
241 | "") continue ;; | | 239 | "") continue ;; |
242 | [!/]*) file="${PKG_PREFIX}/$file" ;; | | 240 | [!/]*) file="${PKG_PREFIX}/$file" ;; |
243 | esac | | 241 | esac |
244 | case $f_user in | | 242 | case $f_user in |
245 | "") ;; | | 243 | "") ;; |
246 | *) ${CHOWN} $f_user $file ;; | | 244 | *) ${CHOWN} $f_user $file ;; |
247 | esac | | 245 | esac |
248 | case $f_group in | | 246 | case $f_group in |
249 | "") ;; | | 247 | "") ;; |
250 | *) ${CHGRP} $f_group $file ;; | | 248 | *) ${CHGRP} $f_group $file ;; |
251 | esac | | 249 | esac |
252 | case $f_mode in | | 250 | case $f_mode in |
253 | "") ;; | | 251 | "") ;; |
254 | *) ${CHMOD} $f_mode $file ;; | | 252 | *) ${CHMOD} $f_mode $file ;; |
255 | esac | | 253 | esac |
256 | done | | 254 | done |
257 | ;; | | 255 | ;; |
258 | | | 256 | |
259 | VIEW-REMOVE) | | 257 | VIEW-REMOVE) |
260 | ${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru | | | 258 | ${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru | |
261 | while read file f_flags f_eg f_mode f_user f_group; do | | 259 | while read file f_flags f_eg f_mode f_user f_group; do |
262 | case $file in | | 260 | case $file in |
263 | ${DEPOTDIR}/*) link="${VIEWDIR}/${file#${DEPOTDIR}/}" ;; | | 261 | ${DEPOTDIR}/*) link="${VIEWDIR}/${file#${DEPOTDIR}/}" ;; |
264 | [!/]*) link="${VIEWDIR}/$file" ;; | | 262 | [!/]*) link="${VIEWDIR}/$file" ;; |
265 | *) continue ;; | | 263 | *) continue ;; |
266 | esac | | 264 | esac |
267 | dir="${link%[^/]*}" | | 265 | dir="${link%[^/]*}" |
268 | if ${TEST} -h "$link"; then | | 266 | if ${TEST} -h "$link"; then |
269 | ${RM} -f $link | | 267 | ${RM} -f $link |
270 | ${RMDIR} -p $dir 2>/dev/null || ${TRUE} | | 268 | ${RMDIR} -p $dir 2>/dev/null || ${TRUE} |
271 | fi | | 269 | fi |
272 | done | | 270 | done |
273 | ;; | | 271 | ;; |
274 | | | 272 | |
275 | CHECK-ADD) | | 273 | CHECK-ADD) |
276 | ${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru | | | 274 | ${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru | |
277 | { while read file f_flags f_eg f_mode f_user f_group; do | | 275 | { while read file f_flags f_eg f_mode f_user f_group; do |
278 | case $file in | | 276 | case $file in |
279 | "") continue ;; | | 277 | "") continue ;; |
280 | [!/]*) file="${PKG_PREFIX}/$file" ;; | | 278 | [!/]*) file="${PKG_PREFIX}/$file" ;; |
281 | esac | | 279 | esac |
282 | ${TEST} ! -f "$file" || continue | | 280 | ${TEST} ! -f "$file" || continue |
283 | case $f_flags in | | 281 | case $f_flags in |
284 | *c*) ;; | | 282 | *c*) ;; |
285 | *) continue ;; | | 283 | *) continue ;; |
286 | esac | | 284 | esac |
287 | case $f_eg in | | 285 | case $f_eg in |
288 | "") continue ;; | | 286 | "") continue ;; |
289 | [!/]*) f_eg="${PKG_PREFIX}/$f_eg" ;; | | 287 | [!/]*) f_eg="${PKG_PREFIX}/$f_eg" ;; |
290 | esac | | 288 | esac |
291 | | | 289 | |
292 | case "$printed_header" in | | 290 | case "$printed_header" in |
293 | yes) ;; | | 291 | yes) ;; |
294 | *) printed_header=yes | | 292 | *) printed_header=yes |
295 | ${ECHO} "===========================================================================" | | 293 | ${ECHO} "===========================================================================" |
296 | ${ECHO} "The following files should be created for ${PKGNAME}:" | | 294 | ${ECHO} "The following files should be created for ${PKGNAME}:" |
297 | ;; | | 295 | ;; |
298 | esac | | 296 | esac |
299 | ${ECHO} "" | | 297 | ${ECHO} "" |
300 | case $f_mode:$f_user:$f_group in | | 298 | case $f_mode:$f_user:$f_group in |
301 | ::) | | 299 | ::) |
302 | ${ECHO} " $file" | | 300 | ${ECHO} " $file" |
303 | ;; | | 301 | ;; |
304 | [!:]*::) | | 302 | [!:]*::) |
305 | ${ECHO} " $file (m=$f_mode)" | | 303 | ${ECHO} " $file (m=$f_mode)" |
306 | ;; | | 304 | ;; |
307 | [!:]*:[!:]*:) | | 305 | [!:]*:[!:]*:) |
308 | ${ECHO} " $file (m=$f_mode, o=$f_user)" | | 306 | ${ECHO} " $file (m=$f_mode, o=$f_user)" |
309 | ;; | | 307 | ;; |
310 | [!:]*:[!:]*:[!:]*) | | 308 | [!:]*:[!:]*:[!:]*) |
311 | ${ECHO} " $file (m=$f_mode, o=$f_user, g=$f_group)" | | 309 | ${ECHO} " $file (m=$f_mode, o=$f_user, g=$f_group)" |
312 | ;; | | 310 | ;; |
313 | esac | | 311 | esac |
314 | ${TEST} ! -f "$f_eg" || ${ECHO} " [$f_eg]" | | 312 | ${TEST} ! -f "$f_eg" || ${ECHO} " [$f_eg]" |
315 | done | | 313 | done |
316 | case "$printed_header" in | | 314 | case "$printed_header" in |
317 | yes) ${ECHO} "" | | 315 | yes) ${ECHO} "" |
318 | ${ECHO} "===========================================================================" | | 316 | ${ECHO} "===========================================================================" |
319 | exit 1 | | 317 | exit 1 |
320 | ;; | | 318 | ;; |
321 | esac; } | | 319 | esac; } |
322 | ${TEST} $? -eq 0 || exitcode=1 | | 320 | ${TEST} $? -eq 0 || exitcode=1 |
323 | ;; | | 321 | ;; |
324 | | | 322 | |
325 | CHECK-REMOVE) | | 323 | CHECK-REMOVE) |
326 | ${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru | | | 324 | ${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru | |
327 | { while read file f_flags f_eg f_mode f_user f_group; do | | 325 | { while read file f_flags f_eg f_mode f_user f_group; do |
328 | case $file in | | 326 | case $file in |
329 | "") continue ;; | | 327 | "") continue ;; |
330 | [!/]*) file="${PKG_PREFIX}/$file" ;; | | 328 | [!/]*) file="${PKG_PREFIX}/$file" ;; |
331 | esac | | 329 | esac |
332 | ${TEST} -f "$file" || continue | | 330 | ${TEST} -f "$file" || continue |
333 | shadow_dir="${PKG_REFCOUNT_FILES_DBDIR}$file" | | 331 | shadow_dir="${PKG_REFCOUNT_FILES_DBDIR}$file" |
334 | ${TEST} ! -d "$shadow_dir" || continue # refcount isn't zero | | 332 | ${TEST} ! -d "$shadow_dir" || continue # refcount isn't zero |
335 | case "$printed_header" in | | 333 | case "$printed_header" in |
336 | yes) ;; | | 334 | yes) ;; |
337 | *) printed_header=yes | | 335 | *) printed_header=yes |
338 | ${ECHO} "===========================================================================" | | 336 | ${ECHO} "===========================================================================" |
339 | ${ECHO} "The following files are no longer being used by ${PKGNAME}," | | 337 | ${ECHO} "The following files are no longer being used by ${PKGNAME}," |
340 | ${ECHO} "and they can be removed if no other packages are using them:" | | 338 | ${ECHO} "and they can be removed if no other packages are using them:" |
341 | ${ECHO} "" | | 339 | ${ECHO} "" |
342 | ;; | | 340 | ;; |
343 | esac | | 341 | esac |
344 | ${ECHO} " $file" | | 342 | ${ECHO} " $file" |
345 | done | | 343 | done |
346 | case "$printed_header" in | | 344 | case "$printed_header" in |
347 | yes) ${ECHO} "" | | 345 | yes) ${ECHO} "" |
348 | ${ECHO} "===========================================================================" | | 346 | ${ECHO} "===========================================================================" |
349 | exit 1 | | 347 | exit 1 |
350 | ;; | | 348 | ;; |
351 | esac; } | | 349 | esac; } |
352 | ${TEST} $? -eq 0 || exitcode=1 | | 350 | ${TEST} $? -eq 0 || exitcode=1 |
353 | ;; | | 351 | ;; |
354 | | | 352 | |
355 | CHECK-PERMS) | | 353 | CHECK-PERMS) |
356 | tmpdir="./.pkginstall.$$" | | 354 | tmpdir="./.pkginstall.$$" |
357 | ${MKDIR} -p $tmpdir 2>/dev/null || exit 1 | | 355 | ${MKDIR} -p $tmpdir 2>/dev/null || exit 1 |
358 | ${CHMOD} 0700 $tmpdir | | 356 | ${CHMOD} 0700 $tmpdir |
359 | ${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru | | | 357 | ${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru | |
360 | { while read file f_flags f_eg f_mode f_user f_group; do | | 358 | { while read file f_flags f_eg f_mode f_user f_group; do |
361 | case $file in | | 359 | case $file in |
362 | "") continue ;; | | 360 | "") continue ;; |
363 | [!/]*) file="${PKG_PREFIX}/$file" ;; | | 361 | [!/]*) file="${PKG_PREFIX}/$file" ;; |
364 | esac | | 362 | esac |
365 | ${TEST} -f "$file" || continue | | 363 | ${TEST} -f "$file" || continue |
366 | case $f_mode:$f_user:$f_group in | | 364 | case $f_mode:$f_user:$f_group in |
367 | ::) continue ;; | | 365 | ::) continue ;; |
368 | esac | | 366 | esac |
369 | | | 367 | |
370 | perms=`${LS} -l $file | ${AWK} '{ print $1":"$3":"$4 }'` | | 368 | perms=`${LS} -l $file | ${AWK} '{ print $1":"$3":"$4 }'` |
371 | testpath="$tmpdir/file_perms" | | 369 | testpath="$tmpdir/file_perms" |
372 | ${ECHO} > $testpath | | 370 | ${ECHO} > $testpath |
373 | ${CHMOD} $f_mode $testpath 2>/dev/null | | 371 | ${CHMOD} $f_mode $testpath 2>/dev/null |
374 | longmode=`${LS} -l $testpath | ${AWK} '{ print $1 }'` | | 372 | longmode=`${LS} -l $testpath | ${AWK} '{ print $1 }'` |
375 | case $f_mode:$f_user:$f_group in | | 373 | case $f_mode:$f_user:$f_group in |
376 | :[!:]*:) | | 374 | :[!:]*:) |
377 | case "$perms" in | | 375 | case "$perms" in |
378 | *:$f_user:*) continue ;; | | 376 | *:$f_user:*) continue ;; |
379 | esac | | 377 | esac |
380 | ;; | | 378 | ;; |
381 | :[!:]*:[!:]*) | | 379 | :[!:]*:[!:]*) |
382 | case "$perms" in | | 380 | case "$perms" in |
383 | *:$f_user:$f_group) continue ;; | | 381 | *:$f_user:$f_group) continue ;; |
384 | esac | | 382 | esac |
385 | ;; | | 383 | ;; |
386 | [!:]*::) | | 384 | [!:]*::) |
387 | case "$perms" in | | 385 | case "$perms" in |
388 | $longmode:*:*) continue ;; | | 386 | $longmode:*:*) continue ;; |
389 | esac | | 387 | esac |
390 | ;; | | 388 | ;; |
391 | [!:]*:[!:]*:) | | 389 | [!:]*:[!:]*:) |
392 | case "$perms" in | | 390 | case "$perms" in |
393 | $longmode:$f_user:*) continue ;; | | 391 | $longmode:$f_user:*) continue ;; |
394 | esac | | 392 | esac |
395 | ;; | | 393 | ;; |
396 | [!:]*:[!:]*:[!:]*) | | 394 | [!:]*:[!:]*:[!:]*) |
397 | case "$perms" in | | 395 | case "$perms" in |
398 | $longmode:$f_user:$f_group) continue ;; | | 396 | $longmode:$f_user:$f_group) continue ;; |
399 | esac | | 397 | esac |
400 | ;; | | 398 | ;; |
401 | esac | | 399 | esac |
402 | | | 400 | |
403 | case "$printed_header" in | | 401 | case "$printed_header" in |
404 | yes) ;; | | 402 | yes) ;; |
405 | *) printed_header=yes | | 403 | *) printed_header=yes |
406 | ${ECHO} "===========================================================================" | | 404 | ${ECHO} "===========================================================================" |
407 | ${ECHO} "The following files are used by ${PKGNAME} and have" | | 405 | ${ECHO} "The following files are used by ${PKGNAME} and have" |
408 | ${ECHO} "the wrong ownership and/or permissions:" | | 406 | ${ECHO} "the wrong ownership and/or permissions:" |
409 | ${ECHO} "" | | 407 | ${ECHO} "" |
410 | ;; | | 408 | ;; |
411 | esac | | 409 | esac |
412 | case $f_mode:$f_user:$f_group in | | 410 | case $f_mode:$f_user:$f_group in |
413 | [!:]*::) | | 411 | [!:]*::) |
414 | ${ECHO} " $file (m=$f_mode)" | | 412 | ${ECHO} " $file (m=$f_mode)" |
415 | ;; | | 413 | ;; |
416 | [!:]*:[!:]*:) | | 414 | [!:]*:[!:]*:) |
417 | ${ECHO} " $file (m=$f_mode, o=$f_user)" | | 415 | ${ECHO} " $file (m=$f_mode, o=$f_user)" |
418 | ;; | | 416 | ;; |
419 | [!:]*:[!:]*:[!:]*) | | 417 | [!:]*:[!:]*:[!:]*) |
420 | ${ECHO} " $file (m=$f_mode, o=$f_user, g=$f_group)" | | 418 | ${ECHO} " $file (m=$f_mode, o=$f_user, g=$f_group)" |
421 | ;; | | 419 | ;; |
422 | esac | | 420 | esac |
423 | done | | 421 | done |
424 | case "$printed_header" in | | 422 | case "$printed_header" in |
425 | yes) ${ECHO} "" | | 423 | yes) ${ECHO} "" |
426 | ${ECHO} "===========================================================================" | | 424 | ${ECHO} "===========================================================================" |
427 | exit 1 | | 425 | exit 1 |
428 | ;; | | 426 | ;; |
429 | esac; } | | 427 | esac; } |
430 | ${TEST} $? -eq 0 || exitcode=1 | | 428 | ${TEST} $? -eq 0 || exitcode=1 |
431 | ${RM} -fr $tmpdir | | 429 | ${RM} -fr $tmpdir |
432 | ;; | | 430 | ;; |
433 | | | 431 | |
434 | *) | | 432 | *) |
435 | ${ECHO} "Usage: ./+FILES ADD|REMOVE|PERMS [metadatadir]" | | 433 | ${ECHO} "Usage: ./+FILES ADD|REMOVE|PERMS [metadatadir]" |
436 | ${ECHO} " ./+FILES VIEW-REMOVE depotdir viewdir" | | 434 | ${ECHO} " ./+FILES VIEW-REMOVE depotdir viewdir" |
437 | ${ECHO} " ./+FILES CHECK-ADD|CHECK-REMOVE|CHECK-PERMS [metadatadir]" | | 435 | ${ECHO} " ./+FILES CHECK-ADD|CHECK-REMOVE|CHECK-PERMS [metadatadir]" |
438 | ;; | | 436 | ;; |
439 | esac | | 437 | esac |
440 | exit $exitcode | | 438 | exit $exitcode |
441 | | | 439 | |
442 | EOF | | 440 | EOF |
443 | ${SED} -n "/^\# FILE: /p" ${SELF} >> ./+FILES | | 441 | ${SED} -n "/^\# FILE: /p" ${SELF} >> ./+FILES |
444 | ${CHMOD} +x ./+FILES | | 442 | ${CHMOD} +x ./+FILES |
445 | ;; | | 443 | ;; |
446 | esac | | 444 | esac |
447 | | | 445 | |