Annotation of pkgsrc/pkgtools/pkg_rolling-replace/files/pkg_rolling-replace.sh, revision 1.48
1.1 gdt 1: #!/bin/sh
2:
1.48 ! js 3: # $NetBSD: pkg_rolling-replace.sh,v 1.47 2024/01/03 12:35:22 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@"
1.42 tnn 95: test -z "$PKG_ADMIN" && PKG_ADMIN="@PKG_ADMIN_CMD@"
1.12 tnn 96: test -z "$PKG_INFO" && PKG_INFO="@PKG_INFO_CMD@"
1.1 gdt 97:
1.19 apb 98: export PKGSRCDIR
99:
1.1 gdt 100: unset PKG_PATH || true #or pkgsrc makefiles will complain
101:
102: usage()
103: {
104: echo "Usage: pkg_rolling-replace [opts]
105: -h This help
1.34 abs 106: -B Pass -B to pkg_chk (only applies with -u)
1.22 sno 107: -F Fetch sources (including depends) only, don't build
108: -k Keep running, even on error
1.1 gdt 109: -n Don't actually do make replace
1.13 tnn 110: -r Just replace, don't create binary packages
111: -s Replace even if the ABIs are still compatible ("strict")
1.41 rhialto 112: -u Update mismatched packages
1.1 gdt 113: -v Verbose
1.25 sno 114: -D VAR=VAL Passes given variables and values to make
1.22 sno 115: -L <path> Log to path (<path>/pkgdir/pkg)
1.20 wiz 116: -X <pkg> exclude <pkg> from being rebuilt
1.41 rhialto 117: -x <pkg> exclude <pkg> from mismatch check
1.1 gdt 118:
119: pkg_rolling-replace does 'make replace' on one package at a time,
120: tsorting the packages being replaced according to their
121: interdependencies, which avoids most duplicate rebuilds.
122:
123: pkg_rolling-replace can be used in one of two ways:
124:
125: - 'make replace' is unsafe in that, if the replaced package's ABI
126: changes, its dependent packages may break. If this happens, run
127: 'pkg_rolling-replace' (no arguments) to rebuild them against the
128: new version.
129:
1.41 rhialto 130: - 'pkg_chk -u' will delete all your mismatched packages (where the
131: package version does not match the pkgsrc version), then reinstall
132: them one at a time, leaving you without those packages in the
133: meantime. 'pkg_rolling-replace -u' will instead upgrade them in
134: place, allowing you to keep using your system in the meantime
135: (maybe...if you're lucky...because pkg_rolling-replace replaces
136: the \"deepest\" dependency first, things could still break if that
137: happens to be a fundamental library whose ABI has changed).
1.1 gdt 138: "
139: exit 1
140: }
141:
142: # pkg_rolling-replace's output is intermingled with pkgsrc make
143: # output. Thus, we use a different prefix. pkgsrc uses '===>' for
144: # major steps, and '=>' for minor ones. Thus, we use 'RR>'.
145:
146: OPI='RR>'
147: OPC='rr>' # continuation
148:
149:
150: # Echo the names of packages needing updates, versions stripped. This
151: # has been tested with pkg_chk 1.76. Older versions are not
152: # supported. Newer versions may or may not work (patches welcome).
153: check_packages_mismatched()
154: {
1.43 rhialto 155: warned_once=""
156:
1.48 ! js 157: ${PKG_CHK} -u -q $opt_B | grep -E -v missing | while read line; do
1.1 gdt 158: # duplicate output of pkg_chk to stderr (bypass $(...) or `...`)
1.11 tnn 159: echo "${OPC} $line" 1>&2
1.1 gdt 160: # Look for the first thing that looks like pkg-version rather
161: # than category/pkg and remove the version.
162: for word in $line; do
1.48 ! js 163: if [ "$(echo $word | grep -E '^[^/]+-[0-9][^-/]*$')" ]; then
1.41 rhialto 164: if [ -z "$opt_F" ]; then
1.47 gdt 165: ${PKG_ADMIN} set mismatch=YES "$word" >/dev/null 2>&1 || {
1.43 rhialto 166: if [ -z "$warned_once" ]; then
167: echo 1>&2 "$OPC WARNING: mismatch variable not set due to permissions;"
168: echo 1>&2 "$OPC mismatch status will not persist."
169: warned_once=1
170: fi
171: }
1.41 rhialto 172: fi
1.5 tnn 173: echo $word | sed 's/-[0-9][^-]*$//'
1.1 gdt 174: break #done with this line
175: fi
176: done
177: done
178: }
179:
180: # usage: check_packages_w_flag flag
181: # echo packages with flag=YES
182: check_packages_w_flag()
183: {
184: _flag=$1; shift
1.12 tnn 185: for pkgver in $(${PKG_INFO} -e '*'); do
186: if ${PKG_INFO} -Bq $pkgver \
1.48 ! js 187: | grep -E "^$_flag=[Yy][Ee][Ss]" > /dev/null; then
1.5 tnn 188: echo $pkgver | sed 's/-[0-9][^-]*$//'
1.1 gdt 189: fi
190: done
191: }
192:
193: # echo dep->pkg edges for all installed packages
194: depgraph_installed()
195: {
1.15 tnn 196: ${PKG_INFO} -N '*' | ${AWK} ' \
197: /^Information for/ { \
198: pkg=$3; sub("-[0-9][^-]*:$", "", pkg); \
199: print pkg" "pkg; \
200: state=1; \
201: } \
1.16 gdt 202: /^\** PACKAGE MAY NOT BE DELETED \**$/ { state=3; } \
1.15 tnn 203: /^./ { \
204: if (state == 2) { \
205: dep=$1; sub("-[0-9][^-]*$", "", dep); \
206: print dep" "pkg; \
207: } \
208: } \
209: /^Built using/ { \
210: state=2 \
211: } \
212: '
1.1 gdt 213: }
214:
215: # usage: who_requires pkg --in-graph DEPGRAPH
216: who_requires()
217: {
218: _target=$1; shift
219: test "$1" = '--in-graph' && shift || return $((false))
220:
221: while [ $# -gt 0 ]; do
222: _dep=$1; _pkg=$2; shift 2;
223: if [ $_dep = $_target -a $_dep != $_pkg ]; then
224: echo $_pkg
225: fi
226: done
227: }
228:
229: # usage: is_member x list
230: # return true (0) if x appears in list, false (1) otherwise
231: is_member()
232: {
233: _x="$1"; shift;
234: while [ $# -gt 0 -a "$1" != "$_x" ]; do
235: shift
236: done
237:
238: test $# -gt 0
239: }
240:
241: # usage: exclude list1 --from list2
242: # echo list2 with items from list1 excluded
243: exclude()
244: {
245: _excl=
246: while [ $# -gt 0 -a $1 != "--from" ]; do
247: _excl="$_excl $1"
248: shift
249: done
250: if [ $# -gt 0 ]; then
251: shift #discard '--from'
252: fi
253: while [ $# -gt 0 ]; do
254: is_member $1 $_excl || echo $1
255: shift
256: done
257: }
258:
259: # usage: uniquify list
260: # just does sort -u on list (equiv. to sort | uniq)
261: # CAUTION: reorders list
262: uniqify()
263: {
264: for _x in $*; do echo $_x; done | sort -u
265: }
266:
267: verbose()
268: {
269: if [ -n "$opt_v" ]; then
270: echo "$@"
271: fi
272: }
273:
274: vsleep()
275: {
276: if [ -n "$opt_v" ]; then
277: sleep $1
278: fi
279: }
280:
1.22 sno 281: report()
282: {
1.26 tnn 283: for a in $SUCCEEDED; do
1.22 sno 284: verbose "+ $a"
285: done
286:
287: for a in $FAILED; do
288: verbose "- $a"
289: done
290: }
291:
1.13 tnn 292: abort()
293: {
1.26 tnn 294: echo "*** $1"
295: echo "*** Please read the errors listed above, fix the problem,"
296: echo "*** then re-run pkg_rolling-replace to continue."
297: report
298: exit 1
299: }
300:
301: error()
302: {
1.28 tnn 303: if [ -z "$opt_k" ]; then
1.26 tnn 304: abort "$1"
305: fi
306: echo "*** $1"
307: }
308:
309: mark_as_succeeded()
310: {
1.27 tnn 311: SUCCEEDED=$(uniqify $SUCCEEDED $1)
1.26 tnn 312: }
313:
314: mark_as_failed()
315: {
1.27 tnn 316: FAILED=$(uniqify $FAILED $1)
1.13 tnn 317: }
318:
1.22 sno 319: todo()
320: {
321: if [ -z "$opt_F" ]; then
322: verbose "${OPI} Packages to rebuild:"
323: verbose "${OPC} MISMATCH_TODO=[$(echo $MISMATCH_TODO)]" #strip newlines
324: verbose "${OPC} REBUILD_TODO=[$(echo $REBUILD_TODO)]"
325: verbose "${OPC} UNSAFE_TODO=[$(echo $UNSAFE_TODO)]"
326: REPLACE_TODO=$(uniqify $MISMATCH_TODO $REBUILD_TODO $UNSAFE_TODO)
327: else
328: REPLACE_TODO=$(uniqify $MISMATCH_TODO)
329: verbose "${OPI} Packages to fetch:"
330: verbose "${OPC} MISMATCH_TODO=[$(echo $MISMATCH_TODO)]" #strip newlines
331: fi
332: REPLACE_TODO=$(exclude $REALLYEXCLUDE --from $REPLACE_TODO)
333: if [ -n "$FAILED" ]; then
334: REPLACE_TODO=$(exclude $FAILED --from $REPLACE_TODO)
335: fi
336: vsleep 2
337: }
338:
1.1 gdt 339: ######################################################################
340: ##
341: ## main()
342: ##
343:
344: EXCLUDE=
1.25 sno 345: MAKE_VAR="IN_PKG_ROLLING_REPLACE=1"
346: MAKE_VAR_SEP=" "
1.1 gdt 347:
1.45 mcf 348: while getopts BFhknursvD:x:X:L: opt; do
349: case "$opt" in
350: B) opt_B=-B ;;
351: F) opt_F=1 ;;
352: h) opt_h=1 ;;
353: k) opt_k=1 ;;
354: n) opt_n=1 ;;
355: r) opt_r=1 ;;
356: s) opt_s=1 ;;
357: u) opt_u=1 ;;
358: v) opt_v=1 ;;
359: D) MAKE_VAR="${MAKE_VAR}${MAKE_VAR_SEP}$OPTARG"; MAKE_VAR_SEP=" " ;;
360: x) EXCLUDE="$EXCLUDE $(echo $OPTARG | sed 's/,/ /g')" ;;
361: X) REALLYEXCLUDE="$REALLYEXCLUDE $(echo $OPTARG | sed 's/,/ /g')" ;;
362: L) LOGPATH="$OPTARG" ;;
363: ?) opt_h=1 ;;
1.1 gdt 364: esac
365: done
366:
367: if [ -n "$opt_h" ]; then
368: usage
369: fi
370:
1.13 tnn 371: if [ -n "$opt_s" ]; then
372: UNSAFE_VAR=unsafe_depends_strict
373: else
374: UNSAFE_VAR=unsafe_depends
375: fi
376:
1.25 sno 377: MAKE="${MAKE}${MAKE_VAR_SEP}${MAKE_VAR}"
378:
1.26 tnn 379: SUCCEEDED=""
1.22 sno 380: FAILED=""
381:
1.1 gdt 382: MISMATCH_TODO=
1.41 rhialto 383: if [ -n "$opt_u" ]; then
1.1 gdt 384: echo "${OPI} Checking for mismatched installed packages using pkg_chk"
385: MISMATCH_TODO=$(check_packages_mismatched)
1.41 rhialto 386: else
387: echo "${OPI} Checking for mismatched installed packages (mismatch=YES)"
388: MISMATCH_TODO=$(check_packages_w_flag 'mismatch')
1.1 gdt 389: fi
390:
1.41 rhialto 391: echo "${OPI} Excluding the following mismatched packages:"
392: echo "${OPC} EXCLUDE=[$EXCLUDE]"
393: MISMATCH_TODO=$(exclude $EXCLUDE --from $MISMATCH_TODO)
394:
1.22 sno 395: if [ -z "$opt_F" ]; then
396: echo "${OPI} Checking for rebuild-requested installed packages (rebuild=YES)"
397: REBUILD_TODO=$(check_packages_w_flag 'rebuild')
1.1 gdt 398:
1.22 sno 399: echo "${OPI} Checking for unsafe installed packages (${UNSAFE_VAR}=YES)"
400: UNSAFE_TODO=$(check_packages_w_flag ${UNSAFE_VAR})
401: fi
1.1 gdt 402:
403: # DEPGRAPH_INSTALLED is rebuilt each round. DEPGRAPH_SRC will collect
404: # edges that we discover using 'make show-depends', but that weren't
405: # listed as depends by the installed version of a package, and
406: # DEPENDS_CHECKED lists packages for which we've already done that
407: # check.
408: DEPGRAPH_INSTALLED=
409: DEPGRAPH_SRC=
410: DEPENDS_CHECKED=
411:
1.22 sno 412: todo
1.1 gdt 413:
414: depgraph_built=0
415:
416: while [ -n "$REPLACE_TODO" ]; do
1.22 sno 417: fail=
418:
1.1 gdt 419: # don't rebuild depgraph if we continued from new-depends step below
420: if [ "$depgraph_built" -eq 0 ]; then
421: echo "${OPI} Building dependency graph for installed packages"
422: DEPGRAPH_INSTALLED=$(depgraph_installed)
423: depgraph_built=1
424: fi
425:
426: echo "${OPI} Tsorting dependency graph"
427: TSORTED=$(echo $DEPGRAPH_INSTALLED $DEPGRAPH_SRC | tsort)
1.29 gdt 428: pkgdir=
1.1 gdt 429: for pkg in $TSORTED; do
430: if is_member $pkg $REPLACE_TODO; then
1.29 gdt 431: pkgdir=$(${PKG_INFO} -Q PKGPATH $pkg)
1.40 gdt 432: if [ -n "$pkgdir" ]; then
433: break;
434: else
435: error "Couldn't extract PKGPATH from installed package $pkg"
436: fi
1.1 gdt 437: fi
438: done
1.29 gdt 439: # loop should never exit without selecting a package
440: [ -n "$pkgdir" ] || abort "pkg_chk reports the following packages need replacing, but they are not installed: $REPLACE_TODO"
1.26 tnn 441:
1.1 gdt 442: echo "${OPI} Selecting $pkg ($pkgdir) as next package to replace"
443: sleep 1
444:
445: # Newer versions in pkgsrc sometimes have more depends than are
446: # recorded for the installed version (this is entirely to be
447: # expected as packages are split, renamed, and add new features).
448: # When this happens, add the new edges to the graph and re-tsort.
449: # Don't re-tsort if the new edges were already installed once
450: # (otherwise we'll go into a loop).
451:
452: # XXX I'm not sure that DEPENDS_CHECKED is necessary, or whether
453: # simply ignoring new deps that aren't in $REPLACE_TODO would have
454: # been sufficient. The DEPENDS_CHECKED approach causes one extra
455: # tsort in some cases, which isn't overly expensive.
456:
457: # XXX After tsorting and choosing what to 'make replace', we
458: # filter out packages that aren't already installed and marked for
459: # replacement. This is safe, since uninstalled depends will be
460: # pulled in automatically by 'make replace'; but in rare cases it
461: # might be non-optimal, leading to a duplicate rebuild that we
462: # would have avoided had we selected the uninstalled package in
463: # tsorted order and run 'make install' on it. This seems like
464: # such a rare case that the added complexity isn't worth it.
465:
1.30 gdt 466: # Set PKGNAME_REQD to give underlying make processes a chance to
467: # set options derived from the package name. For example,
468: # the appropriate version of Python can be derived from the
1.35 wiz 469: # package name (so, when building py34-foo, use python-3.4,
1.33 wiz 470: # not python-2.7).
1.32 gdt 471: MAKE_SET_VARS="PKGNAME_REQD=${pkg}-*"
1.30 gdt 472:
1.1 gdt 473: if ! is_member $pkg $DEPENDS_CHECKED; then
474: echo "${OPI} Checking if $pkg has new depends..."
1.12 tnn 475: OLD_DEPENDS=$(${PKG_INFO} -Nq $pkg | sed 's/-[0-9][^-]*$//')
1.1 gdt 476: NEW_DEPENDS=
477: cd "$PKGSRCDIR/$pkgdir"
1.31 obache 478: bdeps=$(@SETENV@ ${MAKE_SET_VARS} ${MAKE} show-depends VARNAME=BUILD_DEPENDS)
1.37 gdt 479: tdeps=$(@SETENV@ ${MAKE_SET_VARS} ${MAKE} show-depends VARNAME=TOOL_DEPENDS)
1.31 obache 480: rdeps=$(@SETENV@ ${MAKE_SET_VARS} ${MAKE} show-depends)
1.37 gdt 481: for depver in $bdeps $tdeps $rdeps; do
1.10 tnn 482: dep=$(echo $depver | sed -e 's/[:[].*$/0/' -e 's/[<>]=/-/' \
483: -e 's/-[0-9][^-]*$//')
1.1 gdt 484: if ! is_member $dep $OLD_DEPENDS $NEW_DEPENDS; then
485: NEW_DEPENDS="$NEW_DEPENDS $dep"
486: DEPGRAPH_SRC="$DEPGRAPH_SRC $dep $pkg"
487: fi
488: done
489: DEPENDS_CHECKED="$DEPENDS_CHECKED $pkg"
490: if [ -n "$NEW_DEPENDS" ]; then
491: echo "${OPI} $pkg has the following new depends (need to re-tsort):"
492: echo "${OPC} [$(echo $NEW_DEPENDS)]"
493: sleep 2
494: continue
495: fi
496: fi
497:
1.22 sno 498: pkgname=$(${PKG_INFO} -e $pkg)
499: if [ -n "$LOGPATH" ]; then
500: logdir="$LOGPATH/`dirname $pkgdir`"
501: logfile="$logdir/$pkgname"
502: @MKDIR@ "$logdir" || abort "mkdir -p '$logdir' failed"
503: exec 3>"$logfile"
504: tail -f "$logfile" &
505: TAILPID=$!
506: fi
507:
1.1 gdt 508: # Do make replace, with clean before, and package and clean afterwards.
1.13 tnn 509: fail=
1.23 sno 510: if [ -d "$PKGSRCDIR/$pkgdir" ]; then
511: cd "$PKGSRCDIR/$pkgdir";
1.22 sno 512: else
1.36 gdt 513: fail=1
1.26 tnn 514: mark_as_failed $pkg
515: error "No package directory '$pkgdir' for $pkg."
1.22 sno 516: fi
1.23 sno 517:
518: if [ -z "$fail" ]; then
519: if [ -z "$opt_F" ]; then
520: echo "${OPI} Replacing $pkgname"
1.31 obache 521: cmd="@SETENV@ ${MAKE_SET_VARS} ${MAKE} clean || fail=1"
1.23 sno 522: if [ -n "$opt_n" ]; then
523: echo "${OPI} Would run: $cmd"
524: else
525: if [ -n "$logfile" ]; then
526: eval "$cmd" >&3 2>&3
527: else
528: eval "$cmd"
529: fi
530: if [ -n "$fail" ]; then
1.26 tnn 531: mark_as_failed $pkg
532: error "'make clean' failed for package $pkg."
1.23 sno 533: fi
534: fi
1.31 obache 535: cmd="@SETENV@ ${MAKE_SET_VARS} ${MAKE} replace || fail=1" # XXX OLDNAME= support? xmlrpc-c -> xmlrpc-c-ss
1.23 sno 536: else
537: echo "${OPI} Fetching $pkgname"
1.31 obache 538: cmd="@SETENV@ ${MAKE_SET_VARS} ${MAKE} fetch depends-fetch || fail=1"
1.23 sno 539: fi
540: fi
541:
1.22 sno 542: if [ -n "$opt_n" -a -z "$fail" ]; then
1.13 tnn 543: echo "${OPI} Would run: $cmd"
1.22 sno 544: elif [ -z "$fail" ]; then
545: if [ -n "$logfile" ]; then
546: eval "$cmd" >&3 2>&3
547: else
548: eval "$cmd"
549: fi
550: if [ -n "$fail" ]; then
1.26 tnn 551: mark_as_failed $pkg
552: error "'make replace' failed for package $pkg."
1.22 sno 553: fi
1.13 tnn 554: fi
1.22 sno 555: if [ -z "$opt_n" -a -z "$opt_k" -a -z "$opt_F" ]; then
1.13 tnn 556: [ -z "$(${PKG_INFO} -Q unsafe_depends_strict $pkg)" ] || \
557: abort "package $pkg still has unsafe_depends_strict."
558: [ -z "$(${PKG_INFO} -Q unsafe_depends $pkg)" ] || \
559: abort "package $pkg still has unsafe_depends."
560: [ -z "$(${PKG_INFO} -Q rebuild $pkg)" ] || \
561: abort "package $pkg is still requested to be rebuilt."
1.41 rhialto 562: [ -z "$(${PKG_INFO} -Q mismatch $pkg)" ] || \
563: abort "package $pkg is still a mismatched version."
1.1 gdt 564: fi
1.18 gdt 565: # If -r not given, make a binary package.
1.22 sno 566: if [ -z "$opt_r" -a -z "$fail" -a -z "$opt_F" ]; then
1.13 tnn 567: echo "${OPI} Packaging $(${PKG_INFO} -e $pkg)"
1.31 obache 568: cmd="@SETENV@ ${MAKE_SET_VARS} ${MAKE} package || fail=1"
1.22 sno 569: if [ -n "$opt_n" -a -z "$fail" ]; then
1.13 tnn 570: echo "${OPI} Would run: $cmd"
1.22 sno 571: elif [ -z "$fail" ]; then
572: if [ -n "$logfile" ]; then
573: eval "$cmd" >&3 2>&3
574: else
575: eval "$cmd"
576: fi
577: if [ -n "$fail" ]; then
1.26 tnn 578: mark_as_failed $pkg
579: error "'make package' failed for package $pkg."
1.22 sno 580: fi
1.13 tnn 581: fi
1.1 gdt 582: fi
1.18 gdt 583: # Clean
1.22 sno 584: if [ -z "$opt_n" -a -z "$fail" -a -z "$opt_F" ]; then
1.31 obache 585: cmd="@SETENV@ ${MAKE_SET_VARS} ${MAKE} clean || fail=1"
1.22 sno 586: if [ -n "$logfile" ]; then
587: eval "$cmd" >&3 2>&3
588: else
589: eval "$cmd"
590: fi
591: if [ -n "$fail" ]; then
1.26 tnn 592: mark_as_failed $pkg
593: error "'make clean' failed for package $pkg."
1.22 sno 594: fi
595: fi
596:
597: if [ -z "$fail" ]; then
1.26 tnn 598: mark_as_succeeded $pkg
1.18 gdt 599: fi
600:
1.1 gdt 601: sleep 1
602:
603: # remove just-replaced package from all *_TODO lists
604: MISMATCH_TODO=$(exclude $pkg --from $MISMATCH_TODO)
605: REBUILD_TODO=$(exclude $pkg --from $REBUILD_TODO)
606: UNSAFE_TODO=$(exclude $pkg --from $UNSAFE_TODO)
607:
1.13 tnn 608: echo "${OPI} Re-checking for unsafe installed packages (${UNSAFE_VAR}=YES)"
1.1 gdt 609: if [ -n "$opt_n" ]; then
610: # With -n, the replace didn't happen, and thus the packages that would
611: # have been marked unsafe_depends=YES were not. Add the set that
612: # would have been marked so we can watch what pkg_rolling-replace
613: # would have done (approximately).
614: UNSAFE_TODO=$(uniqify $UNSAFE_TODO \
615: $(who_requires $pkg --in-graph $DEPGRAPH_INSTALLED))
616: sleep 1
617: else
1.13 tnn 618: UNSAFE_TODO=$(check_packages_w_flag ${UNSAFE_VAR})
1.1 gdt 619: fi
620:
1.22 sno 621: depgraph_built=0
622:
623: todo
624: vsleep 2
1.1 gdt 625:
1.22 sno 626: if [ -n "$logfile" ]; then
627: exec 3>&-
628: kill $TAILPID
629: fi
1.1 gdt 630: done
631:
632: echo "${OPI} No more packages to replace; done."
1.22 sno 633:
634: report
CVSweb <webmaster@jp.NetBSD.org>