From owner-freebsd-ports Fri Jun 18 11:21:51 1999 Delivered-To: freebsd-ports@freebsd.org Received: from ns.raditex.se (www.raditex.se [192.5.36.20]) by hub.freebsd.org (Postfix) with ESMTP id 3456614D1E for ; Fri, 18 Jun 1999 11:21:41 -0700 (PDT) (envelope-from kaj@raditex.se) Received: from localhost (gandalf.raditex.se [192.5.36.18]) by ns.raditex.se (8.8.8/8.8.8) with ESMTP id UAA17168; Fri, 18 Jun 1999 20:21:39 +0200 (CEST) (envelope-from kaj@raditex.se) To: ports@FreeBSD.org Cc: Rasmus Kaj Subject: Checking the checksums for an installed port From: Rasmus Kaj X-Mailer: Mew version 1.93 on XEmacs 20.4 (Emerald) X-URL: http://www.e.kth.se/~kaj/ X-Phone: +46 (0)8 - 694 92 80 X-Attribution: Kaj X-Face: M9cR~WYav<"fu%MaslX0`43PAYY?uIsM8[#E(0\Xuy9rj>4gE\h3jm.7DD?]R8*^7T\o&vT U@[53Dwkuup4[0@gw#~kyu>`unH?kVj9CJa02(h>Ki\+i=%rn%sDf^KC.!?IHkKjMAbkd\jgmphp^' d|Q;OeXEAhq?ybGqOs1CHb6TJT42'C`Krnk61//AOfXtNjj/t'`5>Vw0QX!dKfOL$.f+S"LIuwR<;I Z0Qnnx(F^F]o@*V%TUtEV'1Z[TkOl^FFV9Z~A[b19%}uP*,huCU Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Fri_Jun_18_20:21:25_1999_294)--" Content-Transfer-Encoding: 7bit Message-Id: <19990618202139I.kaj@raditex.se> Date: Fri, 18 Jun 1999 20:21:39 +0200 X-Dispatcher: imput version 980905(IM100) Lines: 89 Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org ----Next_Part(Fri_Jun_18_20:21:25_1999_294)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hello port wizards! Since I needed to find the file I had manually edited on a machine (to copy it to another host) I figured a good way would be to check the installed files for the three of four ports I suspected contained the edited file against their checksums. Neither pkg_add(1), pkg_delete(1), nor pkg_info(1) mentions the checksums for all individual files which is included in the package database (in +CONTENTS). So I wrote a simple perl script to check the checksums for me, and since it is not quite so ugly that I'm ashamed of it, I figured someone else might also benefit from it. Here's an example run, that tells me that my to installed versions of lynx collides, and lynx-2.8.2dev.22 was installed after the other one. frodo ~>pkg_checksum lynx-2.8.1.1 lynx-2.8.2dev.22 Checking package lynx-2.8.1.1 ... Checksum mismatch: /usr/local/man/man1/lynx.1.gz Checksum mismatch: /usr/local/bin/lynx Checking package lynx-2.8.2dev.22 ... Ok. My perl script is attached. Please tell me if this is already covered by some other pkg_ utility, if the script is bogus (and works for me only by accident), or if I should submit a port of it ... -- Rasmus Kaj ---------------- rasmus@kaj.a.se - http://www.e.kth.se/~kaj/ \ I link, therefore I am - /usr/bin/ld \--------------------------------------------- http://www.Raditex.se/ ----Next_Part(Fri_Jun_18_20:21:25_1999_294)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Description: pkg_checksum Content-Disposition: attachment; filename=pkg_checksum #! /usr/bin/perl -w use strict; use vars qw($opt_v); use Getopt::Std; # Options: # -v verbose (list good files, print mismatching checksums). getopts('v'); my $dbdir = $ENV{'PKG_DBDIR'}; $dbdir = '/var/db/pkg' if(!defined $dbdir); foreach (@ARGV) { print "Checking package $_ ..."; my $noerrors = 1; open(CONTENTS, "<$dbdir/$_/+CONTENTS"); my ($prefix, $file); foreach() { chomp; if(/^\@cwd (.*)/) { $prefix = $1; } elsif(! /^\@/) { $file = $_ ; } elsif(/^\@comment MD5:(.*)/) { my $sum = $1; my $realsum = `md5 \'$prefix/$file\'`; chomp $realsum; $realsum =~ s/.* ([0-9a-f]+)$/$1/; if($sum eq $realsum) { print "Ok: $prefix/$file\n" if($opt_v); } else { print "\n" if($noerrors); $noerrors = 0; print "Checksum mismatch: $prefix/$file\n"; print "$sum != $realsum\n" if($opt_v); } } } print " Ok.\n" if($noerrors); } ----Next_Part(Fri_Jun_18_20:21:25_1999_294)---- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message