pkg_rolling-replace-0.10:

- Abort if any of rebuild, unsafe_depends, unsafe_depends_strict are still
  set after "make replace".
- Following changes in pkgsrc, does not replace by default if the
  dependencies' ABI is still compatible.
- Add option -s that retains the old behaviour of always replacing.
- Add option -r for "replace only", this supresses creation of binary pkgs.
- The -n option has not been fully updated for these changes.
- versions 0.[7-9] were skipped to avoid any ambiguity from the 0.04 -> 0.5
  transition.
This commit is contained in:
tnn 2007-08-08 11:28:04 +00:00
parent 2e3ae84d55
commit f32a62ac9e
3 changed files with 74 additions and 37 deletions

View file

@ -1,6 +1,6 @@
# $NetBSD: Makefile,v 1.12 2007/08/06 15:07:56 tnn Exp $ # $NetBSD: Makefile,v 1.13 2007/08/08 11:28:04 tnn Exp $
DISTNAME= pkg_rolling-replace-0.6 DISTNAME= pkg_rolling-replace-0.10
CATEGORIES= pkgtools CATEGORIES= pkgtools
MASTER_SITES= # empty MASTER_SITES= # empty
DISTFILES= # empty DISTFILES= # empty
@ -28,7 +28,7 @@ SUBST_CLASSES+= tools
SUBST_STAGE.tools= pre-configure SUBST_STAGE.tools= pre-configure
SUBST_MESSAGE.tools= Substituting tool locations. SUBST_MESSAGE.tools= Substituting tool locations.
SUBST_FILES.tools= pkg_rolling-replace.sh SUBST_FILES.tools= pkg_rolling-replace.sh
SUBST_VARS.tools= PKG_INFO_CMD PKG_ADMIN MAKE PKG_CHK SUBST_VARS.tools= PKG_INFO_CMD MAKE PKG_CHK
SUBST_CLASSES+= makeconf SUBST_CLASSES+= makeconf
SUBST_STAGE.makeconf= pre-configure SUBST_STAGE.makeconf= pre-configure

View file

@ -1,5 +1,5 @@
.\" $NetBSD: pkg_rolling-replace.8,v 1.6 2007/08/07 20:46:43 wiz Exp $ .\" $NetBSD: pkg_rolling-replace.8,v 1.7 2007/08/08 11:28:04 tnn Exp $
.Dd May 11, 2007 .Dd August 8, 2007
.Dt PKG_ROLLING-REPLACE 8 .Dt PKG_ROLLING-REPLACE 8
.Os .Os
.Sh NAME .Sh NAME
@ -7,17 +7,15 @@
.Nd rebuild or update packages using 'make replace' in tsorted order .Nd rebuild or update packages using 'make replace' in tsorted order
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl hnuv .Op Fl hnrsuv
.Op Fl x Ar pkgs .Op Fl x Ar pkgs
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm .Nm
runs runs
.Dq make replace .Dq make replace
on packages that have been marked with the on packages that have been marked to have unsafe dependencies or have
.Dq unsafe_depends=YES been marked to be rebuilt.
flag or the Optionally it can replace any outdated packages (as reported by
.Dq rebuild=YES
flag, optionally replacing any outdated packages (as reported by
.Xr pkg_chk 8 ) .Xr pkg_chk 8 )
as well. as well.
.Pp .Pp
@ -25,9 +23,11 @@ Whenever
.Dq make replace .Dq make replace
is run on a package, all installed packages is run on a package, all installed packages
that depend on it are marked with the that depend on it are marked with the
.Dq unsafe_depends_strict=YES
flag. If the version of the replaced package has changed, this indicates
that it may no longer be ABI-compatible so
.Dq unsafe_depends=YES .Dq unsafe_depends=YES
flag, which indicates that they may no longer be ABI-compatible is also set for all packages that depend on it.
with the replaced package.
Running Running
.Nm .Nm
with no arguments will restore such packages to a safe state by with no arguments will restore such packages to a safe state by
@ -70,6 +70,17 @@ or change any flags on installed packages.
This option attempts to calculate the new packages that would be This option attempts to calculate the new packages that would be
marked unsafe after each marked unsafe after each
.Dq make replace . .Dq make replace .
.It Fl r
Just replace packages, do not build binary packages.
.It Fl s
Enable strict mode. This makes
.Nm
Look at
.Dq unsafe_depends_strict
tags instead of
.Dq unsafe_depends
tags. This will replace packages more aggressively and can be used to solve
shared library problems.
.It Fl u .It Fl u
Use Use
.Xl pkg_chk 8 .Xl pkg_chk 8
@ -111,6 +122,9 @@ If not set in environment then defaults to
with initial idea and many suggestions from with initial idea and many suggestions from
.An Greg Troxel .An Greg Troxel
.Aq gdt@ir.bbn.com . .Aq gdt@ir.bbn.com .
The options -s and -r were added by
.An Tobias Nygren
.Aq tnn@NetBSD.org .
.Sh BUGS .Sh BUGS
.Nm .Nm
does not run fully automatically when any significant number of does not run fully automatically when any significant number of

View file

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# $NetBSD: pkg_rolling-replace.sh,v 1.12 2007/08/06 15:07:56 tnn Exp $ # $NetBSD: pkg_rolling-replace.sh,v 1.13 2007/08/08 11:28:04 tnn Exp $
#<license> #<license>
# Copyright (c) 2006 BBN Technologies Corp. All rights reserved. # Copyright (c) 2006 BBN Technologies Corp. All rights reserved.
# #
@ -71,7 +71,6 @@ test -f "$MAKECONF" && test -z "$PKGSRCDIR" && PKGSRCDIR="` \
test -z "$PKGSRCDIR" && PKGSRCDIR=/usr/pkgsrc test -z "$PKGSRCDIR" && PKGSRCDIR=/usr/pkgsrc
test -z "$PKG_CHK" && PKG_CHK="@PKG_CHK@" test -z "$PKG_CHK" && PKG_CHK="@PKG_CHK@"
test -z "$PKG_INFO" && PKG_INFO="@PKG_INFO_CMD@" test -z "$PKG_INFO" && PKG_INFO="@PKG_INFO_CMD@"
test -z "$PKG_ADMIN" && PKG_ADMIN="@PKG_ADMIN@"
unset PKG_PATH || true #or pkgsrc makefiles will complain unset PKG_PATH || true #or pkgsrc makefiles will complain
@ -80,6 +79,8 @@ usage()
echo "Usage: pkg_rolling-replace [opts] echo "Usage: pkg_rolling-replace [opts]
-h This help -h This help
-n Don't actually do make replace -n Don't actually do make replace
-r Just replace, don't create binary packages
-s Replace even if the ABIs are still compatible ("strict")
-u Update mismatched packages -u Update mismatched packages
-v Verbose -v Verbose
-x <pkg> exclude <pkg> from update check -x <pkg> exclude <pkg> from update check
@ -227,6 +228,14 @@ vsleep()
fi fi
} }
abort()
{
echo "*** $1"
echo "*** Please read the errors listed above, fix the problem,"
echo "*** then re-run pkg_rolling-replace to continue."
exit 1
}
###################################################################### ######################################################################
## ##
## main() ## main()
@ -234,7 +243,7 @@ vsleep()
EXCLUDE= EXCLUDE=
args=$(getopt hnuvx: $*) args=$(getopt hnursvx: $*)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
opt_h=1 opt_h=1
fi fi
@ -243,6 +252,8 @@ while [ $# -gt 0 ]; do
case "$1" in case "$1" in
-h) opt_h=1 ;; -h) opt_h=1 ;;
-n) opt_n=1 ;; -n) opt_n=1 ;;
-r) opt_r=1 ;;
-s) opt_s=1 ;;
-u) opt_u=1 ;; -u) opt_u=1 ;;
-v) opt_v=1 ;; -v) opt_v=1 ;;
-x) EXCLUDE="$EXCLUDE $(echo $2 | sed 's/,/ /g')" ; shift ;; -x) EXCLUDE="$EXCLUDE $(echo $2 | sed 's/,/ /g')" ; shift ;;
@ -255,6 +266,12 @@ if [ -n "$opt_h" ]; then
usage usage
fi fi
if [ -n "$opt_s" ]; then
UNSAFE_VAR=unsafe_depends_strict
else
UNSAFE_VAR=unsafe_depends
fi
MISMATCH_TODO= MISMATCH_TODO=
if [ -n "$opt_u" ]; then if [ -n "$opt_u" ]; then
echo "${OPI} Checking for mismatched installed packages using pkg_chk" echo "${OPI} Checking for mismatched installed packages using pkg_chk"
@ -267,8 +284,8 @@ fi
echo "${OPI} Checking for rebuild-requested installed packages (rebuild=YES)" echo "${OPI} Checking for rebuild-requested installed packages (rebuild=YES)"
REBUILD_TODO=$(check_packages_w_flag 'rebuild') REBUILD_TODO=$(check_packages_w_flag 'rebuild')
echo "${OPI} Checking for unsafe installed packages (unsafe_depends=YES)" echo "${OPI} Checking for unsafe installed packages (${UNSAFE_VAR}=YES)"
UNSAFE_TODO=$(check_packages_w_flag 'unsafe_depends') UNSAFE_TODO=$(check_packages_w_flag ${UNSAFE_VAR})
# DEPGRAPH_INSTALLED is rebuilt each round. DEPGRAPH_SRC will collect # DEPGRAPH_INSTALLED is rebuilt each round. DEPGRAPH_SRC will collect
# edges that we discover using 'make show-depends', but that weren't # edges that we discover using 'make show-depends', but that weren't
@ -354,25 +371,31 @@ while [ -n "$REPLACE_TODO" ]; do
# Do make replace, with clean before, and package and clean afterwards. # Do make replace, with clean before, and package and clean afterwards.
echo "${OPI} Replacing $(${PKG_INFO} -e $pkg)" echo "${OPI} Replacing $(${PKG_INFO} -e $pkg)"
FAIL= fail=
cmd="cd \"$PKGSRCDIR/$pkgdir\" \ cmd="cd \"$PKGSRCDIR/$pkgdir\" && ${MAKE} clean && ${MAKE} replace || fail=1"
&& ${MAKE} clean && ${MAKE} replace \ if [ -n "$opt_n" ]; then
&& ([ -z \"$(${PKG_INFO} -Q unsafe_depends $pkg)\" ] \ echo "${OPI} Would run: $cmd"
|| ${PKG_ADMIN} unset unsafe_depends $pkg) \
&& ([ -z \"$(${PKG_INFO} -Q rebuild $pkg)\" ] \
|| ${PKG_ADMIN} unset rebuild $pkg) \
&& ${MAKE} package && ${MAKE} clean \
|| FAIL=1"
if [ -z "$opt_n" ]; then
eval "$cmd"
else else
echo "$cmd" eval "$cmd"
[ -z "$fail" ] || abort "'make replace' failed for package $pkg."
fi fi
if [ -n "$FAIL" ]; then if [ -z "$opt_n" ]; then
echo "*** 'make replace' failed for package $pkg." [ -z "$(${PKG_INFO} -Q unsafe_depends_strict $pkg)" ] || \
echo "*** Please read the errors listed above, fix the problem," abort "package $pkg still has unsafe_depends_strict."
echo "*** then re-run pkg_rolling-replace to continue." [ -z "$(${PKG_INFO} -Q unsafe_depends $pkg)" ] || \
exit 1 abort "package $pkg still has unsafe_depends."
[ -z "$(${PKG_INFO} -Q rebuild $pkg)" ] || \
abort "package $pkg is still requested to be rebuilt."
fi
if [ -z "$opt_r" ]; then
echo "${OPI} Packaging $(${PKG_INFO} -e $pkg)"
cmd="${MAKE} package && ${MAKE} clean || fail=1"
if [ -n "$opt_n" ]; then
echo "${OPI} Would run: $cmd"
else
eval "$cmd"
[ -z "$fail" ] || abort "'make package' failed for package $pkg."
fi
fi fi
sleep 1 sleep 1
@ -381,7 +404,7 @@ while [ -n "$REPLACE_TODO" ]; do
REBUILD_TODO=$(exclude $pkg --from $REBUILD_TODO) REBUILD_TODO=$(exclude $pkg --from $REBUILD_TODO)
UNSAFE_TODO=$(exclude $pkg --from $UNSAFE_TODO) UNSAFE_TODO=$(exclude $pkg --from $UNSAFE_TODO)
echo "${OPI} Re-checking for unsafe installed packages (unsafe_depends=YES)" echo "${OPI} Re-checking for unsafe installed packages (${UNSAFE_VAR}=YES)"
if [ -n "$opt_n" ]; then if [ -n "$opt_n" ]; then
# With -n, the replace didn't happen, and thus the packages that would # With -n, the replace didn't happen, and thus the packages that would
# have been marked unsafe_depends=YES were not. Add the set that # have been marked unsafe_depends=YES were not. Add the set that
@ -391,7 +414,7 @@ while [ -n "$REPLACE_TODO" ]; do
$(who_requires $pkg --in-graph $DEPGRAPH_INSTALLED)) $(who_requires $pkg --in-graph $DEPGRAPH_INSTALLED))
sleep 1 sleep 1
else else
UNSAFE_TODO=$(check_packages_w_flag 'unsafe_depends') UNSAFE_TODO=$(check_packages_w_flag ${UNSAFE_VAR})
fi fi
verbose "${OPI} Packages to rebuild:" verbose "${OPI} Packages to rebuild:"