summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pkgtools/pkglint/files/plist-clash.pl131
1 files changed, 48 insertions, 83 deletions
diff --git a/pkgtools/pkglint/files/plist-clash.pl b/pkgtools/pkglint/files/plist-clash.pl
index befdf25f1b1..0048d8d2dc8 100644
--- a/pkgtools/pkglint/files/plist-clash.pl
+++ b/pkgtools/pkglint/files/plist-clash.pl
@@ -1,97 +1,62 @@
-#!@PERL@
+#! @PERL@
+# $NetBSD: plist-clash.pl,v 1.4 2005/10/24 20:56:53 rillig Exp $
#
-# $NetBSD: plist-clash.pl,v 1.3 2005/02/14 22:14:48 cube Exp $
-#
-# Scan all ports and look for filenames used by more than one port.
-
-if(`uname -s` eq "FreeBSD"){
- $OS="FreeBSD";
- $PORTSDIR="/usr/ports";
-}else{
- $OS="NetBSD";
- $PORTSDIR="@PORTSDIR@";
-}
-
-###########################################################################
-sub read_plist
-{
- local($pkg)=@_;
- local($base);
+# Scan all PLIST files given on the command line and report all lines
+# that appear more than once.
- $prefix="\$LOCALBASE";
-
- if(! -d $pkg){
- print "$pkg: no such dir\n";
- return;
- }
+my $conf_rootdir = '@PKGSRCDIR@';
- open(M,"$pkg/Makefile") || die "Can't read $pkg/Makefile: $!\n";
- while(<M>){
- $prefix="\$X11BASE" if /USE_X11/;
- $prefix="\$X11BASE" if /USE_IMAKE/;
- $prefix=$1 if /^PREFIX\??=\s*(\S+)/;
- }
- close(M);
+my %files = ();
- # printf "%-40s prefix=%s\n","$pkg:",$prefix;
+sub read_PLIST($) {
+ my ($fname) = @_;
- # NetBSD may have more than one PLIST file
- opendir(D,"$pkg/pkg/.") || die "Can't readdir($pkg/pkg/.): $!\n";
- while($f=readdir(D)){
- if($f =~ /^PLIST/){
- next if $f=~/.orig$/;
-
- # printf("%-40s PLIST=$f\n","",$f);
-
- open(P,"$pkg/pkg/$f") or die "Can't read $pkg/pkg/$f: $!\n";
- while(<P>){
- next if /^@/;
- chomp;
-
- # strip .gz off manpages - handled via MANZ
- s/.gz$// if /^man/;
+ if (!open(F, "<", $fname)) {
+ warn "$!\n";
+ return undef;
+ }
- ($p) = $pkg =~ m@$PORTSDIR/(.+)@;
- if(0 and $F{"$prefix/$_"}){
- print "$prefix/$_ already used by ",$F{"$prefix/$_"},"\n";
+ my $lineno = 0;
+ foreach my $line (<F>) {
+ chomp($line);
+ $lineno++;
+
+ # Ignore comments and commands
+ next if ($line =~ qr"^@");
+
+ # Ignore filenames with embedded variables
+ next if ($line =~ qr"\$");
+
+ if ($line =~ qr"^[A-Za-z0-9].*") {
+ if (!exists($files{$line})) {
+ $files{$line} = [];
+ }
+ push(@{$files{$line}}, "$fname:$lineno");
+
+ } else {
+ warn("ERROR: $fname:$lineno: Unknown line type\n");
}
- $F{"$prefix/$_"} .= " $p";
- }
- close(P);
}
- }
- closedir(D);
+ close(F);
}
+sub main() {
+ if (@ARGV == 0) {
+ die("usage: $0 <plist>...\n");
+ }
-###########################################################################
-# M A I N
-###########################################################################
-
-if($#ARGV < 0){
- die "Usage: $0 portsdir1 ...\n";
-}
+ foreach my $plist (@ARGV) {
+ read_PLIST($plist);
+ }
-# loop to parse all PLIST files
-foreach $pkg (@ARGV){
- print "===> $pkg\n";
- &read_plist($pkg);
+ foreach my $file (sort keys %files) {
+ my $srcs = $files{$file};
+ if (@{$srcs} != 1) {
+ foreach my $src (@{$srcs}) {
+ print "$src: $file\n";
+ }
+ }
+ }
}
-# Output diplicates
-foreach $file (sort keys %F){
- $pkgs=$F{$file};
- $pkgs=~s/^\s+//g;
-
- # clean up duplicates (e.g. via PLIST-*)
- undef %pF;
- foreach $p (split(/ /,$pkgs)){
- $pF{$p}=1;
- }
- @pkgs=sort keys %pF;
-
- $n=$#pkgs+1;
- if($n>1){
- print "$n for $file: ",join(", ",@pkgs),"\n";
- }
-}
+main();