Subject: Re: Smarter make update / pkg_chk algo
To: David Brownlee <>
From: Greg Troxel <>
List: tech-pkg
Date: 05/25/2005 15:09:01
  > pkgA pkgB and firefox would all be in the 'need (possibly recursive)
  > removal', and hence in the tsort, and then one would
  >  pkg_add -u pkgA-new
  >  pkg_add -u pkgB-new
  >  pkg_add -u firefox-new
  > so if A or B changed shlib versions or other interfaces, firefox would
  > be broken for a bit, but if not the window would be small.

  This implies in-place updates without first removing packages
  that depend on each package? That is not something pkg_chk
  has ever done, so I'd need to think more about it.

Yes, it does imply that.  I see your point about crossing the 'make
replace/pkg_add -u' line, but I think it's nice to give people that

  That is quite similar to my usage here - except that to update
  a machine I run 'pkg_chk -l' on the build box to determine the
  list of packages, push them to the destination host and then
  install them there (this is assuming the build host always
  builds everything)

That's what I'm actually doing, since I started using pkg_chk before
it worked without a tree.  I have been using a local patch to make -l
output the dependencies first, so I can use a script to remove
mismatches and then add. (I've posted my script before, but there's no
reason for anyone to use it now that pkg_chk works without a pkgsrc

The patch (first chunk) also adds a column with the package directory
to the normal output.  When not using bulk builds, I do 'pkg_chk -i'
and then use shell functions to update individual packages:

# do a full make replace cycle on a number of packages
function pkgreplace () { (if [ "$1" = "" ]; then echo "usage eg pkgreplace editors/emacs"; \
else cd /usr/pkgsrc && \
(for i in $*; do (cd $i && make replace package clean); done); fi); }
function pkgreplacecat () { pkgreplace `egrep $1 PKG | awk '{print $1}'`; }

index: files/
rcs file: /netbsd-cvs/pkgsrc/pkgtools/pkg_chk/files/,v
retrieving revision 1.14
diff -u -r1.14
--- files/	20 apr 2005 15:32:25 -0000	1.14
+++ files/	25 may 2005 18:53:25 -0000
@@ -24,6 +24,7 @@
 	if [ ! -d $pkg_dbdir/$pkgname ];then
+	    msg_n "$pkgdir "
 	    msg_n "$pkgname: "
 	    pkg=$(echo $pkgname | ${sed} 's/-[0-9].*//')
 	    pkginstalled=$(sh -c "${pkg_info} -e $pkg" || true)
@@ -208,7 +209,8 @@
 	checklist="$checklist$pkgname ";
     while [ "$checklist" != ' ' ]; do
-	pkglist="$pkglist$checklist"
+	# prepend checklist, so original packages are at end
+	pkglist="$checklist$pkglist"
 	nextcheck=' '
 	for pkg in $checklist ; do
 	    if [ ! -f $packages/$pkg.tgz ] ; then