pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkg_rolling-replace pkg_rolling-replace does ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/063a3c16e9d8
branches:  trunk
changeset: 522203:063a3c16e9d8
user:      gdt <gdt%pkgsrc.org@localhost>
date:      Tue Dec 05 18:23:52 2006 +0000

description:
pkg_rolling-replace does 'make replace' on one package at a time,
tsorting the packages being replaced according to their
interdependencies, which avoids most duplicate rebuilds.

diffstat:

 pkgtools/pkg_rolling-replace/DESCR                        |    3 +
 pkgtools/pkg_rolling-replace/Makefile                     |   53 +
 pkgtools/pkg_rolling-replace/PLIST                        |    3 +
 pkgtools/pkg_rolling-replace/files/pkg_rolling-replace.8  |   91 +++
 pkgtools/pkg_rolling-replace/files/pkg_rolling-replace.sh |  402 ++++++++++++++
 5 files changed, 552 insertions(+), 0 deletions(-)

diffs (truncated from 572 to 300 lines):

diff -r 9f5b9dc5acaa -r 063a3c16e9d8 pkgtools/pkg_rolling-replace/DESCR
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkg_rolling-replace/DESCR        Tue Dec 05 18:23:52 2006 +0000
@@ -0,0 +1,3 @@
+pkg_rolling-replace does 'make replace' on one package at a time,
+tsorting the packages being replaced according to their
+interdependencies, which avoids most duplicate rebuilds.
diff -r 9f5b9dc5acaa -r 063a3c16e9d8 pkgtools/pkg_rolling-replace/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkg_rolling-replace/Makefile     Tue Dec 05 18:23:52 2006 +0000
@@ -0,0 +1,53 @@
+# $NetBSD: Makefile,v 1.1.1.1 2006/12/05 18:23:52 gdt Exp $
+
+DISTNAME=      pkg_rolling-replace-0.04
+PKGREVISION=   2
+CATEGORIES=    pkgtools
+MASTER_SITES=  # empty
+DISTFILES=     # empty
+
+MAINTAINER=    ngoffee%bbn.com@localhost
+COMMENT=       Replace/upgrade packages in-place
+
+DEPENDS+=      pkg_chk>=1.76:../../pkgtools/pkg_chk
+DEPENDS+=      pkg_tarup>=1.6.6:../../pkgtools/pkg_tarup
+
+PKG_INSTALLATION_TYPES= overwrite pkgviews
+
+USE_TOOLS+=    patch
+
+WRKSRC=                ${WRKDIR}
+NO_CHECKSUM=   yes
+NO_BUILD=      yes
+USE_LANGUAGES= # none
+
+INSTALLATION_DIRS=     sbin man/man8
+
+.include "../../mk/bsd.prefs.mk"
+
+# target exists only to force check-pkgsrc-patch prior to install
+do-extract: check-pkgsrc-patch
+       cp ${FILESDIR}/pkg_rolling-replace.sh ${WRKSRC}
+
+do-install: check-pkgsrc-patch
+       ${INSTALL_SCRIPT} ${WRKSRC}/pkg_rolling-replace.sh ${PREFIX}/sbin/pkg_rolling-replace
+       ${INSTALL_SCRIPT} ${FILESDIR}/pkg_rolling-replace.8 ${PREFIX}/${PKGMANDIR}/man8/pkg_rolling-replace.8
+
+check-pkgsrc-patch:
+       @${ECHO_N} "=> Checking for unsafe_depends support in pkgsrc..."; \
+       REPLACE_MK="${PKGSRCDIR}/mk/flavor/pkg/replace.mk"; \
+       if [ -f "$$REPLACE_MK" ]; then \
+           if [ "`${EGREP} unsafe_depends=YES $$REPLACE_MK`" ]; then \
+               ${ECHO} "found."; \
+               ${TRUE}; \
+           else \
+               ${ECHO}; \
+               ${ECHO} "*** pkg_rolling replace requires pkgsrc>=2006Q3" \
+               ${FALSE}; \
+            fi; \
+       else \
+            ${ECHO} "*** pkg_rolling replace requires pkgsrc>=2006Q3"; \
+            ${FALSE}; \
+        fi
+
+.include "../../mk/bsd.pkg.mk"
diff -r 9f5b9dc5acaa -r 063a3c16e9d8 pkgtools/pkg_rolling-replace/PLIST
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkg_rolling-replace/PLIST        Tue Dec 05 18:23:52 2006 +0000
@@ -0,0 +1,3 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2006/12/05 18:23:52 gdt Exp $
+sbin/pkg_rolling-replace
+man/man8/pkg_rolling-replace.8
diff -r 9f5b9dc5acaa -r 063a3c16e9d8 pkgtools/pkg_rolling-replace/files/pkg_rolling-replace.8
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkg_rolling-replace/files/pkg_rolling-replace.8  Tue Dec 05 18:23:52 2006 +0000
@@ -0,0 +1,91 @@
+.\" $NetBSD: pkg_rolling-replace.8,v 1.1.1.1 2006/12/05 18:23:52 gdt Exp $
+.Dd August 7, 2006
+.Dt PKG_ROLLING-REPLACE 8
+.Sh NAME
+.Nm pkg_rolling-replace
+.Nd rebuild or update packages using 'make replace' in tsorted order
+.Sh SYNOPSIS
+.Nm
+.Op Fl hnuvx
+.Op Fl x Ar pkgs
+.Sh DESCRIPTION
+.Nm
+runs 'make replace' on packages that have been marked with the
+ 'unsafe_depends=YES' flag or the 'rebuild=YES' flag, optionally
+replacing any outdated packages (as reported by
+.Xr pkg_chk 8 )
+as well.
+.Pp
+Whenever 'make replace' is run on a package, all installed packages
+that depend on it are marked with the 'unsafe_depends=YES' flag, which
+indicates that they may no longer be ABI-compatible with the replaced
+package.  Running
+.Nm
+with no arguments will restore such packages to a safe state by
+building a dependency graph, running
+.Xr tsort 1
+on it, and running 'make replace' in the resulting topological order.
+The dependency graph and topological sort are re-calculated after each
+'make replace', in case it causes additional
+packages to be marked unsafe.
+.Pp
+The user can mark additional packages to be rebuilt by setting the
+ 'rebuild=YES' flag on them using the command 
+.Dl % pkg_admin set rebuild=YES <pkg>
+.Pp
+If the
+.Fl u
+option is given,
+.Nm
+will use
+.Xl pkg_chk 8
+to check for packages for which the version in pkgsrc is different
+than the installed version, and run 'make replace' on those packages
+as well (tsorting them along with the unsafe/rebuild packages).
+(Usually this results in packages being upgraded to newer versions,
+assuming the pkgsrc tree is more recent than the currently installed
+packages.)
+.Pp
+.Ss Options
+.Bl -tag -width xxxxxxxx
+.It Fl h
+Brief help.
+.It Fl n
+Display actions that would be taken, but don't actually run 'make
+replace' or change any flags on installed packages.  This option
+attempts to calculate the new packages that would be marked unsafe
+after each 'make replace'.
+.It Fl u
+Use
+.Xl pkg_chk 8
+to check for outdated packages, and replace those too.
+.It Fl v
+Verbose output.
+.It Fl x Ar pkgs
+Exclude the comma-separated list of packages from the update check
+when
+.Fl u
+is given (does not exclude unsafe or rebuild-requested packages).
+.El
+.Sh ENVIRONMENT
+.Nm
+uses the following environment variables.
+.Bl -tag -width xxxx
+.It Ev PKGSRCDIR
+Base of pkgsrc tree.  Defaults to
+.Pa /usr/pkgsrc
+.It Ev PKG_DBDIR
+pkgsrc database directory.
+If not set in environment then defaults to
+.Pa /var/db/pkg
+.El
+.Sh AUTHORS
+.An Nick Goffee
+.Aq ngoffee%bbn.com@localhost ,
+with initial idea and many suggestions from
+.An Greg Troxel
+.Aq gdt%ir.bbn.com@localhost .
+.Sh BUGS
+.Nm
+does not run fully automatically when any significant number of
+packages need to be replaced.
diff -r 9f5b9dc5acaa -r 063a3c16e9d8 pkgtools/pkg_rolling-replace/files/pkg_rolling-replace.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkg_rolling-replace/files/pkg_rolling-replace.sh Tue Dec 05 18:23:52 2006 +0000
@@ -0,0 +1,402 @@
+#!/bin/sh
+
+# $NetBSD: pkg_rolling-replace.sh,v 1.1.1.1 2006/12/05 18:23:52 gdt Exp $
+#<license>
+# Copyright (c) 2006 BBN Technologies Corp.  All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of BBN Technologies nor the names of its contributors
+#    may be used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY BBN TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL BBN TECHNOLOGIES OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# Effort sponsored in part by the Defense Advanced Research Projects
+# Agency (DARPA) and the Department of the Interior National Business
+# Center under agreement number NBCHC050166.
+#</license>
+
+# REVIEW NOTATION LEGEND
+#   XXX marks things that are broken/kludgy
+#   TODO marks things that need to be done
+#   FIXED marks items fixed, needs review and deletion of FIXED comment
+
+# Items to be completed for initial release:
+
+# TODO: move bulk of help into a real man page.
+
+# Items for future work (some imply changes in pkgsrc, not necessarily here)
+#
+#   Make a pass over all packages for build depends, and rememeber
+# which packages have been so checked.  Check newly unsafe packages.
+# The current lazy evaluation can perhaps fail to do things in the
+# right order.  Alternatively, explain why the current scheme is safe
+# and preferred.
+#
+#   Consider expansion to update via binary packages.  This raises
+# interesting questions about ABIs and binary builds
+#
+#   Deal with conflicts in a smarter way, perhaps more automatically.
+# This is hard because just removing packages is not ok.
+#
+#   Handle foo being split into foo and foo-share.  Now, make replace
+# of foo pulls in foo-share which conflicts with foo.  This needlessly
+# loses.
+#
+#   Parse mk.conf for PKGSRCDIR, etc.
+
+test -n "$PKG_DBDIR" || PKG_DBDIR=/var/db/pkg
+test -n "$PKGSRCDIR" || PKGSRCDIR=/usr/pkgsrc
+
+unset PKG_PATH || true  #or pkgsrc makefiles will complain
+
+MAKE=make
+# XXX Find BSD make at package build time.
+UNAME=`uname`
+case "$UNAME" in
+    Darwin)
+    MAKE=bmake
+    ;;
+esac
+
+usage()
+{
+    echo "Usage: pkg_rolling-replace [opts]
+        -h         This help
+        -n         Don't actually do make replace
+        -u         Update mismatched packages
+        -v         Verbose
+        -x <pkg>   exclude <pkg> from update check
+
+pkg_rolling-replace does 'make replace' on one package at a time,
+tsorting the packages being replaced according to their
+interdependencies, which avoids most duplicate rebuilds.
+
+pkg_rolling-replace can be used in one of two ways:
+
+    - 'make replace' is unsafe in that, if the replaced package's ABI
+      changes, its dependent packages may break.  If this happens, run
+      'pkg_rolling-replace' (no arguments) to rebuild them against the
+      new version.
+
+    - 'pkg_chk -u' will delete all your mismatched (outdated)
+      packages, then reinstall them one at a time, leaving you without
+      those packages in the meantime.  'pkg_rolling-replace -u' will
+      instead upgrade them in place, allowing you to keep using your
+      system in the meantime (maybe...if you're lucky...because
+      pkg_rolling-replace replaces the \"deepest\" dependency first,
+      things could still break if that happens to be a fundamental
+      library whose ABI has changed).
+"
+    exit 1
+}
+
+# pkg_rolling-replace's output is intermingled with pkgsrc make
+# output.  Thus, we use a different prefix.  pkgsrc uses '===>' for
+# major steps, and '=>' for minor ones.  Thus, we use 'RR>'.
+
+OPI='RR>'
+OPC='rr>' # continuation
+
+
+# Echo the names of packages needing updates, versions stripped.  This
+# has been tested with pkg_chk 1.76.  Older versions are not
+# supported.  Newer versions may or may not work (patches welcome).
+check_packages_mismatched()
+{
+    pkg_chk -u -q | while read line; do
+        # duplicate output of pkg_chk to stderr (bypass $(...) or `...`)
+        echo "${OPC} $line" > /dev/stderr
+       # Look for the first thing that looks like pkg-version rather
+       # than category/pkg and remove the version.
+        for word in $line; do
+            if [ "$(echo $word | egrep '^[^/]+-[0-9][^/]*$')" ]; then



Home | Main Index | Thread Index | Old Index