summaryrefslogtreecommitdiff
path: root/pkgtools/pkgchk
diff options
context:
space:
mode:
authorabs <abs@pkgsrc.org>2001-07-07 12:17:35 +0000
committerabs <abs@pkgsrc.org>2001-07-07 12:17:35 +0000
commit29bd1451e48a4d1d40637c107716c2d2324b15e8 (patch)
tree76a24456dee0f55072c0312f87341d58958cfb29 /pkgtools/pkgchk
parente65cfeac26baa8b8f50f15d8d06b1f13ada438b0 (diff)
downloadpkgsrc-29bd1451e48a4d1d40637c107716c2d2324b15e8.tar.gz
Updated pkgchk to 1.03
- Move update/installs after check phase, and perform all updates before installs. - When updating packages that depend on each other, skip dependent packages to reduce unnecessary rebuilding. - Implement -n (display actions but do not perform them)
Diffstat (limited to 'pkgtools/pkgchk')
-rw-r--r--pkgtools/pkgchk/Makefile4
-rw-r--r--pkgtools/pkgchk/files/pkgchk.837
-rwxr-xr-xpkgtools/pkgchk/files/pkgchk.sh95
3 files changed, 117 insertions, 19 deletions
diff --git a/pkgtools/pkgchk/Makefile b/pkgtools/pkgchk/Makefile
index 710e0622241..593e02a47cd 100644
--- a/pkgtools/pkgchk/Makefile
+++ b/pkgtools/pkgchk/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.3 2001/07/05 21:00:54 abs Exp $
+# $NetBSD: Makefile,v 1.4 2001/07/07 12:17:35 abs Exp $
#
-DISTNAME= pkgchk-1.02
+DISTNAME= pkgchk-1.03
CATEGORIES= pkgtools
MASTER_SITES= # empty
DISTFILES= # empty
diff --git a/pkgtools/pkgchk/files/pkgchk.8 b/pkgtools/pkgchk/files/pkgchk.8
index abb207b34eb..46089c0aa1e 100644
--- a/pkgtools/pkgchk/files/pkgchk.8
+++ b/pkgtools/pkgchk/files/pkgchk.8
@@ -1,4 +1,4 @@
-.\" $NetBSD: pkgchk.8,v 1.2 2001/07/05 21:00:54 abs Exp $
+.\" $NetBSD: pkgchk.8,v 1.3 2001/07/07 12:17:35 abs Exp $
.\"
.\" Copyright (c) 2001 by David Brownlee (abs@netbsd.org)
.\" Absolutely no warranty.
@@ -10,7 +10,7 @@
.Nd check, and optionally update, installed packages
.Sh SYNOPSIS
.Nm
-.Op Fl abhisv
+.Op Fl abhinsv
.Op Fl D Ar tags
.Op Fl U Ar tags
.Sh DESCRIPTION
@@ -21,6 +21,10 @@ pkgsrc, optionally adding missing or updating mismatched packages.
It can verify all installed packages, or check against a set of packages
based on the hostname, architecture, and other characteristics.
.Pp
+When updating packages that depend on each other
+.Nm
+will skip dependent packages to reduce unnecessary rebuilding.
+.Pp
.Sy Options
.Bl -tag -width xxxxxxxx
.It Fl D Ar tags
@@ -50,6 +54,8 @@ will automatically generate binary packages for later reuse.
Brief help.
.It Fl i
Check versions of installed packages, ignoring pkgchk.conf.
+.It Fl n
+Display actions that would be taken, but do not change anything.
.It Fl s
Limit additions or updates to building from source.
.It Fl u
@@ -132,3 +138,30 @@ David Brownlee <abs@netbsd.org>
.Sh CAVEATS
Updating packages on which other packages depend can currently only be done
via source (not binary packages).
+.Pp
+If both package
+.Em a
+and package
+.Em b
+are to be updated, and
+.Em a
+depends on
+.Em b ,
+.Nm
+will correctly skip the update of
+.Em a .
+However, if
+.Em a
+depends on
+.Em b
+and
+.Em c ,
+and all three are marked for update,
+.Nm
+will update
+.Em b
+and
+.Em c
+in two separate passes, resulting in unnecessary rebuilding of
+.Em a
+(and potentially other packages).
diff --git a/pkgtools/pkgchk/files/pkgchk.sh b/pkgtools/pkgchk/files/pkgchk.sh
index 38889295884..c3931e20f73 100755
--- a/pkgtools/pkgchk/files/pkgchk.sh
+++ b/pkgtools/pkgchk/files/pkgchk.sh
@@ -1,8 +1,10 @@
#!/bin/sh -e
#
-# $Id: pkgchk.sh,v 1.3 2001/07/05 21:00:54 abs Exp $
+# $Id: pkgchk.sh,v 1.4 2001/07/07 12:17:35 abs Exp $
#
# TODO: Handle and as well as or tags (eg: i386+x11)
+# TODO: Order updates based on DEPENDENCIES.
+# TODO: Handle updates with dependencies via binary packages
extract_variables()
{
@@ -45,22 +47,30 @@ pkg_install()
INSTALL=$3
if [ -n "$opt_b" -a -f $PACKAGES/All/$PKGNAME.tgz ] ; then
if [ $INSTALL = U ];then
- if pkg_delete $PKGNAME ; then
- echo "Deleted $PKGNAME"
- else
- echo "Can only update packages with dependencies via -s"
+ echo "pkg_delete $PKGNAME"
+ if [ -z "$opt_n" ];then
+ if pkg_delete $PKGNAME ; then
+ echo "Deleted $PKGNAME"
+ else
+ echo "Can only update packages with dependencies via -s"
+ exit 1
+ fi
fi
fi
- echo "Installing binary package $PKGNAME.tgz"
- pkg_add $PACKAGES/All/$PKGNAME.tgz
+ echo "pkg_add $PKGNAME.tgz"
+ if [ -z "$opt_n" ];then
+ pkg_add $PACKAGES/All/$PKGNAME.tgz
+ fi
elif [ -n "$opt_s" ]; then
- echo "Building $PKGNAME"
+ echo "make update for $PKGNAME"
cd $PKGSRCDIR/$PKGDIR
- make update
+ if [ -z "$opt_n" ];then
+ make update
+ fi
fi
}
-args=`getopt D:IU:abchisuv $*`
+args=`getopt D:IU:abchinsuv $*`
if [ $? != 0 ]; then
opt_h=1
fi
@@ -74,6 +84,7 @@ while [ $# != 0 ]; do
-c ) opt_c=1 ;;
-h ) opt_h=1 ;;
-i ) opt_i=1 ;;
+ -n ) opt_n=1 ;;
-s ) opt_s=1 ;;
-u ) opt_u=1 ;;
-v ) opt_v=1 ;;
@@ -101,6 +112,7 @@ if [ -n "$opt_h" -o $# != 1 ];then
-c Check installed packages against pkgchk.conf
-h This help
-i Check versions of installed packages (ignore pkgchk.conf)
+ -n Display actions that would be taken, but do not perform them
-s Limit installations to building from source
-u Update all mismatched packages
-v Verbose
@@ -199,22 +211,75 @@ for pkgdir in $PKGDIRLIST ; do
if [ -n "$pkginstalled" ];then
echo -n "version mismatch - $pkginstalled"
if [ -n "$opt_u" ]; then
- INSTALL=U
+ DO_UPDATE="$DO_UPDATE $pkgname $pkgdir"
fi
else
echo -n "missing"
if [ -n "$opt_a" ] ; then
- INSTALL=I
+ DO_INSTALL="$DO_INSTALL $pkgname $pkgdir"
fi
fi
if [ -f $PACKAGES/All/$pkgname.tgz ] ;then
echo -n " (binary package available)"
fi
echo
- if [ -n "$INSTALL" ];then
- pkg_install $pkgname $pkgdir $INSTALL
- fi
elif [ -n "$opt_v" ];then
echo "$pkgname: OK"
fi
done
+
+if [ -n "$DO_UPDATE" ];then
+ echo "Updating..."
+
+ # Generate list including packages which depend on updates
+ #
+ set -- $DO_UPDATE
+ while [ $# != 0 ]; do
+ PKGNAME=`echo $1 | sed 's/-[0-9].*//'`
+ if [ -f /var/db/pkg/$PKGNAME-[0-9]*/+REQUIRED_BY ];then
+ LIST="$LIST$1|$2|`cat /var/db/pkg/$PKGNAME-[0-9]*/+REQUIRED_BY`\n"
+ else
+ LIST="$LIST$1|$2\n"
+ fi
+ shift ; shift;
+ done
+
+ # drop any packages whose 'parents' are also to be updated
+ #
+ DO_UPDATE=`printf "$LIST" | awk -F '|' '
+ {
+ pkg2dir[$1] = $2
+ split($3, deplist, " ")
+ for (pkg in deplist)
+ {
+ dep = deplist[pkg]
+ sub("-[0-9].*", "", dep) # Strip version
+ covered[dep] = 1
+ }
+ }
+ END {
+ for (pkg in pkg2dir)
+ {
+ chk = pkg
+ sub("-[0-9].*", "", chk); # Strip version
+ if (!covered[chk])
+ print pkg" "pkg2dir[pkg]
+ }
+ }
+ '`
+
+ set -- $DO_UPDATE
+ while [ $# != 0 ]; do
+ pkg_install $1 $2 U
+ shift ; shift;
+ done
+fi
+
+if [ -n "$DO_INSTALL" ];then
+ echo "Installing..."
+ set -- $DO_INSTALL
+ while [ $# != 0 ]; do
+ pkg_install $1 $2 I
+ shift ; shift;
+ done
+fi