diff options
author | mharo <mharo@FreeBSD.org> | 2000-05-02 03:44:50 +0800 |
---|---|---|
committer | mharo <mharo@FreeBSD.org> | 2000-05-02 03:44:50 +0800 |
commit | b774256aa8635c1ea2f39e24d94a80b63c725a9d (patch) | |
tree | b5a4e6afc79dbcf1137efb4a2a3d332a3934c87c /Tools/scripts | |
parent | d504e9249d02bab72c286a9c2e8c8b73276f7781 (diff) | |
download | freebsd-ports-gnome-b774256aa8635c1ea2f39e24d94a80b63c725a9d.tar.gz freebsd-ports-gnome-b774256aa8635c1ea2f39e24d94a80b63c725a9d.tar.zst freebsd-ports-gnome-b774256aa8635c1ea2f39e24d94a80b63c725a9d.zip |
A tool to check whether all your ports are installed properly, what files
have changed, what new files there are, and so forth.
Created by: Neil Blakey-Milner <nbm@mithrandr.moria.org>
Diffstat (limited to 'Tools/scripts')
-rwxr-xr-x | Tools/scripts/consistency-check | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/Tools/scripts/consistency-check b/Tools/scripts/consistency-check new file mode 100755 index 000000000000..ccd29bdd0676 --- /dev/null +++ b/Tools/scripts/consistency-check @@ -0,0 +1,143 @@ +#!/usr/bin/perl +# +# Copyright (c) 1999 Neil Blakey-Milner +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +#my($path) = "/var/qmail"; +my($path) = "/usr/local/bin"; +my($pkgdir) = "/var/db/pkg"; + +$do_md5 = 1; +$do_fs = 1; + +my(@fsfiles); +my(%files); +my(%fsmd5); +my(%pkgmd5); +my(%pkgname); + +if ($do_fs) { + @fsfiles = `find $path ! -type d`; + foreach (@fsfiles) { + chomp; + s#\Q$path\E/?##; + $files{$_} = 1; + chomp($fsmd5{$_} = `md5 -q $path/$_ 2> /dev/null`) if $do_md5 == 1; + } +} + +require "find.pl"; +&find('/var/db/pkg'); +# Traverse desired filesystems + +foreach (sort keys %files) { + $file = $_; + $pkgname{$_} =~ s/,$//; + $files{$_} == 1 && do { + print "Only on filesystem - $_\n"; + next; + }; + $files{$_} == 2 && do { + if ($do_fs == 1) { + printf "Not on filesystem - $_ from %s\n", $pkgname{$_}; + next; + } + }; + if ($do_fs != 1) { + if (-e "$path/$_") { + chomp($fsmd5{$_} = `md5 -q $path/$_ 2> /dev/null`) if $do_md5 == 1; + } else { + printf "Not on filesystem - $_ from %s\n", $pkgname{$_}; + } + } + $files{$_} > 3 && do { + printf "File $_ owned by multiple packages %s\n", $pkgname{$_}; + }; + + if ($do_md5) { + $pkgmd5tmp = $pkgmd5{$_}; + $fsmd5tmp = $fsmd5{$_}; + if ($fsmd5tmp =~ /^ *$/) { + $msg = ""; + $msg = ", but it exists" if (-e "$path/$_"); + printf "No filesystem md5 available for $_%s\n", $msg; + next; + } + if ($pkgmd5tmp =~ /^ *$/) { + print "No package md5 available for $_\n"; + next; + } + foreach (split /,/, $pkgmd5tmp) { + #print "Comparing: $fsmd5tmp $_\n"; + if ($fsmd5tmp !~ /\Q$_\E/) { + print "For $file, package md5 $_ is " . + "DIFFERENT from fs md5 of $fsmd5tmp!\n"; + } + } + } +} + +exit; + +sub wanted { + my($dev, $ino, $mode, $nlink, $uid, $gid); + my($cwd, $tmp); + (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) && + -f _ && + /^\+CONTENTS$/ || return; + open(CNT, "$name"); + chomp($pkg = `dirname $name`); + chomp($pkg = `basename $pkg`); + $cwd = ""; + $lastfile = ""; + while(<CNT>) { + chomp; + /^\@cwd (.*)$/ && do { + $cwd = $1; + next; + }; + s#^\@comment MD5:## && do { + return if $cwd =~ /^\.?$/; + $tmp = "$cwd/$lastfile"; + if ($tmp =~ s#^\Q$path\E/?##) { + $pkgmd5{$tmp} .= "$_,"; + } + next; + }; + /^[^@]/ && do { + $lastfile = $_; + return if $cwd =~ /^\.?$/; + $tmp = "$cwd/$_"; + if ($tmp =~ s#^\Q$path\E/?##) { + $files{$tmp} += 2; + $pkgname{$tmp} .= "$pkg,"; + } + }; + } + close(CNT); +} + |