packages: kernel/kernel-module-build.pl - extended funcionality to remove u...

sparky sparky at pld-linux.org
Sat Dec 5 04:07:26 CET 2009


Author: sparky                       Date: Sat Dec  5 03:07:26 2009 GMT
Module: packages                      Tag: HEAD
---- Log message:
- extended funcionality to remove unneeded files from headers
- names of output files changed to something more descrptive
- commets added ! not many, but should be enough

---- Files affected:
packages/kernel:
   kernel-module-build.pl (1.2 -> 1.3) 

---- Diffs:

================================================================
Index: packages/kernel/kernel-module-build.pl
diff -u packages/kernel/kernel-module-build.pl:1.2 packages/kernel/kernel-module-build.pl:1.3
--- packages/kernel/kernel-module-build.pl:1.2	Tue Mar 31 14:04:28 2009
+++ packages/kernel/kernel-module-build.pl	Sat Dec  5 04:07:20 2009
@@ -6,11 +6,29 @@
 
 my $rpmdir = shift @ARGV or die;
 my $fileoutdir = shift @ARGV or die;
-my @tosort;
 
-find(\&wanted, ".");
+# files which match: */include/*/Kbuild
+my @modulebuild_in_include;
+# files which match: */Kbuild */Kconfig except include
+my @modulebuild;
+# parent dirs of Kconfig files which match */include*
+my @dirs_in_include;
+# parent dirs of Kconfig files except include
+my @dirs;
 
-sub wanted {
+sub push_dirs
+{
+	my $list = shift;
+	my $dir = shift;
+	my $subdir = "";
+	foreach my $sub ( split( '/', $dir )) {
+		$subdir .= "/" . $sub;
+		push @$list, "\%dir $rpmdir$subdir\n";
+	}
+}
+
+sub wanted
+{
 	return unless -f;
 	return unless /^Kconfig/ or /^Makefile/ or /^Kbuild/;
 	#return if /\.orig$/;
@@ -18,21 +36,53 @@
 	(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";
+	if ( $dir =~ m{^(.*/)?include(/.*?)?$} ) {
+		push @modulebuild_in_include, "$rpmdir/$file\n";
+		push_dirs( \@dirs_in_include, $dir );
+	} else {
+		push @modulebuild, "$rpmdir/$file\n";
+		push_dirs( \@dirs, $dir );
 	}
-	push @tosort, "$rpmdir/$file\n";
 }
 
-my $last = "";
-my @toprint = grep {if ($_ ne $last) { $last = $_; 1} else {0}} sort @tosort;
+find(\&wanted, ".");
+
+sub uniq
+{
+	my %hash = map { $_, 1 } @_;
+	return sort keys %hash;
+}
+
+sub remove
+{
+	my $from = shift;
+	my $what = shift;
+	my %hash = map { $_, 1 } @$from;
+	foreach ( @$what ) {
+		delete $hash{ $_ };
+	}
+	return sort keys %hash;
+}
+
+# to module-build add all Kconfig, Makefile and Kbuild files
+# also add all their parent dirs if they aren't parents of some include directory
+open F_OUT, "> $fileoutdir/files.mb_include_modulebuild_and_dirs"
+	or die "Can't create files.mb_include_modulebuild_and_dirs: $!\n";
+print F_OUT remove( \@dirs, \@dirs_in_include );
+print F_OUT uniq( @modulebuild_in_include, @modulebuild );
+close F_OUT and print "files.mb_include_modulebuild_and_dirs created\n";
+
+# from source remove all files Kconfig, Makefile and Kbuild files
+# also remove all their parent dirs
+open F_OUT, "> $fileoutdir/files.source_exclude_modulebuild_and_dirs"
+	or die "Can't create files.source_exclude_modulebuild_and_dirs: $!\n";
+print F_OUT map {"\%exclude $_"} uniq( @modulebuild_in_include, @modulebuild,
+	@dirs_in_include, @dirs );
+close F_OUT and print "files.source_exclude_modulebuild_and_dirs created\n";
 
-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";
+# from headers remove all Kconfig, Makefile and Kbuild files that are
+# part of include directory
+open F_OUT, "> $fileoutdir/files.headers_exclude_kbuild"
+	or die "Can't create files.headers_exclude_kbuild: $!\n";
+print F_OUT map {"\%exclude $_"} uniq( @modulebuild_in_include );
+close F_OUT and print "files.headers_exclude_kbuild created\n";
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/kernel/kernel-module-build.pl?r1=1.2&r2=1.3&f=u



More information about the pld-cvs-commit mailing list