Annotation of pkgsrc/pkgtools/pkg_rolling-replace/files/pkg_rolling-replace.sh, revision 1.39
1.1 gdt 1: #!/bin/sh
2:
1.39 ! gdt 3: # $NetBSD: pkg_rolling-replace.sh,v 1.38 2019/04/26 18:14:15 gdt Exp $
1.1 gdt 4: #<license>
5: # Copyright (c) 2006 BBN Technologies Corp. All rights reserved.
6: #
7: # Redistribution and use in source and binary forms, with or without
8: # modification, are permitted provided that the following conditions
9: # are met:
10: # 1. Redistributions of source code must retain the above copyright
11: # notice, this list of conditions and the following disclaimer.
12: # 2. Redistributions in binary form must reproduce the above copyright
13: # notice, this list of conditions and the following disclaimer in the
14: # documentation and/or other materials provided with the distribution.
15: # 3. Neither the name of BBN Technologies nor the names of its contributors
16: # may be used to endorse or promote products derived from this software
17: # without specific prior written permission.
18: #
19: # THIS SOFTWARE IS PROVIDED BY BBN TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
20: # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21: # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22: # ARE DISCLAIMED. IN NO EVENT SHALL BBN TECHNOLOGIES OR CONTRIBUTORS BE
23: # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24: # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25: # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26: # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27: # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28: # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29: # POSSIBILITY OF SUCH DAMAGE.
30: #
31: # Effort sponsored in part by the Defense Advanced Research Projects
32: # Agency (DARPA) and the Department of the Interior National Business
33: # Center under agreement number NBCHC050166.
34: #</license>
35:
36: # REVIEW NOTATION LEGEND
37: # XXX marks things that are broken/kludgy
38: # TODO marks things that need to be done
39: # FIXED marks items fixed, needs review and deletion of FIXED comment
40:
41: # Items to be completed for initial release:
42:
43: # TODO: move bulk of help into a real man page.
44:
45: # Items for future work (some imply changes in pkgsrc, not necessarily here)
46: #
47: # Make a pass over all packages for build depends, and rememeber
48: # which packages have been so checked. Check newly unsafe packages.
49: # The current lazy evaluation can perhaps fail to do things in the
50: # right order. Alternatively, explain why the current scheme is safe
51: # and preferred.
52: #
53: # Consider expansion to update via binary packages. This raises
54: # interesting questions about ABIs and binary builds
55: #
56: # Deal with conflicts in a smarter way, perhaps more automatically.
57: # This is hard because just removing packages is not ok.
58: #
59: # Handle foo being split into foo and foo-share. Now, make replace
60: # of foo pulls in foo-share which conflicts with foo. This needlessly
61: # loses.
62: #
63:
1.3 tnn 64: # Substituted by pkgsrc at pre-configure time.
1.4 tnn 65: MAKE="@MAKE@"
1.15 tnn 66: AWK="@AWK@"
1.3 tnn 67:
1.19 apb 68: if [ -z "$MAKECONF" ] ; then
69: for mkconf in "@MAKECONF@" "@PREFIX@/etc/mk.conf" /etc/mk.conf ; do
70: if [ -f "$mkconf" ] ; then
71: MAKECONF="$mkconf"
72: break
73: fi
74: done
75: fi
76: if [ -z "$MAKECONF" -o ! -f "$MAKECONF" ] ; then
77: MAKECONF=/dev/null
78: fi
1.7 tnn 79: test -f "$MAKECONF" && test -z "$PKGSRCDIR" && PKGSRCDIR="` \
80: printf '.include "%s"\n_print_pkgsrcdir:\n\t@echo "${PKGSRCDIR}"\n' \
1.8 tnn 81: "$MAKECONF" | "$MAKE" -f - BSD_PKG_MK=1 _print_pkgsrcdir`"
1.19 apb 82: if [ -z "$PKGSRCDIR" ] ; then
83: for dir in . .. ../.. /usr/pkgsrc ; do
84: if [ -f "${dir}/mk/bsd.pkg.mk" ]; then
85: case "${dir}" in
86: /*) PKGSRCDIR="${dir}" ;;
87: *) PKGSRCDIR="$( cd "${dir}" >/dev/null 2>&1 && pwd )" ;;
88: esac
89: break
90: fi
91: done
92: fi
93: test -z "$PKGSRCDIR" && echo >&2 "Please set PKGSRCDIR" && exit 1
1.12 tnn 94: test -z "$PKG_CHK" && PKG_CHK="@PKG_CHK@"
95: test -z "$PKG_INFO" && PKG_INFO="@PKG_INFO_CMD@"
1.1 gdt 96:
1.19 apb 97: export PKGSRCDIR
98:
1.1 gdt 99: unset PKG_PATH || true #or pkgsrc makefiles will complain
100:
101: usage()
102: {
103: echo "Usage: pkg_rolling-replace [opts]
104: -h This help
1.34 abs 105: -B Pass -B to pkg_chk (only applies with -u)
1.22 sno 106: -F Fetch sources (including depends) only, don't build
107: -k Keep running, even on error
1.1 gdt 108: -n Don't actually do make replace
1.13 tnn 109: -r Just replace, don't create binary packages
110: -s Replace even if the ABIs are still compatible ("strict")
1.17 apb 111: -u Update outdated packages
1.1 gdt 112: -v Verbose
1.25 sno 113: -D VAR=VAL Passes given variables and values to make
1.22 sno 114: -L <path> Log to path (<path>/pkgdir/pkg)
1.20 wiz 115: -X <pkg> exclude <pkg> from being rebuilt
1.17 apb 116: -x <pkg> exclude <pkg> from outdated check
1.1 gdt 117:
118: pkg_rolling-replace does 'make replace' on one package at a time,
119: tsorting the packages being replaced according to their
120: interdependencies, which avoids most duplicate rebuilds.
121:
122: pkg_rolling-replace can be used in one of two ways:
123:
124: - 'make replace' is unsafe in that, if the replaced package's ABI
125: changes, its dependent packages may break. If this happens, run
126: 'pkg_rolling-replace' (no arguments) to rebuild them against the
127: new version.
128:
129: - 'pkg_chk -u' will delete all your mismatched (outdated)
130: packages, then reinstall them one at a time, leaving you without
131: those packages in the meantime. 'pkg_rolling-replace -u' will
132: instead upgrade them in place, allowing you to keep using your
133: system in the meantime (maybe...if you're lucky...because
134: pkg_rolling-replace replaces the \"deepest\" dependency first,
135: things could still break if that happens to be a fundamental
136: library whose ABI has changed).
137: "
138: exit 1
139: }
140:
141: # pkg_rolling-replace's output is intermingled with pkgsrc make
142: # output. Thus, we use a different prefix. pkgsrc uses '===>' for
143: # major steps, and '=>' for minor ones. Thus, we use 'RR>'.
144:
145: OPI='RR>'
146: OPC='rr>' # continuation
147:
148:
149: # Echo the names of packages needing updates, versions stripped. This
150: # has been tested with pkg_chk 1.76. Older versions are not
151: # supported. Newer versions may or may not work (patches welcome).
152: check_packages_mismatched()
153: {
1.39 ! gdt 154: ${PKG_CHK} -u -q $opt_B | egrep -v missing | while read line; do
1.1 gdt 155: # duplicate output of pkg_chk to stderr (bypass $(...) or `...`)
1.11 tnn 156: echo "${OPC} $line" 1>&2
1.1 gdt 157: # Look for the first thing that looks like pkg-version rather
158: # than category/pkg and remove the version.
159: for word in $line; do
1.5 tnn 160: if [ "$(echo $word | egrep '^[^/]+-[0-9][^-/]*$')" ]; then
161: echo $word | sed 's/-[0-9][^-]*$//'
1.1 gdt 162: break #done with this line
163: fi
164: done
165: done
166: }
167:
168: # usage: check_packages_w_flag flag
169: # echo packages with flag=YES
170: check_packages_w_flag()
171: {
172: _flag=$1; shift
1.12 tnn 173: for pkgver in $(${PKG_INFO} -e '*'); do
174: if ${PKG_INFO} -Bq $pkgver \
1.1 gdt 175: | egrep "^$_flag=[Yy][Ee][Ss]" > /dev/null; then
1.5 tnn 176: echo $pkgver | sed 's/-[0-9][^-]*$//'
1.1 gdt 177: fi
178: done
179: }
180:
181: # echo dep->pkg edges for all installed packages
182: depgraph_installed()
183: {
1.15 tnn 184: ${PKG_INFO} -N '*' | ${AWK} ' \
185: /^Information for/ { \
186: pkg=$3; sub("-[0-9][^-]*:$", "", pkg); \
187: print pkg" "pkg; \
188: state=1; \
189: } \
1.16 gdt 190: /^\** PACKAGE MAY NOT BE DELETED \**$/ { state=3; } \
1.15 tnn 191: /^./ { \
192: if (state == 2) { \
193: dep=$1; sub("-[0-9][^-]*$", "", dep); \
194: print dep" "pkg; \
195: } \
196: } \
197: /^Built using/ { \
198: state=2 \
199: } \
200: '
1.1 gdt 201: }
202:
203: # usage: who_requires pkg --in-graph DEPGRAPH
204: who_requires()
205: {
206: _target=$1; shift
207: test "$1" = '--in-graph' && shift || return $((false))
208:
209: while [ $# -gt 0 ]; do
210: _dep=$1; _pkg=$2; shift 2;
211: if [ $_dep = $_target -a $_dep != $_pkg ]; then
212: echo $_pkg
213: fi
214: done
215: }
216:
217: # usage: is_member x list
218: # return true (0) if x appears in list, false (1) otherwise
219: is_member()
220: {
221: _x="$1"; shift;
222: while [ $# -gt 0 -a "$1" != "$_x" ]; do
223: shift
224: done
225:
226: test $# -gt 0
227: }
228:
229: # usage: exclude list1 --from list2
230: # echo list2 with items from list1 excluded
231: exclude()
232: {
233: _excl=
234: while [ $# -gt 0 -a $1 != "--from" ]; do
235: _excl="$_excl $1"
236: shift
237: done
238: if [ $# -gt 0 ]; then
239: shift #discard '--from'
240: fi
241: while [ $# -gt 0 ]; do
242: is_member $1 $_excl || echo $1
243: shift
244: done
245: }
246:
247: # usage: uniquify list
248: # just does sort -u on list (equiv. to sort | uniq)
249: # CAUTION: reorders list
250: uniqify()
251: {
252: for _x in $*; do echo $_x; done | sort -u
253: }
254:
255: verbose()
256: {
257: if [ -n "$opt_v" ]; then
258: echo "$@"
259: fi
260: }
261:
262: vsleep()
263: {
264: if [ -n "$opt_v" ]; then
265: sleep $1
266: fi
267: }
268:
1.22 sno 269: report()
270: {
1.26 tnn 271: for a in $SUCCEEDED; do
1.22 sno 272: verbose "+ $a"
273: done
274:
275: for a in $FAILED; do
276: verbose "- $a"
277: done
278: }
279:
1.13 tnn 280: abort()
281: {
1.26 tnn 282: echo "*** $1"
283: echo "*** Please read the errors listed above, fix the problem,"
284: echo "*** then re-run pkg_rolling-replace to continue."
285: report
286: exit 1
287: }
288:
289: error()
290: {
1.28 tnn 291: if [ -z "$opt_k" ]; then
1.26 tnn 292: abort "$1"
293: fi
294: echo "*** $1"
295: }
296:
297: mark_as_succeeded()
298: {
1.27 tnn 299: SUCCEEDED=$(uniqify $SUCCEEDED $1)
1.26 tnn 300: }
301:
302: mark_as_failed()
303: {
1.27 tnn 304: FAILED=$(uniqify $FAILED $1)
1.13 tnn 305: }
306:
1.22 sno 307: todo()
308: {
309: if [ -z "$opt_F" ]; then
310: verbose "${OPI} Packages to rebuild:"
311: verbose "${OPC} MISMATCH_TODO=[$(echo $MISMATCH_TODO)]" #strip newlines
312: verbose "${OPC} REBUILD_TODO=[$(echo $REBUILD_TODO)]"
313: verbose "${OPC} UNSAFE_TODO=[$(echo $UNSAFE_TODO)]"
314: REPLACE_TODO=$(uniqify $MISMATCH_TODO $REBUILD_TODO $UNSAFE_TODO)
315: else
316: REPLACE_TODO=$(uniqify $MISMATCH_TODO)
317: verbose "${OPI} Packages to fetch:"
318: verbose "${OPC} MISMATCH_TODO=[$(echo $MISMATCH_TODO)]" #strip newlines
319: fi
320: REPLACE_TODO=$(exclude $REALLYEXCLUDE --from $REPLACE_TODO)
321: if [ -n "$FAILED" ]; then
322: REPLACE_TODO=$(exclude $FAILED --from $REPLACE_TODO)
323: fi
324: vsleep 2
325: }
326:
1.1 gdt 327: ######################################################################
328: ##
329: ## main()
330: ##
331:
332: EXCLUDE=
1.25 sno 333: MAKE_VAR="IN_PKG_ROLLING_REPLACE=1"
334: MAKE_VAR_SEP=" "
1.1 gdt 335:
1.34 abs 336: args=$(getopt BFhknursvD:x:X:L: $*)
1.1 gdt 337: if [ $? -ne 0 ]; then
338: opt_h=1
339: fi
340: set -- $args
341: while [ $# -gt 0 ]; do
342: case "$1" in
1.34 abs 343: -B) opt_B=-B ;;
1.22 sno 344: -F) opt_F=1 ;;
1.1 gdt 345: -h) opt_h=1 ;;
1.22 sno 346: -k) opt_k=1 ;;
1.1 gdt 347: -n) opt_n=1 ;;
1.13 tnn 348: -r) opt_r=1 ;;
349: -s) opt_s=1 ;;
1.1 gdt 350: -u) opt_u=1 ;;
351: -v) opt_v=1 ;;
1.25 sno 352: -D) MAKE_VAR="${MAKE_VAR}${MAKE_VAR_SEP}$2"; MAKE_VAR_SEP=" "; shift ;;
1.1 gdt 353: -x) EXCLUDE="$EXCLUDE $(echo $2 | sed 's/,/ /g')" ; shift ;;
1.17 apb 354: -X) REALLYEXCLUDE="$REALLYEXCLUDE $(echo $2 | sed 's/,/ /g')" ; shift ;;
1.22 sno 355: -L) LOGPATH="$2"; shift ;;
1.1 gdt 356: --) shift; break ;;
357: esac
358: shift
359: done
360:
361: if [ -n "$opt_h" ]; then
362: usage
363: fi
364:
1.13 tnn 365: if [ -n "$opt_s" ]; then
366: UNSAFE_VAR=unsafe_depends_strict
367: else
368: UNSAFE_VAR=unsafe_depends
369: fi
370:
1.25 sno 371: MAKE="${MAKE}${MAKE_VAR_SEP}${MAKE_VAR}"
372:
1.26 tnn 373: SUCCEEDED=""
1.22 sno 374: FAILED=""
375:
1.1 gdt 376: MISMATCH_TODO=
1.22 sno 377: if [ -n "$opt_u" -o -n "$opt_F" ]; then
1.1 gdt 378: echo "${OPI} Checking for mismatched installed packages using pkg_chk"
379: MISMATCH_TODO=$(check_packages_mismatched)
380: echo "${OPI} Excluding the following mismatched packages:"
381: echo "${OPC} EXCLUDE=[$EXCLUDE]"
382: MISMATCH_TODO=$(exclude $EXCLUDE --from $MISMATCH_TODO)
383: fi
384:
1.22 sno 385: if [ -z "$opt_F" ]; then
386: echo "${OPI} Checking for rebuild-requested installed packages (rebuild=YES)"
387: REBUILD_TODO=$(check_packages_w_flag 'rebuild')
1.1 gdt 388:
1.22 sno 389: echo "${OPI} Checking for unsafe installed packages (${UNSAFE_VAR}=YES)"
390: UNSAFE_TODO=$(check_packages_w_flag ${UNSAFE_VAR})
391: fi
1.1 gdt 392:
393: # DEPGRAPH_INSTALLED is rebuilt each round. DEPGRAPH_SRC will collect
394: # edges that we discover using 'make show-depends', but that weren't
395: # listed as depends by the installed version of a package, and
396: # DEPENDS_CHECKED lists packages for which we've already done that
397: # check.
398: DEPGRAPH_INSTALLED=
399: DEPGRAPH_SRC=
400: DEPENDS_CHECKED=
401:
1.22 sno 402: todo
1.1 gdt 403:
404: depgraph_built=0
405:
406: while [ -n "$REPLACE_TODO" ]; do
1.22 sno 407: fail=
408:
1.1 gdt 409: # don't rebuild depgraph if we continued from new-depends step below
410: if [ "$depgraph_built" -eq 0 ]; then
411: echo "${OPI} Building dependency graph for installed packages"
412: DEPGRAPH_INSTALLED=$(depgraph_installed)
413: depgraph_built=1
414: fi
415:
416: echo "${OPI} Tsorting dependency graph"
417: TSORTED=$(echo $DEPGRAPH_INSTALLED $DEPGRAPH_SRC | tsort)
1.29 gdt 418: pkgdir=
1.1 gdt 419: for pkg in $TSORTED; do
420: if is_member $pkg $REPLACE_TODO; then
1.29 gdt 421: pkgdir=$(${PKG_INFO} -Q PKGPATH $pkg)
1.38 gdt 422: [ -n "$pkgdir" ] || error "Couldn't extract PKGPATH from installed package $pkg"
1.1 gdt 423: break;
424: fi
425: done
1.29 gdt 426: # loop should never exit without selecting a package
427: [ -n "$pkgdir" ] || abort "pkg_chk reports the following packages need replacing, but they are not installed: $REPLACE_TODO"
1.26 tnn 428:
1.1 gdt 429: echo "${OPI} Selecting $pkg ($pkgdir) as next package to replace"
430: sleep 1
431:
432: # Newer versions in pkgsrc sometimes have more depends than are
433: # recorded for the installed version (this is entirely to be
434: # expected as packages are split, renamed, and add new features).
435: # When this happens, add the new edges to the graph and re-tsort.
436: # Don't re-tsort if the new edges were already installed once
437: # (otherwise we'll go into a loop).
438:
439: # XXX I'm not sure that DEPENDS_CHECKED is necessary, or whether
440: # simply ignoring new deps that aren't in $REPLACE_TODO would have
441: # been sufficient. The DEPENDS_CHECKED approach causes one extra
442: # tsort in some cases, which isn't overly expensive.
443:
444: # XXX After tsorting and choosing what to 'make replace', we
445: # filter out packages that aren't already installed and marked for
446: # replacement. This is safe, since uninstalled depends will be
447: # pulled in automatically by 'make replace'; but in rare cases it
448: # might be non-optimal, leading to a duplicate rebuild that we
449: # would have avoided had we selected the uninstalled package in
450: # tsorted order and run 'make install' on it. This seems like
451: # such a rare case that the added complexity isn't worth it.
452:
1.30 gdt 453: # Set PKGNAME_REQD to give underlying make processes a chance to
454: # set options derived from the package name. For example,
455: # the appropriate version of Python can be derived from the
1.35 wiz 456: # package name (so, when building py34-foo, use python-3.4,
1.33 wiz 457: # not python-2.7).
1.32 gdt 458: MAKE_SET_VARS="PKGNAME_REQD=${pkg}-*"
1.30 gdt 459:
1.1 gdt 460: if ! is_member $pkg $DEPENDS_CHECKED; then
461: echo "${OPI} Checking if $pkg has new depends..."
1.12 tnn 462: OLD_DEPENDS=$(${PKG_INFO} -Nq $pkg | sed 's/-[0-9][^-]*$//')
1.1 gdt 463: NEW_DEPENDS=
464: cd "$PKGSRCDIR/$pkgdir"
1.31 obache 465: bdeps=$(@SETENV@ ${MAKE_SET_VARS} ${MAKE} show-depends VARNAME=BUILD_DEPENDS)
1.37 gdt 466: tdeps=$(@SETENV@ ${MAKE_SET_VARS} ${MAKE} show-depends VARNAME=TOOL_DEPENDS)
1.31 obache 467: rdeps=$(@SETENV@ ${MAKE_SET_VARS} ${MAKE} show-depends)
1.37 gdt 468: for depver in $bdeps $tdeps $rdeps; do
1.10 tnn 469: dep=$(echo $depver | sed -e 's/[:[].*$/0/' -e 's/[<>]=/-/' \
470: -e 's/-[0-9][^-]*$//')
1.1 gdt 471: if ! is_member $dep $OLD_DEPENDS $NEW_DEPENDS; then
472: NEW_DEPENDS="$NEW_DEPENDS $dep"
473: DEPGRAPH_SRC="$DEPGRAPH_SRC $dep $pkg"
474: fi
475: done
476: DEPENDS_CHECKED="$DEPENDS_CHECKED $pkg"
477: if [ -n "$NEW_DEPENDS" ]; then
478: echo "${OPI} $pkg has the following new depends (need to re-tsort):"
479: echo "${OPC} [$(echo $NEW_DEPENDS)]"
480: sleep 2
481: continue
482: fi
483: fi
484:
1.22 sno 485: pkgname=$(${PKG_INFO} -e $pkg)
486: if [ -n "$LOGPATH" ]; then
487: logdir="$LOGPATH/`dirname $pkgdir`"
488: logfile="$logdir/$pkgname"
489: @MKDIR@ "$logdir" || abort "mkdir -p '$logdir' failed"
490: exec 3>"$logfile"
491: tail -f "$logfile" &
492: TAILPID=$!
493: fi
494:
1.1 gdt 495: # Do make replace, with clean before, and package and clean afterwards.
1.13 tnn 496: fail=
1.23 sno 497: if [ -d "$PKGSRCDIR/$pkgdir" ]; then
498: cd "$PKGSRCDIR/$pkgdir";
1.22 sno 499: else
1.36 gdt 500: fail=1
1.26 tnn 501: mark_as_failed $pkg
502: error "No package directory '$pkgdir' for $pkg."
1.22 sno 503: fi
1.23 sno 504:
505: if [ -z "$fail" ]; then
506: if [ -z "$opt_F" ]; then
507: echo "${OPI} Replacing $pkgname"
1.31 obache 508: cmd="@SETENV@ ${MAKE_SET_VARS} ${MAKE} clean || fail=1"
1.23 sno 509: if [ -n "$opt_n" ]; then
510: echo "${OPI} Would run: $cmd"
511: else
512: if [ -n "$logfile" ]; then
513: eval "$cmd" >&3 2>&3
514: else
515: eval "$cmd"
516: fi
517: if [ -n "$fail" ]; then
1.26 tnn 518: mark_as_failed $pkg
519: error "'make clean' failed for package $pkg."
1.23 sno 520: fi
521: fi
1.31 obache 522: cmd="@SETENV@ ${MAKE_SET_VARS} ${MAKE} replace || fail=1" # XXX OLDNAME= support? xmlrpc-c -> xmlrpc-c-ss
1.23 sno 523: else
524: echo "${OPI} Fetching $pkgname"
1.31 obache 525: cmd="@SETENV@ ${MAKE_SET_VARS} ${MAKE} fetch depends-fetch || fail=1"
1.23 sno 526: fi
527: fi
528:
1.22 sno 529: if [ -n "$opt_n" -a -z "$fail" ]; then
1.13 tnn 530: echo "${OPI} Would run: $cmd"
1.22 sno 531: elif [ -z "$fail" ]; then
532: if [ -n "$logfile" ]; then
533: eval "$cmd" >&3 2>&3
534: else
535: eval "$cmd"
536: fi
537: if [ -n "$fail" ]; then
1.26 tnn 538: mark_as_failed $pkg
539: error "'make replace' failed for package $pkg."
1.22 sno 540: fi
1.13 tnn 541: fi
1.22 sno 542: if [ -z "$opt_n" -a -z "$opt_k" -a -z "$opt_F" ]; then
1.13 tnn 543: [ -z "$(${PKG_INFO} -Q unsafe_depends_strict $pkg)" ] || \
544: abort "package $pkg still has unsafe_depends_strict."
545: [ -z "$(${PKG_INFO} -Q unsafe_depends $pkg)" ] || \
546: abort "package $pkg still has unsafe_depends."
547: [ -z "$(${PKG_INFO} -Q rebuild $pkg)" ] || \
548: abort "package $pkg is still requested to be rebuilt."
1.1 gdt 549: fi
1.18 gdt 550: # If -r not given, make a binary package.
1.22 sno 551: if [ -z "$opt_r" -a -z "$fail" -a -z "$opt_F" ]; then
1.13 tnn 552: echo "${OPI} Packaging $(${PKG_INFO} -e $pkg)"
1.31 obache 553: cmd="@SETENV@ ${MAKE_SET_VARS} ${MAKE} package || fail=1"
1.22 sno 554: if [ -n "$opt_n" -a -z "$fail" ]; then
1.13 tnn 555: echo "${OPI} Would run: $cmd"
1.22 sno 556: elif [ -z "$fail" ]; then
557: if [ -n "$logfile" ]; then
558: eval "$cmd" >&3 2>&3
559: else
560: eval "$cmd"
561: fi
562: if [ -n "$fail" ]; then
1.26 tnn 563: mark_as_failed $pkg
564: error "'make package' failed for package $pkg."
1.22 sno 565: fi
1.13 tnn 566: fi
1.1 gdt 567: fi
1.18 gdt 568: # Clean
1.22 sno 569: if [ -z "$opt_n" -a -z "$fail" -a -z "$opt_F" ]; then
1.31 obache 570: cmd="@SETENV@ ${MAKE_SET_VARS} ${MAKE} clean || fail=1"
1.22 sno 571: if [ -n "$logfile" ]; then
572: eval "$cmd" >&3 2>&3
573: else
574: eval "$cmd"
575: fi
576: if [ -n "$fail" ]; then
1.26 tnn 577: mark_as_failed $pkg
578: error "'make clean' failed for package $pkg."
1.22 sno 579: fi
580: fi
581:
582: if [ -z "$fail" ]; then
1.26 tnn 583: mark_as_succeeded $pkg
1.18 gdt 584: fi
585:
1.1 gdt 586: sleep 1
587:
588: # remove just-replaced package from all *_TODO lists
589: MISMATCH_TODO=$(exclude $pkg --from $MISMATCH_TODO)
590: REBUILD_TODO=$(exclude $pkg --from $REBUILD_TODO)
591: UNSAFE_TODO=$(exclude $pkg --from $UNSAFE_TODO)
592:
1.13 tnn 593: echo "${OPI} Re-checking for unsafe installed packages (${UNSAFE_VAR}=YES)"
1.1 gdt 594: if [ -n "$opt_n" ]; then
595: # With -n, the replace didn't happen, and thus the packages that would
596: # have been marked unsafe_depends=YES were not. Add the set that
597: # would have been marked so we can watch what pkg_rolling-replace
598: # would have done (approximately).
599: UNSAFE_TODO=$(uniqify $UNSAFE_TODO \
600: $(who_requires $pkg --in-graph $DEPGRAPH_INSTALLED))
601: sleep 1
602: else
1.13 tnn 603: UNSAFE_TODO=$(check_packages_w_flag ${UNSAFE_VAR})
1.1 gdt 604: fi
605:
1.22 sno 606: depgraph_built=0
607:
608: todo
609: vsleep 2
1.1 gdt 610:
1.22 sno 611: if [ -n "$logfile" ]; then
612: exec 3>&-
613: kill $TAILPID
614: fi
1.1 gdt 615: done
616:
617: echo "${OPI} No more packages to replace; done."
1.22 sno 618:
619: report
CVSweb <webmaster@jp.NetBSD.org>