#!/usr/bin/perl # skvidal@phy.duke.edu # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. sub compsprune { my ($compslist,$arch)=@_; my @compsreturn; my @compstmp; my $numerrors=0; open(comps,"$compslist"); while () { next if m/^\s*$/; next if m/[{|}|\@]/; if (m/:/g) { next if m/\!\s*$arch:/; push @compstmp,$_ if m/^\s*$arch\:/; push @compstmp,$_ if m/\(lang .*\):.*/; next; } next if m/^\d$/; push @compstmp, $_; } close(comps); foreach $item (@compstmp) { $item=~s/^.*://g; $item=~s/[\s|\t|\n]*//g; # print "$item\n"; push @compsreturn, "$item"; } return @compsreturn; } sub getrpms { my $dir="@_"; @rpmsreturn=`/bin/rpm -qp --queryformat '%{name}\n' $dir/*.rpm`; return @rpmsreturn; } if ($#ARGV < 2) { print "Usage: $0 [architecture] [comps file] [path to rpms]\n"; exit(1); } ($arch,$compslist,$dir)=@ARGV; @comps=&compsprune($compslist,$arch); @rpms=&getrpms($dir); my %rpmhash; foreach $rpm (@rpms) { $rpm=~s/[\n|\s]//g; $rpmhash{$rpm}=1; } foreach $comp (@comps) { $comp=~s/[\n|\s]//g; print "$comp present in comps for $arch but absent from rpm directory\n" if ! exists $rpmhash{"$comp"}; $numerrors++; } exit($numerrors);