aem@mthvax.cs.miami.edu (a.e.mossberg) (03/21/91)
I whiped this up today to show me the changes from what setld thinks I have loaded, and what changed I've made. Synopsis: setldv -i - list of what setld thinks you have loaded setldv -i [subset...] - lists contents of subset(s) setldv -v [subset...] - try to verify subset using checksums -V option gives more verbose messages ---cut here--- #!/usr/local/bin/perl # verify a setld subset inventory # aem@mthvax.cs.miami.edu 3/20/91 # # setldv [-i[V]] [-v[V]] [subsets...] # -i inventory subset. If no subset listed, list installed subsets # -v verify specified subset # -V verbosity do 'getopts.pl'; do Getopts('viV'); if (!$opt_v && !$opt_i) { print "Usage: setldv [-viV] [subset]\n"; exit 1; } if ($opt_v && $#ARGV < 0 ) { print "setldv: verify requires subset name. Do setldv -i for list.\n"; exit 1; } # subset control files are in: $DIR="/usr/etc/subsets"; if ($opt_i && $#ARGV < 0 ) { # read in list of .lk files from subset dir, # print out name and description from .ctrl file chdir $DIR; open(IN,"ls *.lk|"); while (<IN>) { chop; $file = $_; $file =~ s/\.lk//; if ( -f "${file}.ctrl" ) { print "$file"; if ($opt_V) { open(IN2,"${file}.ctrl"); while (<IN2>) { if (/DESC=/) { ($foo,$desc,$foo) = split(/'/); print " - $desc"; } if (/DEPS=/) { ($foo,$desc,$foo) = split(/"/); if ($desc ne ".") {print " - Depends on $desc.";} } } } print "\n"; } else { die "$file $!"; } } exit 0; } foreach $subset (@ARGV) { if ( ! -f "$DIR/$subset.inv" ) { print "setldv: sorry, subset \"$subset\" does not exist.\n"; exit 1; } if ($opt_V) { print "loading inventory for subset $subset...\n"; } open (IN,"$DIR/$subset.inv") || die "Couldn't open $subset.inv $!"; while (<IN>) { ( $foo, $bytes, $sum, $foo, $foo, $mode, $date, $vers, $type, $file, $linkto, $foo ) = split; if ($opt_v) { push(@files,$file); $checksum{$file} = $sum; $filetype{$file} = $type; if ($type eq "l") { $link{$file} = $linkto; } if ($type eq "s") { $link{$file} = $linkto; } } if ($opt_i) { $_ = $type; if (/d/) { print "$file"; $dirs++; if ($opt_V) { print " (directory)";} } if (/l/) { print "$file"; $links++; if ($opt_V) { print " (hard link to $linkto)";} } if (/s/) { print "$file"; $syms++; if ($opt_V) { print " (symbolic link to $linkto)";} } if (/f/) { print "$file"; $plain++; if ($opt_V) { print " (plain file)";} } print "\n"; } } close(IN); } if ($opt_v) { chdir '/'; # all filenames relative to origin foreach $file (@files) { $_ = $filetype{$file}; if (/d/) { # check directory if ( -d $file ) { if ($opt_V) { print "$file directory okay.\n"; } } else { print "$file (directory) missing.\n"; } } if (/s/) { # symbolic link if ( ! -s $file ) { print "$file (symbolic link) missing.\n"; } } if (/l/) { # hard link if ( ! -l $file ) { print "$file (hard link) missing.\n"; } } if (/f/) { # plain file, do the checksum thing if ( -f $file ) { $tmp = `sum $file`; chop $tmp; ($sum_now, $foo) = split(/ /,$tmp); if ( $checksum{$file} == $sum_now ) { if ($opt_V) { print "$file okay.\n"; } } else { print "$file checksum changed.\n"; } } else { print "$file (plain file) missing.\n"; } } } } #end of file -- aem@mthvax.cs.miami.edu ....................................................... What does a lifetime of watching television do to your brain? - Andrew McEvoy