[Fai-commit] r5845 - branches/experimental/patches
Julien Blache
jblache at alioth.debian.org
Wed Jul 7 16:01:50 UTC 2010
Author: jblache
Date: 2010-07-07 16:01:46 +0000 (Wed, 07 Jul 2010)
New Revision: 5845
Added:
branches/experimental/patches/device2grub_stable_names
Modified:
branches/experimental/patches/series
Log:
Patch device2grub to use stable names (by-id) if needed.
Added: branches/experimental/patches/device2grub_stable_names
===================================================================
--- branches/experimental/patches/device2grub_stable_names (rev 0)
+++ branches/experimental/patches/device2grub_stable_names 2010-07-07 16:01:46 UTC (rev 5845)
@@ -0,0 +1,48 @@
+2010-07-07 Julien BLACHE <jblache at debian.org>
+ * bin/device2grub: try to find and use a stable name (by-id) for the
+ device if the shortname has no match in device.map. Needed now that
+ grub2 in unstable has switched to using stable names in device.map.
+Index: trunk/bin/device2grub
+===================================================================
+--- trunk.orig/bin/device2grub 2010-07-07 17:58:55.160374252 +0200
++++ trunk/bin/device2grub 2010-07-07 17:58:46.200397745 +0200
+@@ -5,11 +5,15 @@
+ # TODO: read from stdin if no parameter given
+
+ use strict;
++
++use Cwd 'abs_path';
++
+ my $grubdevice;
+ my %map;
+
+ my $device=shift;
+ my $devicemap="$ENV{target}/boot/grub/device.map";
++my $devbyid = "/dev/disk/by-id";
+
+ open (DEVICEMAP,"<$devicemap") || die "Can't open $devicemap\n";
+ while (<DEVICEMAP>) {
+@@ -23,7 +27,22 @@
+ if ($map{$disk}) {
+ $grubdevice=$map{$disk};
+ } else {
+- die "No match in $devicemap for $disk\n";
++ opendir (my $dh, $devbyid) || die "Can't open /dev/disk/by-id\n";
++ while (my $diskid = readdir $dh) {
++ next if ($diskid =~ /[.].*/);
++
++ $diskid = $devbyid . "/" . $diskid;
++
++ my $shortdev = abs_path($diskid);
++
++ if (($shortdev eq $disk) && $map{$diskid}) {
++ $grubdevice = $map{$diskid};
++ last;
++ }
++ }
++ closedir $dh;
++
++ die "No match in $devicemap for $disk\n" unless $grubdevice;
+ }
+
+ if ($partition) {
Modified: branches/experimental/patches/series
===================================================================
--- branches/experimental/patches/series 2010-07-07 12:19:18 UTC (rev 5844)
+++ branches/experimental/patches/series 2010-07-07 16:01:46 UTC (rev 5845)
@@ -24,3 +24,4 @@
setup-storage_extended-is-not-last
setup-storage_exit-codes
setup-storage_no-useless-rebuild
+device2grub_stable_names
More information about the Fai-commit
mailing list