From owner-freebsd-hackers@FreeBSD.ORG Fri Apr 4 05:22:49 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7496437B405 for ; Fri, 4 Apr 2003 05:22:49 -0800 (PST) Received: from gandalf.online.bg (gandalf.online.bg [217.75.128.9]) by mx1.FreeBSD.org (Postfix) with SMTP id D4A0443F75 for ; Fri, 4 Apr 2003 05:22:47 -0800 (PST) (envelope-from roam@ringlet.net) Received: (qmail 15421 invoked from network); 4 Apr 2003 13:17:45 -0000 Received: from office.sbnd.net (HELO straylight.ringlet.net) (217.75.140.130) by gandalf.online.bg with SMTP; 4 Apr 2003 13:17:44 -0000 Received: (qmail 27241 invoked by uid 1000); 4 Apr 2003 13:20:54 -0000 Date: Fri, 4 Apr 2003 16:20:54 +0300 From: Peter Pentchev To: Danny Braniss Message-ID: <20030404132054.GG7008@straylight.oblivion.bg> Mail-Followup-To: Danny Braniss , Kris Kennaway , hackers@freebsd.org References: <20030403223006.GD15705@rot13.obsecurity.org> <20030404131419.GF7008@straylight.oblivion.bg> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="RDS4xtyBfx+7DiaI" Content-Disposition: inline In-Reply-To: <20030404131419.GF7008@straylight.oblivion.bg> User-Agent: Mutt/1.5.4i cc: hackers@freebsd.org cc: Kris Kennaway Subject: Re: ports and /var/db/pkg X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Apr 2003 13:22:50 -0000 --RDS4xtyBfx+7DiaI Content-Type: text/plain; charset=windows-1251 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 04, 2003 at 04:14:19PM +0300, Peter Pentchev wrote: > On Fri, Apr 04, 2003 at 02:11:58PM +0300, Danny Braniss wrote: > >=20 > > > > ok, so i wrote a small script (tcl, since i don't know perl), that > > > > does some checking, it reports for each package, the number of files > > > > how many are realy there, and if so, checks the MD5. > > > > > > > > now, if im not to far off, if some/all files are missing, or if the > > > > md5 does not match, i should be able to remove the package info, ... > > >=20 > > > Well, that's not what you were asking for originally, and tools > > > already exist to check that. > >=20 > > OK, let me refrase it > >=20 > > PROBLEM: > > how to update /var/db/pkg, when it knows too much, > > i.e. /usr/local has less stuff that /var/db/pkg knows about. > > =09 > > >=20 > > > e.g. pkg_info -g and the example from the pkg_which(1) manpage that I > > > mentioned to you in a previous email. > >=20 > > i read most of the pkg*, and though im very impressed, i fail to find a > > clear/easy way to get a one line output saying: > > pkg xyz no longer exits, can be removed from database >=20 > If you are only interested in packages which no longer have *any* files > on the filesystem, then compare the output of the following two > commands: >=20 > pkg_info -qL package | wc -l > pkg_info -qg package | wc -l >=20 > If the output of those two commands is the same, then there are no valid > package files left at all, and a pkg_delete -f is in order. >=20 > Moreover, if you are only interested in the existence of the files, it > would be easier to do something like: >=20 > remove=3D1 > pkg_info -qL package | while read fname; do > [ -f "$fname" ] && remove=3D0 > done > if [ $remove =3D=3D "1" ]; then pkg_delete package; fi Just one more comment: the reason I stick to pkg_delete -f instead of rm -rf /var/db/pkg/package is that the /var/db/pkg scheme is not really set in stone: the correct way to manipulate the package database is *only* via the pkg_* tools. Well, there is something to be said about the tools available in ports/sysutils/portupgrade, but then, they are actively maintained by knu, who will most probably track any changes in the base system handling of packages, if and when those should occur. G'luck, Peter --=20 Peter Pentchev roam@ringlet.net roam@sbnd.net roam@FreeBSD.org PGP key: http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553 Hey, out there - is it *you* reading me, or is it someone else? --RDS4xtyBfx+7DiaI Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQE+jYa27Ri2jRYZRVMRAsbWAKCJseyYdZYkOdehhIcmihg1SdYChgCgi5nb GINrqzrGxnXIcbvAUunosWA= =sfzA -----END PGP SIGNATURE----- --RDS4xtyBfx+7DiaI--