SOURCES (LINUX_2_6): kernel-module-build.pl - more perl, less blac...

sparky sparky at pld-linux.org
Tue Jun 13 23:59:11 CEST 2006


Author: sparky                       Date: Tue Jun 13 21:59:11 2006 GMT
Module: SOURCES                       Tag: LINUX_2_6
---- Log message:
- more perl, less black magic

---- Files affected:
SOURCES:
   kernel-module-build.pl (1.1.2.1 -> 1.1.2.2) 

---- Diffs:

================================================================
Index: SOURCES/kernel-module-build.pl
diff -u SOURCES/kernel-module-build.pl:1.1.2.1 SOURCES/kernel-module-build.pl:1.1.2.2
--- SOURCES/kernel-module-build.pl:1.1.2.1	Tue May 16 19:22:40 2006
+++ SOURCES/kernel-module-build.pl	Tue Jun 13 23:59:06 2006
@@ -1,18 +1,38 @@
 #!/usr/bin/perl
+#
+use strict;
+use warnings;
+use File::Find qw(find);
 
-open( F, $ARGV[0]) or die("cannot open file: $ARGV[0]\n" );
- at lines = <F>;
-close( F );
-
-foreach (@lines)
-{
-	@pe = split( '/', $_ );
-	my $tmp;
-	for my $p (0 .. $#pe - 1)
-	{
-		$tmp = $tmp . '/' . $pe[$p];
-		print( "%dir $ARGV[1]$tmp\n" );
+my $rpmdir = shift @ARGV or die;
+my $fileoutdir = shift @ARGV or die;
+my @tosort;
+
+find(\&wanted, ".");
+
+sub wanted {
+	return unless -f;
+	return unless /^Kconfig/ or /^Makefile/;
+	#return if /\.orig$/;
+	return if $File::Find::name =~ /(Documentation|scripts)/;
+	(my $file = $File::Find::name) =~ s#^\./##;
+	$file =~ m#^(.*)/#;
+	my $dir = $1;
+	my $subdir = "";
+	foreach my $sub ( split( '/', $dir )) {
+		$subdir .= "/" . $sub;
+		push @tosort, "\%dir $rpmdir$subdir\n";
 	}
-	my $file = join( '/', @pe );
-	print( "$ARGV[1]/$file" );
+	push @tosort, "$rpmdir/$file\n";
 }
+
+my $last = "";
+my @toprint = grep {if ($_ ne $last) { $last = $_; 1} else {0}} sort @tosort;
+
+open F_OUT, "> $fileoutdir/aux_files" or die "Can't create aux_files: $!\n";
+print F_OUT @toprint;
+close F_OUT and print "aux_files created\n";
+
+open F_OUT, "> $fileoutdir/aux_files_exc" or die "Can't create aux_files_exc: $!\n";
+print F_OUT map {"\%exclude $_"} @toprint;
+close F_OUT and print "aux_files_exc created\n";
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/kernel-module-build.pl?r1=1.1.2.1&r2=1.1.2.2&f=u



More information about the pld-cvs-commit mailing list