Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Per Make apt-get (or aptitude) run with -y but not prompt for replacement of configuration files?

I did the following:

ec2run ami-3c994355 --region us-east-1 -n 1 -t m1.large -z us-east-1d

On the machine:

sudo apt-get update
sudo apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade

I still get a prompt asking me which config file I want to use. These are the lines that come before the prompt:

Setting up grub-pc (1.99-21ubuntu3.1) ...

then:

                         ┌───────────────────────────────────────────────────────┤ Configuring grub-pc ├───────────────────────────────────────────────────────┐                              
                         │ 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 modified configuration file grub?                                                                      │                              
                         │                                                                                                                                     │                              
                         │                                     install the package maintainer's version                                                        │                              

(Unrelated, was this too much information?)

share|improve this question
    
Unsatisfactory workaround: echo grub-pc hold | sudo dpkg --set-selections before first apt-get command –  fratrik Jun 5 '12 at 19:02
    
I get this same issue and have tried many different permutations/spellings of Dpkg::Options::=, none of which have worked. I also tried adding the lines to the /etc/apt/apt.conf.d/local file as indicated, and they did not work either. This seems to be a regression in Precise. –  Scott Ritchie Jun 6 '12 at 1:39
    
+1 - thanks for asking - it was surprisingly easy to find this thread to this annoying problem –  cwd Jun 8 '12 at 17:07

2 Answers 2

up vote 37 down vote accepted

The /etc/default/grub file is generated at package install time, which is necessary because it integrates with debconf. This means that it can not treated as a dpkg conf file, and so dpkg's configuration file handling doesn't know about it.

Instead, it uses ucf, a more sophisticated Debian tool for handling configuration. This, unfortunately, doesn't understand dpkg options, so setting Dpkg::Options::="--force-confdef" won't help. It does have its own way of doing no-prompt upgrades, though, through the UCF_FORCE_CONFFNEW and UCF_FORCE_CONFFOLD environment variables.

ucf uses debconf for prompting, so setting the debconf interface to noninteractive will also silence the message. If you really want non-interactive updates you'll need to do this anyway - arbitrary packages may ask debconf questions (although they generally won't during upgrades).

You can set the debconf interface as a one-off by adding DEBIAN_FRONTEND=noninteractive to your environment, or can set it permanently by running dpkg-reconfigure debconf and selecting the noninteractive frontend. If you're using the noninteractive frontend you'll get the default answer for any questions a package might ask.

For ucf, the default answer is “keep the existing file”.

So, the full command to do a really, 100% guaranteed¹ no-prompting update would be.

sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade

¹: It's technically possible for packages to use another method of prompting than debconf, but this is against Debian policy. If you run across such a package, file a bug.

share|improve this answer
1  
Note that if you are testing this on a shell the sudo command seems to remove the DEBIAN_FRONTEND variable, ie you need sudo DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade whereas DEBIAN_FRONTEND=noninteractive sudo apt-get -y dist-upgrade will fail –  Scott Ritchie Jun 6 '12 at 22:46
    
worked well for me, thankyou –  cwd Jun 8 '12 at 19:05
    
Also note that this is considered a bug and they are releasing new AMI images that should not have this issue: bugs.launchpad.net/ubuntu/+bug/1009294 –  Scott Ritchie Jun 13 '12 at 7:01
    
And the new AMIs are now released. –  Scott Ritchie Jun 27 '12 at 0:39

going off of RAOF's answer and after spending countless hours searching on the web to be able to perform a completely hands-off update & dist-upgrade on Ubuntu 12.04, i came up with this thanks to the fact this post (https://bugs.launchpad.net/ubuntu/+source/grub/+bug/239674/comments/1) points out that grub adheres to UCF and not Dpkg Options when you want to use the package maintainers grub menu.lst instead of any possible local menu.lst edits.

i left the Dpkg force-confnew options in for other packages that aren't grub.

#!/bin/bash

unset UCF_FORCE_CONFFOLD
export UCF_FORCE_CONFFNEW=YES
ucf --purge /boot/grub/menu.lst

export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get -o Dpkg::Options::="--force-confnew" --force-yes -fuy dist-upgrade
share|improve this answer
    
This was the only thing that worked for me. Thanks! –  wes Oct 17 at 21:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.