4

I'm trying to provision a machine using Vagrant and plain bash scripts.

The two lines are:

DEBIAN_FRONTEND=noninteractive apt-get update
DEBIAN_FRONTEND=noninteractive apt-get upgrade -yq

However, it doesn't work as expected:

default: Configuration file '/etc/update-manager/release-upgrades'
default:  ==> Modified (by you or by a script) since installation.
default:  ==> Package distributor has shipped an updated version.
default:    What would you like to do about it ?  Your options are:
default:     Y or I  : install the package maintainer's version
default:     N or O  : keep your currently-installed version
default:       D     : show the differences between the versions
default:       Z     : start a shell to examine the situation
default:  The default action is to keep your current version.
default: 
default: *** release-upgrades (Y/I/N/O/D/Z) [default=N] ? dpkg: error processing package ubuntu-release-upgrader-core (--configure):
default: 
default:  end of file on stdin at conffile prompt

Is there any other option I could use to provide a Y answer to that?

1 Answer 1

4

< Apt 1.1

Try the following command to force upgrade for non-interactive sessions:

DEBIAN_FRONTEND=noninteractive \
        apt-get \
                -o Dpkg::Options::="--force-confnew" \
                --force-yes \
                -fuy \
                dist-upgrade

Note: Use --force-confold to keep old, and --force-confnew to keep new configs.

Source: apt-get -y upgrade for non-interactive sessions - and replacing conf files in /etc.

>= 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:

DEBIAN_FRONTEND=noninteractive \
  apt-get \
  -o Dpkg::Options::=--force-confold \
  -o Dpkg::Options::=--force-confdef \
  -y --allow-downgrades --allow-remove-essential --allow-change-held-packages

Source: CFE-2360: Make apt_get package module version aware.

Related:

1
  • The command as shown, on apt 2.4.10 (ubuntu 22.04) gives an Usage error, I guess because there is no apt-get subcommand? So we should do the above once with "update", and then again the same but with "upgrade" ? Commented Oct 16, 2023 at 12:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .