Unattended grub-pc update
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.
Solution 1:
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.