[Bug 1803805] Re: grub-pc fails to install on the last of multiple devices

Bug Watch Updater 1803805 at bugs.launchpad.net
Sat Nov 17 07:49:01 UTC 2018


** Changed in: grub2 (Debian)
       Status: Unknown => New

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to grub2 in Ubuntu.
https://bugs.launchpad.net/bugs/1803805

Title:
  grub-pc fails to install on the last of multiple devices

Status in grub2 package in Ubuntu:
  New
Status in grub2 package in Debian:
  New

Bug description:
  When installing grub-pc to multiple devices, it fails installing on
  the last device. For the failing device, all of the errors show a
  stray comma at the end of the device name.

  This is occurring because install_devices is a multiselect, and the
  results are separated by commas. There is a comma at the end too. This
  ends up being interpreted as part of the device name. The package has
  code to remove the commas in the middle, but it does not remove the
  comma at the end.

  To reproduce this after the first failure, I had to do this (where that device is the _last_ device, on which the install is failing):
  grub-install /dev/disk/by-id/ata-ST4000NM0035-1V4107_ZC18GCZ3 && DEBCONF_DEBUG=developer dpkg-reconfigure grub-pc

  In the installed package's grub-pc.postinst, or the source package's debian/postinst.in, this is the code in question (indentation reduced 8 spaces):
      failed_devices=
      for i in `echo $RET | sed -e 's/, / /g'` ; do
        real_device="$(readlink -f "$i")"
        if grub-install --target=i386-pc --force --no-floppy $real_device ; then
          # We just installed GRUB 2; then also generate grub.cfg.
          touch /boot/grub/grub.cfg
        else
          failed_devices="$failed_devices $real_device"
        fi
      done

  For testing, I added a couple of echo statements:
       failed_devices=
  +    echo RET: $RET
       for i in `echo $RET | sed -e 's/, / /g'` ; do
         real_device="$(readlink -f "$i")"
  +      echo REAL: $real_device
         if grub-install --target=i386-pc --force --no-floppy $real_device ; then
           # We just installed GRUB 2; then also generate grub.cfg.
           touch /boot/grub/grub.cfg
         else
           failed_devices="$failed_devices $real_device"
         fi
       done

  This is the output:

  debconf (developer): <-- GET grub-pc/install_devices
  debconf (developer): --> 0 /dev/disk/by-id/ata-ST4000NM0035-1V4107_ZC18FT84, /dev/disk/by-id/ata-ST4000NM0035-1V4107_ZC18GPPQ, /dev/disk/by-id/ata-ST4000NM0035-1V4107_ZC18GCZ3,
  RET: /dev/disk/by-id/ata-ST4000NM0035-1V4107_ZC18FT84, /dev/disk/by-id/ata-ST4000NM0035-1V4107_ZC18GPPQ, /dev/disk/by-id/ata-ST4000NM0035-1V4107_ZC18GCZ3,
  REAL: /dev/sdb
  Installing for i386-pc platform.
  Installation finished. No error reported.
  REAL: /dev/sdc
  Installing for i386-pc platform.
  Installation finished. No error reported.
  REAL: /dev/disk/by-id/ata-ST4000NM0035-1V4107_ZC18GCZ3,
  Installing for i386-pc platform.
  grub-install: error: cannot find a GRUB drive for /dev/disk/by-id/ata-ST4000NM0035-1V4107_ZC18GCZ3,.  Check your device.map.
  debconf (developer): <-- SUBST grub-pc/install_devices_failed FAILED_DEVICES  /dev/disk/by-id/ata-ST4000NM0035-1V4107_ZC18GCZ3,

  The issue is definitely the comma at the end.

  To fix the issue, I changed the sed line to be like this:
      for i in `echo $RET | sed -e 's/,\( \|$\)/ /g'` ; do

  This strips the comma at the end, not just those in the middle (commas
  followed by spaces).

  Alternatively, if you prefer sed -E instead of backslashes for parens, this also works:
      for i in `echo $RET | sed -E 's/,( |$)/ /g'` ; do
  or if -e is important, this also works:
      for i in `echo $RET | sed -Ee 's/,( |$)/ /g'` ; do

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1803805/+subscriptions



More information about the foundations-bugs mailing list