[kernel] r14145 - in dists/trunk/linux-2.6/debian: . templates/temp.image.plain

Ben Hutchings benh at alioth.debian.org
Thu Aug 20 02:22:37 UTC 2009


Author: benh
Date: Thu Aug 20 02:22:34 2009
New Revision: 14145

Log:
Add warning on upgrade to a new upstream version where the system appears to be missing necessary firmware files (closes: #541702)

Modified:
   dists/trunk/linux-2.6/debian/changelog
   dists/trunk/linux-2.6/debian/templates/temp.image.plain/postinst
   dists/trunk/linux-2.6/debian/templates/temp.image.plain/templates

Modified: dists/trunk/linux-2.6/debian/changelog
==============================================================================
--- dists/trunk/linux-2.6/debian/changelog	Thu Aug 20 00:34:40 2009	(r14144)
+++ dists/trunk/linux-2.6/debian/changelog	Thu Aug 20 02:22:34 2009	(r14145)
@@ -53,6 +53,8 @@
   * ib_ipath: remove firmware for QLogic IBA7220 and use
     request_firmware() to load it
   * dvb-usb-af9005: remove firmware and disable
+  * Add warning on upgrade to a new upstream version where the system
+    appears to be missing necessary firmware files (closes: #541702)
 
   [ Martin Michlmayr ]
   * [armel/orion5x, armel/kirkwood] Set GPIO_SYSFS=y since these

Modified: dists/trunk/linux-2.6/debian/templates/temp.image.plain/postinst
==============================================================================
--- dists/trunk/linux-2.6/debian/templates/temp.image.plain/postinst	Thu Aug 20 00:34:40 2009	(r14144)
+++ dists/trunk/linux-2.6/debian/templates/temp.image.plain/postinst	Thu Aug 20 02:22:34 2009	(r14145)
@@ -19,6 +19,7 @@
 #use strict; #for debugging
 use Cwd 'abs_path';
 use Debconf::Client::ConfModule qw(:all);
+use POSIX ();
 version('2.0');
 my $capb=capb("backup");
 
@@ -760,6 +761,94 @@
       }
     }
   }
+
+  # If we are installing (not upgrading) a package for a newer
+  # upstream version than that of the running kernel, check whether
+  # the user might be missing necessary firmware, perhaps because
+  # it has now been removed from the kernel.
+  #
+  # We base this check on the modules used in the running kernel and
+  # the corresponding (by name) modules in the new kernel.  This is
+  # not entirely accurate because:
+  # 1. A device may now be handled by a module with a different name,
+  #    leading us to miss the dependency
+  # 2. A device may be handled by a module that needs firmware only
+  #    for some other device, leading us to claim a dependency wrongly
+
+  if (!defined($ARGV[1]) || $ARGV[1] eq '') {
+    (undef, undef, my $running_version) = POSIX::uname();
+    my $running_patchlevel = $running_version;
+    $running_patchlevel =~ s/^2\.6\.(\d+).*/$1/;
+    my $new_patchlevel = $version;
+    $new_patchlevel =~ s/^2\.6\.(\d+).*/$1/;
+
+  FIRMWARE_CHECK:
+    if ($new_patchlevel > $running_patchlevel) {
+      my $missing = '';
+      my %module_paths;
+      open(DEP, "<$modules_base/$version/modules.dep") or last FIRMWARE_CHECK;
+      while (<DEP>) {
+	if (m|(.*/([^/]*)\.ko):|) {
+	  my ($path, $module) = ($1, $2);
+	  $module =~ s/-/_/g;
+	  $module_paths{$module} = $path;
+	}
+      }
+      close(DEP);
+      open(MODULES, '</proc/modules') or last FIRMWARE_CHECK;
+      while (<MODULES>) {
+	s/ .*//s;
+	my $module = $_;
+	my $module_path = $module_paths{$module};
+	if (defined($module_path)) {
+	  my $first = 1;
+	  open(MODINFO,
+	       "modinfo -F firmware '$modules_base/$version/$module_path' |");
+	  while (<MODINFO>) {
+	    chomp;
+	    my $firmware = $_;
+	    unless (-e "/lib/firmware/$firmware" ||
+		    -e "/lib/firmware/$version/$firmware") {
+	      if ($first) {
+		$missing .= "\\n" if $missing ne '';
+		$missing .= "$module: ";
+		$first = 0;
+	      } else {
+		$missing .= ', ';
+	      }
+	      $missing .= $firmware;
+	    }
+	  }
+	  close(MODINFO);
+	}
+      }
+      close(MODULES);
+
+      if ($missing ne '') {
+	my ($ret, $seen);
+	my $text = "${package_name}/postinst/missing-firmware-${version}";
+
+	($ret, $seen) = subst($text, 'runningversion', $running_version);
+	die "Error setting debconf substitutions in $text: $seen" if $ret;
+
+	($ret, $seen) = subst($text, 'version', $version);
+	die "Error setting debconf substitutions in $text: $seen" if $ret;
+
+	($ret, $seen) = subst($text, 'missing', $missing);
+	die "Error setting debconf substitutions in $text: $seen" if $ret;
+
+	($ret, $seen) = input('high', $text);
+	if ($ret && $ret != 30) {
+	  die "Error setting debconf question $text: $seen";
+	}
+
+	($ret, $seen) = go();
+	if ($ret && $ret != 30) {
+	  die "Error asking debconf question $text: $seen";
+	}
+      }
+    }
+  }
 }
 
 

Modified: dists/trunk/linux-2.6/debian/templates/temp.image.plain/templates
==============================================================================
--- dists/trunk/linux-2.6/debian/templates/temp.image.plain/templates	Thu Aug 20 00:34:40 2009	(r14144)
+++ dists/trunk/linux-2.6/debian/templates/temp.image.plain/templates	Thu Aug 20 02:22:34 2009	(r14145)
@@ -91,3 +91,17 @@
  .
  It is highly recommended to abort the kernel removal unless you are
  prepared to fix the system after removal.
+
+Template: =ST-image-=V/postinst/missing-firmware-=V
+Type: note
+Description: Required firmware files may be missing
+ This system is currently running Linux ${runningversion} and you are
+ installing Linux ${version}.  In the new version some of the drivers
+ used on this system may require additional firmware files:
+ .
+ ${missing}
+ .
+ Most firmware files are not included in the Debian system because
+ no source code is available for them.  You may need to reconfigure
+ the package manager to include the non-free section of the Debian
+ archive before you can install these firmware files.



More information about the Kernel-svn-changes mailing list