Hi,

grub2 in unstable has switched to using stable names (/dev/disk/by-id)
instead of unstable short names (/dev/sdX) and device2grub needs to be
updated for that.

The attached patch does just that, it tries to find a stable name for
the device if the short name couldn't be matched to anything from grub's
device.map.

I wasn't sure if I should just go ahead and commit that to experimental,
let me know.

JB.

-- 
 Julien BLACHE <jbla...@debian.org>  |  Debian, because code matters more 
 Debian & GNU/Linux Developer        |       <http://www.debian.org>
 Public key available on <http://www.jblache.org> - KeyID: F5D6 5169 
 GPG Fingerprint : 935A 79F1 C8B3 3521 FD62 7CC7 CD61 4FD7 F5D6 5169 

diff -ru a/bin/device2grub b/bin/device2grub
--- a/bin/device2grub	2010-07-05 09:50:52.000000000 +0200
+++ b/bin/device2grub	2010-07-05 09:49:53.000000000 +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) {

Reply via email to