[kernel] r15912 - dists/sid/linux-2.6/debian

Ben Hutchings benh at alioth.debian.org
Sun Jun 27 01:02:58 UTC 2010


Author: benh
Date: Sun Jun 27 01:02:45 2010
New Revision: 15912

Log:
linux-base: If the disk ID update process fails, give the user a chance to retry or change their answers (Closes: #585609)

Modified:
   dists/sid/linux-2.6/debian/changelog
   dists/sid/linux-2.6/debian/linux-base.postinst
   dists/sid/linux-2.6/debian/linux-base.templates

Modified: dists/sid/linux-2.6/debian/changelog
==============================================================================
--- dists/sid/linux-2.6/debian/changelog	Sun Jun 27 00:08:57 2010	(r15911)
+++ dists/sid/linux-2.6/debian/changelog	Sun Jun 27 01:02:45 2010	(r15912)
@@ -36,6 +36,8 @@
   * Enable IPv6 support for IPVS (IP_VS_IPV6) (Closes: #584549)
   * Revert "tpm: autoload tpm_tis based on system PnP IDs", included in
     stable 2.6.32.12 (Closes: #584273)
+  * linux-base: If the disk ID update process fails, give the user a
+    chance to retry or change their answers (Closes: #585609)
 
   [ Aurelien Jarno ]
   * [sh4] fix sh_tmu clocksource following recent nohz changes.

Modified: dists/sid/linux-2.6/debian/linux-base.postinst
==============================================================================
--- dists/sid/linux-2.6/debian/linux-base.postinst	Sun Jun 27 00:08:57 2010	(r15911)
+++ dists/sid/linux-2.6/debian/linux-base.postinst	Sun Jun 27 01:02:45 2010	(r15912)
@@ -24,38 +24,10 @@
 use POSIX ();
 use UUID;
 
-# Since debconf clients get their standard input and output redirected
-# to the debconf front-end, we need to redirect them again before
-# running any other program.
-sub _system {
-    my $pid = fork();
-    die "$!" unless defined($pid);
-    if ($pid == 0) {
-       # </dev/null
-       POSIX::close(0);
-       POSIX::open('/dev/null', POSIX::O_RDONLY) or die "$!";
-       # >&2
-       POSIX::dup2(2, 1) or die "$!";
-       exec(@_);
-       exit(255); # usual exit code for failed exec
-    } else {
-       waitpid($pid, 0);
-       # The built-in system() function does this substitution
-       if (POSIX::WIFEXITED($?) && POSIX::WEXITSTATUS($?) == 255) {
-	   return -1;
-       } else {
-	   return $?;
-       }
-    }
-}
-
 package DebianKernel::DiskId;
 
 ### utility
 
-# Import _system() function
-*_system = \&main::_system;
-
 sub id_to_path {
     my ($id) = @_;
     $id =~ m|^/|
@@ -347,7 +319,7 @@
 }
 
 sub grub1_post {
-    _system('update-grub');
+    system('update-grub');
 }
 
 ### GRUB 2 config
@@ -384,7 +356,7 @@
 }
 
 sub grub2_post {
-    _system('grub-mkconfig', '-o', '/boot/grub/grub.cfg');
+    system('grub-mkconfig', '-o', '/boot/grub/grub.cfg');
 }
 
 ### LILO
@@ -553,13 +525,13 @@
 }
 
 sub lilo_post {
-    _system('lilo');
+    system('lilo');
 }
 
 ### SILO
 
 sub silo_post {
-    _system('silo');
+    system('silo');
 }
 
 ### ELILO
@@ -576,7 +548,7 @@
 }
 
 sub elilo_post {
-    _system('elilo');
+    system('elilo');
 }
 
 ### extlinux
@@ -639,7 +611,7 @@
 }
 
 sub extlinux_post {
-    _system('update-extlinux');
+    system('update-extlinux');
 }
 
 # udev persistent-cd
@@ -1038,40 +1010,40 @@
 
 sub ext2_set_label {
     my ($bdev, $label) = @_;
-    _system('tune2fs', '-L', $label, $bdev) == 0 or die "tune2fs failed: $?";
+    system('tune2fs', '-L', $label, $bdev) == 0 or die "tune2fs failed: $?";
 }
 sub ext2_set_uuid {
     my ($bdev, $uuid) = @_;
-    _system('tune2fs', '-U', $uuid, $bdev) == 0 or die "tune2fs failed: $?";
+    system('tune2fs', '-U', $uuid, $bdev) == 0 or die "tune2fs failed: $?";
 }
 
 sub jfs_set_label {
     my ($bdev, $label) = @_;
-    _system('jfs_tune', '-L', $label, $bdev) == 0 or die "jfs_tune failed: $?";
+    system('jfs_tune', '-L', $label, $bdev) == 0 or die "jfs_tune failed: $?";
 }
 sub jfs_set_uuid {
     my ($bdev, $uuid) = @_;
-    _system('jfs_tune', '-U', $uuid, $bdev) == 0 or die "jfs_tune failed: $?";
+    system('jfs_tune', '-U', $uuid, $bdev) == 0 or die "jfs_tune failed: $?";
 }
 
 sub fat_set_label {
     my ($bdev, $label) = @_;
-    _system('dosfslabel', $bdev, $label) == 0 or die "dosfslabel failed: $?";
+    system('dosfslabel', $bdev, $label) == 0 or die "dosfslabel failed: $?";
 }
 
 sub ntfs_set_label {
     my ($bdev, $label) = @_;
-    _system('ntfslabel', $bdev, $label) == 0 or die "ntfslabel failed: $?";
+    system('ntfslabel', $bdev, $label) == 0 or die "ntfslabel failed: $?";
 }
 
 sub reiserfs_set_label {
     my ($bdev, $label) = @_;
-    _system('reiserfstune', '--label', $label, $bdev)
+    system('reiserfstune', '--label', $label, $bdev)
 	or die "reiserfstune failed: $?";
 }
 sub reiserfs_set_uuid {
     my ($bdev, $uuid) = @_;
-    _system('reiserfstune', '--uuid', $uuid, $bdev)
+    system('reiserfstune', '--uuid', $uuid, $bdev)
 	or die "reiserfstune failed: $?";
 }
 
@@ -1135,16 +1107,16 @@
 
 sub ufs_set_label {
     my ($bdev, $label) = @_;
-    _system('tunefs.ufs', '-L', $label, $bdev) or die "tunefs.ufs failed: $?";
+    system('tunefs.ufs', '-L', $label, $bdev) or die "tunefs.ufs failed: $?";
 }
 
 sub xfs_set_label {
     my ($bdev, $label) = @_;
-    _system('xfs_admin', '-L', $label, $bdev) or die "xfs_admin failed: $?";
+    system('xfs_admin', '-L', $label, $bdev) or die "xfs_admin failed: $?";
 }
 sub xfs_set_uuid {
     my ($bdev, $uuid) = @_;
-    _system('xfs_admin', '-U', $uuid, $bdev) or die "xfs_admin failed: $?";
+    system('xfs_admin', '-U', $uuid, $bdev) or die "xfs_admin failed: $?";
 }
 
 my %filesystem_types = (
@@ -1431,9 +1403,42 @@
     }
 }
 
+sub update_all {
+    # The update process may be aborted if a command fails, but we now
+    # want to recover and ask the user what to do.  We can use 'do' to
+    # prevent 'die' from exiting the process, but we also need to
+    # capture and present error messages using debconf as they may
+    # otherwise be hidden.  Therefore, we fork and capture stdout and
+    # stderr from the update process in the main process.
+    my $pid = open(PIPE, '-|');
+    return (-1, '') unless defined $pid;
+
+    if ($pid == 0) {
+	# Complete redirection
+	# </dev/null
+	POSIX::close(0);
+	POSIX::open('/dev/null', POSIX::O_RDONLY) or die "$!";
+	# 2>&1
+	POSIX::dup2(1, 2) or die "$!";
+
+	# Do the update
+	set_new_ids();
+	update_config(@_);
+	exit;
+    } else {
+	my @output = ();
+	while (<PIPE>) {
+	    push @output, $_;
+	}
+	close(PIPE);
+	return ($?, join('', @output));
+    }
+}
+
 sub transition {
     use Debconf::Client::ConfModule ':all';
 
+retry:
     %bdev_map = ();
     %id_map = ();
 
@@ -1520,8 +1525,30 @@
 	die "Error retrieving answer for $question: $answer" if $ret;
     
 	if ($answer eq 'true') {
-	    set_new_ids();
-	    update_config(\%update_map, @auto_configs);
+	    my ($rc, $output) = update_all(\%update_map, @auto_configs);
+	    if ($rc != 0) {
+		# Display output of update commands
+		$question = 'linux-base/disk-id-update-failed';
+		$output =~ s/\n/\\n/g;
+		($ret, $seen) = subst($question, 'output', $output);
+		die "Error setting debconf substitutions in $question: $seen"
+		    if $ret;
+		($ret, $seen) = input('high', $question);
+		if ($ret && $ret != 30) {
+		    die "Error setting debconf question $question: $seen";
+		}
+		($ret, $seen) = go();
+		if ($ret && $ret != 30) {
+		    die "Error asking debconf question $question: $seen";
+		}
+
+		# Mark previous questions as unseen
+		fset('linux-base/disk-id-convert-auto', 'seen', 'false');
+		fset('linux-base/disk-id-convert-plan', 'seen', 'false');
+		fset('linux-base/disk-id-convert-plan-no-relabel', 'seen',
+		     'false');
+		goto retry;
+	    }
 	}
     }
 

Modified: dists/sid/linux-2.6/debian/linux-base.templates
==============================================================================
--- dists/sid/linux-2.6/debian/linux-base.templates	Sun Jun 27 00:08:57 2010	(r15911)
+++ dists/sid/linux-2.6/debian/linux-base.templates	Sun Jun 27 01:02:45 2010	(r15912)
@@ -74,3 +74,14 @@
  You should generally identify these devices by UUID or
  label. However, on MIPS systems the root device must be identified by
  name.
+
+Template: linux-base/disk-id-update-failed
+Type: error
+# Not yet translated
+Description: Failed to update disk device IDs
+ An error occurred while attempting to update the system configuration:
+ .
+ ${output}
+ .
+ You can either correct this error and retry the automatic update,
+ or choose to update the system configuration yourself.



More information about the Kernel-svn-changes mailing list