Date: Fri, 18 Jun 1999 20:21:39 +0200 From: Rasmus Kaj <kaj@raditex.se> To: ports@FreeBSD.org Cc: Rasmus Kaj <kaj@raditex.se> Subject: Checking the checksums for an installed port Message-ID: <19990618202139I.kaj@raditex.se>
next in thread | raw e-mail | index | archive | help
----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(<CONTENTS>) { 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990618202139I.kaj>