Is there a way to do an apt-get dist-upgrade
in Debian that not only automatically answers "yes" to all questions asked, but also uses reasonable defaults as answers to questions that are sophisticated enough to require various interactive dialog boxes to pop up? I'm thinking here of the keymap stuff that shows up when you upgrade libc6
, and kernel image choices.
The goal is to be able to remotely initiate a rather large dist-upgrade
- even for a machine that is severely behind the times - and not have to babysit it at all, unless something is just horribly, disastrously wrong.
Surely this is possible?
Thanks in advance!
If you set
DEBIAN_FRONTEND=noninteractive
(to stop debconf prompts from appearing) and addforce-confold
andforce-confdef
to your/etc/dpkg/dpkg.cfg
file, you should have a completely noninteractive package installation experience. Any package that still prompts you for information has a release critical bug (and I say that as both an automation junkie and as a Debian developer).Florian Lohoff posted a way to get what womble suggested into a single command:
Of course you might also use
-o Dpkg::Options::="--force-confnew --force-confdef"
(search the the dpkg man page for confnew). I'm not sure in what cases this would make a difference though. I personally need the non-interactive upgrade to bring vanilla images up-to-date, in which case I suppose always picking the new config file (without--force-confdef
) is a reasonable thing.Even though womble's answer above is generally good, it did not work for me and I had to do some additional research to go 100% unattended. I thought I'll share the result in a concise manner to make things simpler for future visitors.
The following is a script that will run according to the debian 8 release notes upgrade recommendations (mostly) along with flags and environment variables that will make it unattended. (the
echo
s are just for debugging and could be removed - though I recommend keeping them so if the script gets stuck you will know where)>= Apt 1.1
If you're using Apt 1.1 or above,
--force-yes
has been deprecated, so you've to use the options starting with--allow
instead, e.g.--allow-downgrades
,--allow-remove-essential
,--allow-change-held-packages
.So the command is:
Note: Use
--force-confold
to keep old, and--force-confnew
to keep new configs.Source: CFE-2360: Make apt_get package module version aware.
Related:
From the
apt-get(8)
man page:For reference, the
-y
option works onyum(8)
as well.