7

I would like to know how to update grub-pc on a ubuntu 10.04 derivative distro without the configure grub-pc ncurses based dialog. I have tried examining debconf-get-selections before and after as well as variations on:

apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes -fuy install grub-pc

as well as setting DEBIAN_FRONTEND:

export DEBIAN_FRONTEND=noninteractive

All to no avail, what I wish to do is to keep the local version of the configuration file and use this code in a script for offline installation.

fecko2130
  • 73
  • 1
  • 3

1 Answers1

6

you can pre-load debconf answer with 'debconf-set-selections'

first, install debconf-utils on a host that already has grub-pc installed. then run:

debconf-get-selections | grep grub-pc > /tmp/grubpc.debconf

you'll have a file that looks something like this:

grub-pc grub2/kfreebsd_cmdline  string
grub-pc grub2/device_map_regenerated    note
grub-pc grub2/linux_cmdline     string
grub-pc grub-pc/install_devices_failed  boolean false
grub-pc grub-pc/chainload_from_menu.lst boolean true
grub-pc grub-pc/kopt_extracted  boolean true
grub-pc grub-pc/postrm_purge_boot_grub  boolean false
grub-pc grub2/kfreebsd_cmdline_default  string  quiet
grub-pc grub2/linux_cmdline_default     string
grub-pc grub-pc/install_devices_empty   boolean false
grub-pc grub-pc/install_devices multiselect     /dev/sda
grub-pc grub-pc/install_devices_failed_upgrade  boolean true
grub-pc grub-pc/install_devices_disks_changed   multiselect     /dev/sda
grub-pc grub-pc/mixed_legacy_and_grub2  boolean true

Next, edit /tmp/grubpc.debconf to suit the new system. In particular, the grub-pc/install_devices entry.

You won't need all of those entries. My guess is that for grub-pc, you probably only need the install_devices and linux_cmdline* entries, and (if you previously had grub-legacy installed) maybe the chainload_from_menu.lst entry.

Once you have edited the file, scp it to the remote machine and feed it into debconf-set-selections.

You should now be able to remotely install grub-pc without a debconf dialog.

[ later ]

The grub-pc package depends on ucf, which provides the same sort of conffile management for files owned/created by a package that aren't listed as a conffile.

On all systems I've checked so far, /var/lib/ucf/cache/ contains a file called :etc:default:grub so that's a likely candidate for causing this.

try uncommenting the 'conf_force_conffold=YES' line in /etc/ucf.conf on the target machine. this could be automated for bulk upgrading many machines, of course, with scp or sed (There doesn't seem to be a debconf entry for this).

if this is what's causing it, the fact that it's ignoring your DEBIAN_FRONTEND=noninteractive setting may require a bug report. looking at the scripts, both debconf and ucf seem to use a DEBIAN_HAS_FRONTEND env var (but i'm not sure if it's meant to be user-definable or used internally. it's not mentioned in the man pages).

It may also be a bug that ucf doesn't inherit the dpkg --force-confold setting you specified...but there may be no way for ucf to know about that.

cas
  • 6,783
  • 32
  • 35
  • I would agree I would think that would work, but if you read my original post you will see I said I "examining debconf-get-selections before and after" installation of the new version of grub-pc. Debconf-set-selections doesn't work in this case. What I am trying to do is write a script which will update Bodhi linux 1.1 to Bodhi linux 1.2. Bodhi 1.1 already has grub-pc installed (version 1.98-lubuntu10) while to update to bodhi 1.2 installs version 1.98-lubuntu12. – fecko2130 Sep 12 '11 at 15:36
  • ok, what exact question is being asked during the upgrade? BTW, that does work in the general case - by coincidence I used the technique only a few hours before i saw your question, using pdsh to batch-install ocsinventory-agent onto a bunch of workstations, vms, and servers. There must be something specific being asked by the grub-pc upgrade. – cas Sep 12 '11 at 21:51
  • The debian package of grub-pc depends on ucf, so I'll assume that ubuntu and bohdi packages do to :). it might not be debconf that's asking the question, but ucf instead. see the conf_force_conffold option in /etc/ucf.conf in particular. – cas Sep 12 '11 at 21:55
  • Great, the ucf.conf option conf_force_conffold fixes the issue. Much Thanks for your insight :) And for the record the question being ask was 'A new version of configuration file /etc/default/grub is available, but the version installed currently has been locally modified. What do you want to do about the modified configuration file?' – fecko2130 Sep 13 '11 at 13:42