Subject: Re: pkg_chk doesn't work due too a fmt(1) bug (was: CVS commit:
To: None <tech-pkg@NetBSD.org>
From: Hisashi T Fujinaka <htodd@twofifty.com>
List: tech-pkg
Date: 01/04/2006 06:50:01
On Tue, 3 Jan 2006, Bernd Ernesti wrote:

> On Thu, Dec 15, 2005 at 09:32:00PM +0000, Christos Zoulas wrote:
>>
>> Module Name:	src
>> Committed By:	christos
>> Date:		Thu Dec 15 21:32:00 UTC 2005
>>
>> Modified Files:
>> 	src/usr.bin/fmt: fmt.c
>> Added Files:
>> 	src/usr.bin/fmt: buffer.h
>>
>> Log Message:
>> PR/32305: seebs: Eliminate buffer overflows and simplify code by using
>> dynamically allocated buffers.
>
> I had strange problems with the latest fmt(1) and notice that there were
> some changes lately. So I did go back to rev 1.18 of fmt.c and my problems
> were gone.
>
> 'pkg_chk -a' fails to merge the old pkgchk_update-HOSTNAME.conf file, while
> comparing the currently installed packages with the old ones.
> The resultin pkgchk_update-HOSTNAME.conf file is only 3 bytes long and
> contains 'a ' + RETURN.
>
> I have over 400 packages installed and the pkgchk_update-HOSTNAME.conf file
> is 8556 bytes long, where the size of that file doesn't matter. It is the output
> from $(pkgdirs_from_installed) which causes fmt to fail in such a way.
>
> It comes down to the following lines (line 710 and following of pkg_chk.sh,v 1.21):
>
> tmp=$(cat $PKGCHK_UPDATE_CONF;echo $(pkgdirs_from_installed)|fmt -1)
> echo $tmp | fmt -1 | ${SORT} -u > $PKGCHK_UPDATE_CONF
>
> where pkgdirs_from_installed is the following function to get all the pathnames
> of the installed packages, relative to PKGSRCDIR.
>
> pkgdirs_from_installed()
>    {
>    ${PKG_INFO} -Bqa | ${AWK} -F= '/PKGPATH=/{print $2}' | ${SORT}
>    }
>
> I reduced the old pkgchk_update-HOSTNAME.conf file so it contains just one
> line (package), but still got the wrong updated file. $tmp was allready corrupt
> at this point. Removing the pkgdirs_from_installed part 'fixed' $tmp, but then
> the whole function would not do what it should do.

Is anyone looking at this? pkg_chk -u is broken for me as well.

-- 
Hisashi T Fujinaka - htodd@twofifty.com
BSEE(6/86) + BSChem(3/95) + BAEnglish(8/95) + MSCS(8/03) + $2.50 = latte