diff options
Diffstat (limited to 'v4l/scripts')
| -rwxr-xr-x | v4l/scripts/hghead.pl | 20 | ||||
| -rwxr-xr-x | v4l/scripts/make_kconfig.pl | 188 | ||||
| -rwxr-xr-x | v4l/scripts/make_makefile.pl | 29 | ||||
| -rwxr-xr-x | v4l/scripts/make_myconfig.pl (renamed from v4l/scripts/make_noconfig.pl) | 0 | ||||
| -rwxr-xr-x | v4l/scripts/prep_commit_msg.pl | 73 | ||||
| -rwxr-xr-x | v4l/scripts/strip-trailing-whitespaces.sh | 57 | 
6 files changed, 289 insertions, 78 deletions
| diff --git a/v4l/scripts/hghead.pl b/v4l/scripts/hghead.pl index 16e566ea9..3f8b4b0ba 100755 --- a/v4l/scripts/hghead.pl +++ b/v4l/scripts/hghead.pl @@ -12,6 +12,7 @@ my $sub_ok=0;  my $init=0;  my $num=0;  my $hgimport=0; +my $mmimport=0;  my $maint_ok=0;  my $noblank=1;  my $maintainer_name=$ENV{CHANGE_LOG_NAME}; @@ -33,6 +34,10 @@ while ($line = <IN>) {  	if ($line =~ m/^\-\-\- .*/) {  		last;  	} +	if ($line =~ m/^\-\-\-\-.*/) { +		$body=""; +		next; +	}  	if ($line =~ m/^\-\-\-.*/) {  		last;  	} @@ -62,7 +67,11 @@ while ($line = <IN>) {  			$from= "From: $fromname\n";  			next;  		} -		print "Bad: author line have a wrong syntax\n"; +		if ($line =~ m/^From:\sakpm\@osdl.org/) { +			$mmimport=1; +			next; +		} +		print "Bad: author line have a wrong syntax: $line\n";  		die;  	} @@ -87,11 +96,11 @@ while ($line = <IN>) {  		$signed="$signed$line";  		next;  	} -	if ($line =~ m/^\# HG changeset patch/) { +	if ( ($line =~ m/^\# HG changeset patch/) || +	     ($line =~ m/^has been added to the -mm tree.  Its filename is/) ) {  		$sub_ok=0;  		$init=0;  		$num=0; -		$hgimport=0;  		$maint_ok=0;  		$noblank=1;  		$from=""; @@ -100,6 +109,7 @@ while ($line = <IN>) {  		$hgimport=1;  		next;  	} +  	if ($line =~ m/^Acked-by:.*/) {  		$signed="$signed$line"; @@ -164,8 +174,8 @@ if (!$signed =~ m/$from/) {  	die;  } -$body=~s/\n+$//; -$body=~s/^\n+$//; +$body=~s/[\n\s]+$//; +$body=~s/^[\n\s]+//;  # First from is used by hg to recognize commiter name  print "#Committer: $maintainer_name <$maintainer_email>\n"; diff --git a/v4l/scripts/make_kconfig.pl b/v4l/scripts/make_kconfig.pl index b499fefa1..c58f5b028 100755 --- a/v4l/scripts/make_kconfig.pl +++ b/v4l/scripts/make_kconfig.pl @@ -7,10 +7,69 @@ my %config = ();  my %intopt = ();  my %hexopt = ();  my %tristate = (); +my %kernopts = (); +my %depmods = ();  my $version, $level, $sublevel; +my $kernel=shift;  my $force_kconfig=shift; +#!/usr/bin/perl +use FileHandle; + +########################################################### +# Checks config.h and autoconf.h for current kernel defines +sub process_config ($) +{ +	my $filename = shift; +        my $in = new FileHandle; + +	open $in,"$kernel/include/$filename" or die; +	while (<$in>) { +	        if (m|\#include\s+\<(.*)\>|) { +			process_config ($1); +			next; +	        } +		if (m/\#define\s+CONFIG_([^ ]*)_ON_SMP\s+(.*)\n/) { +			my $key=$1; +			my $value=$2; +#			printf "defined $key as $value\n"; +			if ( $value == 1 ) { +				$value='y'; +			} +			$kernopts{$key}=$value; +			next; +		} +		if (m/\#define\s+CONFIG_([^ ]*)_MODULE\s+(.*)\n/) { +			my $key=$1; +			my $value=$2; +#			printf "defined $key as $value\n"; +			if ( $value == 1 ) { +				$value='m'; +			} +			$kernopts{$key}=$value; +			next; +		} +		if (m/\#define\s+CONFIG_([^ ]*)\s+(.*)\n/) { +			my $key=$1; +			my $value=$2; +#			printf "defined $key as $value\n"; +			if ( $value == 1 ) { +				$value='y'; +			} +			$kernopts{$key}=$value; +			next; +		} +		if (m/\#undef\s+CONFIG_([^ ]*)\n/) { +#			printf "undefined $1\n"; +			$kernopts{$1}='n'; +			next; +		} +	} + +	close $in; +} +  sub add_bool($)  {  	my $arg=shift; @@ -18,6 +77,8 @@ sub add_bool($)  	exists $config{$arg} or die "Adding unknown boolean '$arg'";  	$tristate{$arg}="bool";  #	printf "Boolean:%s\n",$arg; + +	$kernopts{$arg}='y';  }  sub add_tristate($) @@ -26,7 +87,8 @@ sub add_tristate($)  	exists $config{$arg} or die "Adding unknown tristate '$arg'";  	$tristate{$arg}="tristate"; -#	printf "Tristate:%s\n",$arg; + +	$kernopts{$arg}='m';  }  sub add_int($) @@ -75,6 +137,7 @@ sub add_config($)  	}  } +########################################  # Turn option off, iff it already exists  sub disable_config($)  { @@ -83,9 +146,14 @@ sub disable_config($)  	$config{$key} = 0 if (exists $config{$key});  } -sub check_deps($) +################################################################# +# Make a list of dependencies and the number of references for it +sub check_deps($$)  { +	my $key=shift;  	my $arg=shift; + +	$depmods{$key}=$arg;  	$arg=$arg." ";  	while ($arg ne "") { @@ -96,6 +164,44 @@ sub check_deps($)  		}  		$arg =~ s/^[^ ]+ //;  	} + +	return $ok; +} + +###################################################### +# Checks if all dependencies for the key are satisfied +sub deps_ok($) +{ +	my $key=shift; +	my $arg=$depmods{$key}; +	my $ok=1; + +	if ($arg eq "") { +		return $ok; +	} + +	$arg=$arg." "; + + +#	printf "$key: deps are '$arg'\n"; + +	while ($arg ne "") { +		if ($arg =~ m/^([A-Z0-9_]+) /) { +			if ((! exists $kernopts {$1}) || ($kernopts {$1} eq 'n')) { +				printf "$key: Required kernel opt '$1' is not present\n"; +				$ok=0; +			} +		} +		if ($arg =~ m/^\!([A-Z0-9_]+) /) { +			if ($kernopts {$1} eq 'y') { +				printf "$key: Driver is incompatible with  '$1'\n"; +				$ok=0; +			} +		} +		$arg =~ s/^[^ ]+ //; +	} + +	return $ok;  }  sub open_kconfig($$) { @@ -105,7 +211,7 @@ sub open_kconfig($$) {  	my $key;  #print "opening $file\n"; -	open $in,"$file"; +	open $in,"$file" or die;  	while (<$in>) {  #		if (m;^\s*source[\s\"]+drivers/media/(video|dvb)/Kconfig;) {  #			next; @@ -124,10 +230,10 @@ sub open_kconfig($$) {  			next;  		}  		if (m|^\s+depends on\s+(.*)\n|) { -			check_deps ($1); +			check_deps ($key,$1);  		}  		if (m|^\s+select\s+(.*)\n|) { -			check_deps ($1); +			check_deps ($key,$1);  		}  		if (m|^\s+bool(ean)?\s|) {  			add_bool($key); @@ -155,7 +261,6 @@ sub open_kconfig($$) {  			$default_seen = 1;  			$_ = "\tdefault n\n";  		} -  		# check for end of config definition for disabled drivers  		# we need to make sure we've disabled it, and add a bit  		# to the help text @@ -211,7 +316,7 @@ sub parse_versions ()  	my $in = new FileHandle;  	my $ver; -	open $in,"versions.txt"; +	open $in,"versions.txt" or die;  	while (<$in>) {  		if (m/\[([\d.]*)\]/) {  			$ver=$1; @@ -226,9 +331,11 @@ sub parse_versions ()  	close $in;  } +process_config("linux/config.h"); +  parse_versions; -open IN,".version"; +open IN,".version" or die;  while (<IN>) {  	if (m/KERNELRELEASE\s*[:]*[=]+\s*(\d+)\.(\d+)\.(\d+)/) {  		$version=$1; @@ -240,7 +347,7 @@ close IN;  printf "Preparing to compile for kernel version %d.%d.%d\n",$version,$level,$sublevel; -open OUT,">Kconfig"; +open OUT,">Kconfig" or die;  print OUT <<"EOF";  mainmenu "V4L/DVB menu" @@ -273,14 +380,19 @@ while ( my ($key, $value) = each(%config) ) {  		delete $depend{$key};  } -open OUT,">Kconfig.kern"; +open OUT,">Kconfig.kern" or die;  print OUT "config MODULES\n\tboolean\n\tdefault y\n\n";  add_config('MODULES');  add_bool('MODULES');  while ( my ($key, $value) = each(%depend) ) { -	print OUT "# $key with $value refs\nconfig $key\n\ttristate\n\tdefault m\n\n"; +	if ($kernopts{$key}) { +		print OUT "# $key with $value refs\nconfig $key\n\ttristate\n\tdefault ". +			$kernopts{$key}."\n\n"; +	} else { +		print OUT "# $key with $value refs\nconfig $key\n\ttristate\n\tdefault n #not found\n\n"; +	}  }  close OUT; @@ -288,12 +400,62 @@ close OUT;  disable_config('DVB_AV7110_FIRMWARE');  disable_config('DVB_CINERGYT2_TUNING'); +# Hack for check sound/oss/aci.h header + +my $mirodep="$kernel/sound/oss/aci.h"; +if (!open IN, $mirodep) { +	my $key="RADIO_MIROPCM20"; +print <<"EOF2"; +$key: $mirodep is missing. + +***WARNING:*** You do not have the full kernel sources installed. +This does not prevent you from building the v4l-dvb tree if you have the  +kernel headers, but the full kernel source is required in order to use  +make menuconfig / xconfig / qconfig. + +If you are experiencing problems building the v4l-dvb tree, please try  +building against a vanilla kernel before reporting a bug. + +Vanilla kernels are available at http://kernel.org. +On most distros, this will compile a newly downloaded kernel: + +cp /boot/config-`uname -r` <your kernel dir>/.config +cd <your kernel dir> +make all modules_install install + +Please see your distro's web site for instructions to build a new kernel. + +EOF2 +	$kernopts{$key}='n'; +} +close IN; + +# Recursively check for broken dependencies +my $i; +do { +	$i=0; +	while ( my ($key,$value) = each(%kernopts) ) { +		if ($value ne 'n') { +			if (!deps_ok($key)) { +				$kernopts{$key}='n'; +			} +			$i=$i+1; +		} +	} +} until (!$disable); +  # Produce a .config file if it's forced or one doesn't already exist  if (($force_kconfig eq 1) || !open IN,".config") { -	open OUT,">.config"; +	open OUT,">.config" or die;  	while ( my ($key,$value) = each(%tristate) ) {  		if (!$config{$key}) { -			print OUT "CONFIG_$key=n\n"; +			print OUT "# CONFIG_$key is not set\n"; +		} elsif ($kernopts{$key}) { +			if ($kernopts{$key} eq 'n') { +				print OUT "# CONFIG_$key is not set\n"; +			} else { +				print OUT "CONFIG_$key=".$kernopts{$key}."\n"; +			}  		} elsif ($value eq 'tristate') {  			print OUT "CONFIG_$key=m\n";  		} else { # must be 'bool' diff --git a/v4l/scripts/make_makefile.pl b/v4l/scripts/make_makefile.pl index 238c5082f..e0a099e9b 100755 --- a/v4l/scripts/make_makefile.pl +++ b/v4l/scripts/make_makefile.pl @@ -1,6 +1,7 @@  #!/usr/bin/perl  use FileHandle; +my $kernel=shift;  my $instdir = ();  sub check_line($$$) @@ -109,7 +110,7 @@ sub open_makefile($) {  	close $in;  } -open OUT,">Makefile.media"; +open OUT,">Makefile.media.new";  open_makefile ("../linux/drivers/media/Makefile");  # Creating Install rule @@ -156,8 +157,30 @@ while ( my ($key, $value) = each(%depend) ) {  }  close OUT; -if (open OUT,".myconfig") { +if (open IN,"Makefile.media") { +	close IN; +	my $changed=0; +	if (open IN,"diff Makefile.media Makefile.media.new|") { +		while (<IN>) { +			if ($_ ne "") { +				$changed=1; +			} +		} +		close IN; +		if ($changed) { +			printf("One or more linux Makefiles had changed. Makefile.media rewrited.\n"); +			system ("mv Makefile.media.new Makefile.media"); +		} else { +			system ("rm Makefile.media.new"); +		} +	} +} else { +	printf("Creating Makefile.media.\n"); +	system "mv Makefile.media.new Makefile.media"; +} + +if (open IN,".myconfig") {  	close IN;  } else { -	system "make allmodconfig"; +	system "./scripts/make_kconfig.pl $kernel 1";  } diff --git a/v4l/scripts/make_noconfig.pl b/v4l/scripts/make_myconfig.pl index 7323f419c..7323f419c 100755 --- a/v4l/scripts/make_noconfig.pl +++ b/v4l/scripts/make_myconfig.pl diff --git a/v4l/scripts/prep_commit_msg.pl b/v4l/scripts/prep_commit_msg.pl index ac958667b..a4594c7f9 100755 --- a/v4l/scripts/prep_commit_msg.pl +++ b/v4l/scripts/prep_commit_msg.pl @@ -1,34 +1,59 @@  #!/usr/bin/perl -$f=shift;  -open IN,"hg diff|diffstat -p1 |";  -my $n=2; -my $from=""; -my $first=""; -my $changed=""; -$out=""; -while (<IN>) { -	$changed="$changed#$_"; -} +my $autopatch = shift; +# Get Hg username from environment  my $user = $ENV{HGUSER}; -if ( $user eq "" ) { +# Didn't work? Try the .hgrc file +if ($user eq "") { +	open IN, "<$ENV{HOME}/.hgrc"; +	while (<IN>) { +		if(/^\s*username\s*=\s*(\S.*)$/) { +			$user = $1; +			last; +		} +	} +	close IN; +} + +# Still no luck? Try some other environment variables +if ($user eq "") {  	my $name = $ENV{CHANGE_LOG_NAME};  	my $email = $ENV{CHANGE_LOG_EMAIL_ADDRESS}; +	$user = "$name <$email>" if ($name ne "" || $email ne ""); +} + +# Last try to come up with something +if ($user eq "") { +	$user = "$ENV{USER} <>"; +} -	$user="$name <$email>"; +print "# Added/removed/changed files:\n"; +system "hg diff | diffstat -p1 -c"; +if (-s $autopatch) { +	print "#\n# Note, a problem with your patch was detected!  These changes were made\n"; +	print "# automatically: $autopatch\n"; +	system "diffstat -p0 -c $autopatch"; +	print "#\n# Please review these changes and see if they belong in your patch or not.\n";  } +print <<"EOF"; +# +# For better log display, please keep a blank line after subject, after from, +# and before signed-off-by. +# First line should be the subject, without Subject: +# + + +# Now, patch author (just the main one), on a From: field +# Please change below if the committer is not the patch author. +# +From: $user + +# Then a detailed description: + -$first= "# Please change below if you are not patch author\n#\nFrom: $user"; -$out= "# At the end Signed-off-by: fields by patch author and committer, at least\n#\nSigned-off-by: $user"; -$from= "From: $user"; - -printf  "#Added/removed/changed files:\n%s#\n" . -	"# For better log display, please keep a blank line after subject, after from\n" . -	"# and before signed-off-by\n" . -	"# First line should be the subject, without Subject:\n#\n\n\n" . -	"# Now, patch author (just the main one), on a From: field\n" . -	"# Please change below if the committer is not the patch author\n#\n%s\n\n" . -	"# Then a detailed description:\n\n\n%s", -	$changed,$from,$out; +# At the end Signed-off-by: fields by patch author and committer, at least. +# +Signed-off-by: $user +EOF diff --git a/v4l/scripts/strip-trailing-whitespaces.sh b/v4l/scripts/strip-trailing-whitespaces.sh index 1a23e436d..a546a0b9f 100755 --- a/v4l/scripts/strip-trailing-whitespaces.sh +++ b/v4l/scripts/strip-trailing-whitespaces.sh @@ -1,37 +1,28 @@  #!/bin/sh +# Strips trailing whitespace.  Leading spaces and spaces after tabs are +# converted to the equivalent sequence of tabs only. -# tmp dir for my files -WORK="${TMPDIR-/tmp}/${0##*/}-$$" -mkdir "$WORK" || exit 1 -trap 'rm -rf "$WORK"' EXIT +# Use the option "fast" to only check files Hg thinks are new or modified. +# The option "manifest" will use Hg's manifest command to check all files +# under Hg revision control. +# Otherwise, all files under the linux tree are checked, except files in CVS +# directories and .cvsignore files. This is the historical behavior. -for file in `find linux -type d | grep -v CVS | grep -v .cvsignore` ; do -    mkdir -p "$WORK/${file}" -done -for file in `find linux -type f | grep -v CVS | grep -v .cvsignore` ; do -	tmpfile="$WORK/${file}.$$" -	perl -ne 's/[ \t]+$//; -        s/^\ \ \ \ \ \ \ \ /\t/;  -        s/^\ \ \ \ \ \ \ \t/\t/;  -        s/^\ \ \ \ \ \ \t/\t/;  -        s/^\ \ \ \ \ \t/\t/;  -        s/^\ \ \ \t/\t/;  -        s/^\ \ \t/\t/;  -        s/^\ \t/\t/; -	$m=1; -	while ($m>0) { -		$m=0; -	        $m=   s/\t\ \ \ \ \ \ \ \ /\t\t/g;  -	        $m=$m+s/\t\ \ \ \ \ \ \ \t/\t\t/g;  -	        $m=$m+s/\t\ \ \ \ \ \ \t/\t\t/g;  -	        $m=$m+s/\t\ \ \ \ \ \t/\t\t/g;  -	        $m=$m+s/\t\ \ \ \t/\t\t/g;  -		$m=$m+s/\t\ \ \t/\t\t/g;  -	        $m=$m+s/\t\ \t/\t\t/g; -	} -	print' < "${file}" > "${tmpfile}" -	diff -u "${file}" "${tmpfile}" | sed 		\ -		-e "s|^--- ${file}|--- ${file}.orig|"	\ -		-e "s|^+++ ${tmpfile}|+++ ${file}|" -	rm -f "$tmpfile" + +if [ "x$1" = "xfast" ]; then +	files="hg status -man" +elif [ "x$1" = "xmanifest" ]; then +	files="hg manifest | cut '-d ' -f3" +else +	files="find linux -name CVS -prune -o -type f -not -name .cvsignore -print" +fi + +for file in `eval $files`; do +	perl -ne ' +	s/[ \t]+$//; +	s<^ {8}> <\t>; +	s<^ {1,7}\t> <\t>; +	while( s<\t {8}> <\t\t>g || s<\t {1,7}\t> <\t\t>g ) {}; +	print' < "${file}" | \ +		diff -u --label="$file" "$file" --label="$file" -  done | 
