| @@ -1,16 +1,16 @@ | | | @@ -1,16 +1,16 @@ |
1 | #!/bin/sh | | 1 | #!/bin/sh |
2 | # | | 2 | # |
3 | # $NetBSD: binpkg-cache,v 1.17 2007/10/13 17:46:12 rillig Exp $ | | 3 | # $NetBSD: binpkg-cache,v 1.18 2010/02/27 12:00:54 spz Exp $ |
4 | # | | 4 | # |
5 | # Script for generating a cache file with information about | | 5 | # Script for generating a cache file with information about |
6 | # all binary packages contained in a directory. | | 6 | # all binary packages contained in a directory. |
7 | # | | 7 | # |
8 | # Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. | | 8 | # Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. |
9 | # All rights reserved. | | 9 | # All rights reserved. |
10 | # | | 10 | # |
11 | # This code is derived from software contributed to The NetBSD Foundation | | 11 | # This code is derived from software contributed to The NetBSD Foundation |
12 | # by Dan McMahill. | | 12 | # by Dan McMahill. |
13 | # | | 13 | # |
14 | # Redistribution and use in source and binary forms, with or without | | 14 | # Redistribution and use in source and binary forms, with or without |
15 | # modification, are permitted provided that the following conditions | | 15 | # modification, are permitted provided that the following conditions |
16 | # are met: | | 16 | # are met: |
| @@ -196,27 +196,27 @@ process_binpkg_dir(){ | | | @@ -196,27 +196,27 @@ process_binpkg_dir(){ |
196 | echo "${tab}Invalid version cache file. ${d}/${cachefile} will be regenerated." | | 196 | echo "${tab}Invalid version cache file. ${d}/${cachefile} will be regenerated." |
197 | echo "Need version ${cacheversion} but the file has" | | 197 | echo "Need version ${cacheversion} but the file has" |
198 | ${GREP} "^pkgcache_version " ${d}/${cachefile} | | 198 | ${GREP} "^pkgcache_version " ${d}/${cachefile} |
199 | else | | 199 | else |
200 | echo "${tab}Cache file ${d}/${cachefile} is up to date." | | 200 | echo "${tab}Cache file ${d}/${cachefile} is up to date." |
201 | fi | | 201 | fi |
202 | fi | | 202 | fi |
203 | | | 203 | |
204 | if test "${build_summary}" = "yes" -a ! -f ${d}/${summaryfile}.gz ; then | | 204 | if test "${build_summary}" = "yes" -a ! -f ${d}/${summaryfile}.gz ; then |
205 | echo "${tab}Summary file ${d}/${summaryfile}.gz is missing and will be created." | | 205 | echo "${tab}Summary file ${d}/${summaryfile}.gz is missing and will be created." |
206 | need_update=yes | | 206 | need_update=yes |
207 | fi | | 207 | fi |
208 | if test "${build_summary}" = "yes" -a ${d}/${summaryfile}.gz -ot ${d}/${cachefile} ; then | | 208 | if test "${build_summary}" = "yes" -a ${d}/${summaryfile}.gz -ot ${d}/${cachefile} ; then |
209 | echo "${tab}Summary file ${d}/${summaryfile}.gz is out of date and will be regnerated." | | 209 | echo "${tab}Summary file ${d}/${summaryfile}.gz is out of date and will be regenerated." |
210 | need_update=yes | | 210 | need_update=yes |
211 | fi | | 211 | fi |
212 | | | 212 | |
213 | # FIX_ME | | 213 | # FIX_ME |
214 | # We should use stale_entries in a way where we only update the | | 214 | # We should use stale_entries in a way where we only update the |
215 | # cache file entries corresponding to these if we're rebuilding | | 215 | # cache file entries corresponding to these if we're rebuilding |
216 | # due to stale entries. That should save a good bit of time. | | 216 | # due to stale entries. That should save a good bit of time. |
217 | # | | 217 | # |
218 | if test "X${need_update}" = "Xyes" ; then | | 218 | if test "X${need_update}" = "Xyes" ; then |
219 | echo "pkgcache_version ${cacheversion}" > ${tmpd}/${cachefile} | | 219 | echo "pkgcache_version ${cacheversion}" > ${tmpd}/${cachefile} |
220 | rm -f ${tmpd}/${summaryfile} | | 220 | rm -f ${tmpd}/${summaryfile} |
221 | touch ${tmpd}/${summaryfile} | | 221 | touch ${tmpd}/${summaryfile} |
222 | for f in ${d}/*${PKG_SUFX} ; do | | 222 | for f in ${d}/*${PKG_SUFX} ; do |
| @@ -228,37 +228,43 @@ process_binpkg_dir(){ | | | @@ -228,37 +228,43 @@ process_binpkg_dir(){ |
228 | #eval $(${STAT} -s ${f} 2>/dev/null) | | 228 | #eval $(${STAT} -s ${f} 2>/dev/null) |
229 | echo "pkgcache_begin ${fn}" >> ${tmpd}/${cachefile} | | 229 | echo "pkgcache_begin ${fn}" >> ${tmpd}/${cachefile} |
230 | #echo "pkgcache_mtime=${st_mtime}" >> ${tmpd}/${cachefile} | | 230 | #echo "pkgcache_mtime=${st_mtime}" >> ${tmpd}/${cachefile} |
231 | | | 231 | |
232 | $if_debug echo "${PKG_INFO} -q -B ${f}" | | 232 | $if_debug echo "${PKG_INFO} -q -B ${f}" |
233 | ${PKG_INFO} -q -B ${f} >> ${tmpd}/${cachefile} | | 233 | ${PKG_INFO} -q -B ${f} >> ${tmpd}/${cachefile} |
234 | | | 234 | |
235 | if test "${build_summary}" = "yes" ; then | | 235 | if test "${build_summary}" = "yes" ; then |
236 | $if_debug echo "${PKG_INFO} -X ${f}" | | 236 | $if_debug echo "${PKG_INFO} -X ${f}" |
237 | ${PKG_INFO} -X ${f} >> ${tmpd}/${summaryfile} | | 237 | ${PKG_INFO} -X ${f} >> ${tmpd}/${summaryfile} |
238 | fi | | 238 | fi |
239 | echo "pkgcache_end ${fn}" >> ${tmpd}/${cachefile} | | 239 | echo "pkgcache_end ${fn}" >> ${tmpd}/${cachefile} |
240 | done | | 240 | done |
| | | 241 | if test -f ${d}/${cachefile} ; then |
| | | 242 | rm -f ${d}/${cachefile} |
| | | 243 | fi |
241 | mv -f ${tmpd}/${cachefile} ${d}/${cachefile} | | 244 | mv -f ${tmpd}/${cachefile} ${d}/${cachefile} |
242 | if test $? -ne 0 ; then | | 245 | if test $? -ne 0 ; then |
243 | echo "********** WARNING **********" | | 246 | echo "********** WARNING **********" |
244 | echo "move of ${tmpd}/${cachefile} to ${d}/${cachefile} failed!" | | 247 | echo "move of ${tmpd}/${cachefile} to ${d}/${cachefile} failed!" |
245 | echo "Perhaps you do not have write permissions to ${d}?" | | 248 | echo "Perhaps you do not have write permissions to ${d}?" |
246 | echo "This directory will be dropped from the master cache file." | | 249 | echo "This directory will be dropped from the master cache file." |
247 | echo "********** WARNING **********" | | 250 | echo "********** WARNING **********" |
248 | return | | 251 | return |
249 | fi | | 252 | fi |
250 | | | 253 | |
251 | if test "${build_summary}" = "yes" ; then | | 254 | if test "${build_summary}" = "yes" ; then |
| | | 255 | if test -f ${d}/${summaryfile}.gz ; then |
| | | 256 | rm -f ${d}/${summaryfile}.gz |
| | | 257 | fi |
252 | cat ${tmpd}/${summaryfile} | ${GZIP_CMD} > ${d}/${summaryfile}.gz | | 258 | cat ${tmpd}/${summaryfile} | ${GZIP_CMD} > ${d}/${summaryfile}.gz |
253 | if test $? -ne 0 ; then | | 259 | if test $? -ne 0 ; then |
254 | echo "********** WARNING **********" | | 260 | echo "********** WARNING **********" |
255 | echo "${GZIP_CMD} of ${tmpd}/${summaryfile} to ${d}/${summaryfile}.gz failed!" | | 261 | echo "${GZIP_CMD} of ${tmpd}/${summaryfile} to ${d}/${summaryfile}.gz failed!" |
256 | echo "Perhaps you do not have write permissions to ${d}?" | | 262 | echo "Perhaps you do not have write permissions to ${d}?" |
257 | echo "********** WARNING **********" | | 263 | echo "********** WARNING **********" |
258 | return | | 264 | return |
259 | fi | | 265 | fi |
260 | fi | | 266 | fi |
261 | | | 267 | |
262 | fi | | 268 | fi |
263 | | | 269 | |
264 | # if we got here, then this directory should have a good cache file in | | 270 | # if we got here, then this directory should have a good cache file in |