aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2011-03-21 15:43:33 (GMT)
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-03-21 16:36:26 (GMT)
commitc025baff4ff53beb9d35c0a0ae62c73d038723c6 (patch)
treee41681d08f1c522cf73711c00e4eab92a5441762
parent11ab52e7a03fe6829d083914820ad945d1291d68 (diff)
Add a printk messages for media builds
When someone reports an error, we need to know what are the applied patches. Also, users need to be warned that using the backported tree is not the same as running a stable kernel. This patch adds a logic that patches the subsystem core in order to indicate that an experimental tree is being used. It also prints the latest applied patches, in order to help developers when a bug report is filled. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--linux/Makefile3
-rwxr-xr-xlinux/use_dir.pl9
-rwxr-xr-xlinux/version_patch.pl90
3 files changed, 100 insertions, 2 deletions
diff --git a/linux/Makefile b/linux/Makefile
index 1eb4f51..a23abd3 100644
--- a/linux/Makefile
+++ b/linux/Makefile
@@ -95,7 +95,7 @@ untar: linux-media.tar.bz2
-rm -f .patches_applied
clean:
- -rm -rf $(MAINDIRS) .patches_applied .linked_dir
+ -rm -rf $(MAINDIRS) .patches_applied .linked_dir .git_log.md5
dir: clean
@lsdiff --version >/dev/null # Make 'make dir' fail if lsdiff is not installed
@@ -140,6 +140,7 @@ apply_patches apply-patches:
echo "#$$dir" > .patches_applied; \
cat .patches_applied.old >> .patches_applied; \
rm -f .patches_applied.old; \
+ ./version_patch.pl; \
if [ -e .linked_dir ]; then ./use_dir.pl --get_patched; fi
unapply_patches unapply-patches:
diff --git a/linux/use_dir.pl b/linux/use_dir.pl
index 2172270..015c9ac 100755
--- a/linux/use_dir.pl
+++ b/linux/use_dir.pl
@@ -166,7 +166,13 @@ sub get_patched_files()
{
my %files;
- open IN, $patchfile;
+ open IN, $patchfile or return %files;
+
+ # Those files are always patched to add warnings about the usage of experimental version
+ $files{"drivers/media/dvb/dvb-core/dvbdev.c"} = 1;
+ $files{"drivers/media/video/v4l2-dev.c"} = 1;
+ $files{"drivers/media/rc/rc-main.c"} = 1;
+
while (<IN>) {
next if (/^\s*#/);
@@ -193,6 +199,7 @@ sub sync_patched_files()
return if (!%patches);
foreach my $file (keys %patches) {
+printf "sync patched file $file\n";
$fhash{$file} = hash_calc("$dir/$file");
mkpath($path);
copy("$dir/$file", $file);
diff --git a/linux/version_patch.pl b/linux/version_patch.pl
new file mode 100755
index 0000000..c376556
--- /dev/null
+++ b/linux/version_patch.pl
@@ -0,0 +1,90 @@
+#!/usr/bin/perl
+use strict;
+
+
+sub patch_file($$$$)
+{
+ my $filename = shift;
+ my $function = shift;
+ my $after_line = shift;
+ my $media_build_version = shift;
+ my $patched;
+ my $warning = "WARNING: You are using an experimental version of the media stack.";
+
+ open IN, "$filename" or die "can't open $filename";
+ my $is_function;
+ my $file;
+ while (<IN>) {
+ next if (m/($warning)/);
+ $file .= $_;
+ if (m/($function)/) {
+ $is_function = 1;
+ next;
+ };
+ next if (!$is_function);
+ if (/\}/) {
+ $is_function--;
+ next;
+ };
+ if (m/\{/) {
+ $is_function++;
+ next;
+ };
+ if ($is_function && m/($after_line)/) {
+ $file .= "\tprintk(KERN_ERR \"$warning\\n" .
+ "\\t\\tAs the driver is backported to an older kernel, it doesn't offer enough\\n" .
+ "\\t\\tquality for its usage in production.\\n" .
+ "\\t\\tUse it with care.\\n$media_build_version\\n\");\n";
+ $is_function = 0;
+ $patched++;
+ next;
+ };
+ }
+ close IN;
+
+ open OUT, ">$filename.new" or die "Can't open $filename.new";
+ print OUT $file;
+ close OUT;
+ rename "$filename", "$filename~" or die "Can't rename $filename to $filename~";
+ rename "$filename.new", "$filename" or die "Can't rename $filename.new to $filename";
+ if ($patched) {
+ print "Patched $filename\n";
+ } else {
+ die "$filename was not patched.\n";
+ }
+}
+
+#
+# Main
+#
+
+# Prepare patches message
+open IN, "git_log" or die "can't open git_log";
+my $logs;
+$logs.=$_ while (<IN>);
+close IN;
+$logs =~ s/\s+$//;
+$logs =~ s,\n,\\n\\t,g;
+$logs = "Latest git patches:\\n\\t$logs";
+
+my $need_patch;
+open IN, "md5sum git_log|" or die "can't find git_log";
+my $hash = <IN>;
+close IN;
+open IN, ".git_log.md5" or $need_patch = 1;
+if (!$need_patch) {
+ $need_patch = 1 if ($hash ne <IN>);
+}
+
+if ($need_patch) {
+ # Patch dvbdev
+ patch_file "drivers/media/dvb/dvb-core/dvbdev.c", "__init init_dvbdev", "MKDEV", $logs;
+ # Patch v4l2-dev
+ patch_file "drivers/media/video/v4l2-dev.c", "__init videodev_init", "printk", $logs;
+ # Patch rc core
+ patch_file "drivers/media/rc/rc-main.c", "__init rc_core_init", "rc_map_register", $logs;
+
+ open OUT,">.git_log.md5";
+ print OUT $hash;
+ close OUT;
+}

Privacy Policy