Subject: Re: Smarter make update / pkg_chk algo
To: Greg Troxel <gdt@ir.bbn.com>
From: David Brownlee <abs@NetBSD.org>
List: tech-pkg
Date: 05/25/2005 22:24:06
On Wed, 25 May 2005, Greg Troxel wrote:

>  > 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
> option.

 	I tend to use pkg_chk with -B, so an updated dependency would
 	be cause for a package to also be updated even if its version
 	was unchanged, but pkg_add -u would not update in this case.

 	Hmm - if you did not mind the order in which it ran you could
 	just run 'pkg_chk -l | xargs pkg_add -u' and rely on pkg_add
 	to skip those that did not need updating. In fact, with your
 	change to prepend dependencies to the list that should just
 	about cover the order (though ideally a tsort would get it
 	completely right)

>  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
> tree.)

 	I use the output of 'pkg_chk -l' directly as a list of files to
 	copy to a remote machine, so the pkg_dir in there would clutter
 	it for me. Would you be happy with an option to display the
 	pkgdir instead of the pkgname, or would you want both?

 	The prepend to $checklist will definitely be in the next version
 	:)

 	thanks

> 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/pkg_chk.sh
> ===================================================================
> rcs file: /netbsd-cvs/pkgsrc/pkgtools/pkg_chk/files/pkg_chk.sh,v
> retrieving revision 1.14
> diff -u -r1.14 pkg_chk.sh
> --- files/pkg_chk.sh	20 apr 2005 15:32:25 -0000	1.14
> +++ files/pkg_chk.sh	25 may 2005 18:53:25 -0000
> @@ -24,6 +24,7 @@
> 	    continue
> 	fi
> 	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 ";
>     done
>     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
>
>
>
>

-- 
 		David/absolute       -- www.NetBSD.org: No hype required --