How to install .deb with dpkg non-interactively?
Asked Answered
S

3

8

I'm trying to install a .deb file... for example:

example.deb

But the program is already installed in an older version on the Debian minimal server.

So doing dpkg -i example.deb is creating a dialog, if i want to keep the configs... is there any way to do this non-interactive?

Standfast answered 27/7, 2017 at 11:30 Comment(0)
J
15

You can pipe yes into it:

yes | dpkg -i package.deb

man yes

Jeana answered 27/7, 2017 at 11:35 Comment(2)
That's exactly what I was looking for! Thanks :)Standfast
With yes 4 | dpkg -i mysql-apt-config_0.8.13-1_all.deb doesn't works :( Obtain: wget https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.debCheltenham
B
9

You seem to be looking for

dpkg --force-confold -i package.deb

to specify that dpkg should prefer the existing, old configuration files in the case when there is a conflict.

More broadly, the proper solution depends on how desperate you are to avoid interactive prompts, and which prompts precisely you want to avoid.

dpkg has a number of options to select a particular behavior for various types of situations. Refer to its man page; scroll to the section on --force-things; one of them is --force-confold, or conversely --force-confnew to always replace any existing configuration file. (Many modern packages have a facility to upgrade any unchanged configurations completely automatically, but manually changed configuration files still require manual updating or merging.)

If you aren't running dpkg directly, apt and friends allow you to pass options to it with

apt install -o Dpkg::Options::="--force-confold" install package

(Yeah, that's a lot of colons. You probably want install -y to avoid interactive prompting by Apt itself, too.)

Setting the environment variable DEBIAN_FRONTEND to the string noninteractive will make Debconf (the configuration management component of Debian) select the default answer for all questions, and disable any prompting.

If the default answers to a package's configuration questions are not suitable, you can preseed Debconf's configuration database with the settings you want. You'll need to install debconf-utils which contains the utility debconf-set-selections. See further its man page and e.g. some sections of https://wiki.debian.org/DebianInstaller/Preseed (though this is rather focused on preseeding the installer, so you can potentially perform an unattended installation of all of Debian).


The problem with

yes | dpkg -i package.deb

is that you can't exactly predict which prompts are going to be shown, depending on the package's and the hosting system's configuration; you might say yes to something you didn't want to, or perhaps tell the system that your domain name or default database user is yes. Debconf was designed to give you very detailed and, for the most part, very safe and robust control over package installation - use that power.

Bolster answered 21/7, 2020 at 9:48 Comment(0)
L
1

I had same problem with debian 10 image specifically for installing mssql client, I have solved this issue by setting:

ENV ACCEPT_EULA=Y

RUN dpkg --install msodbcsql18_18.2.1.1-1_amd64.deb &&
dpkg --install mssql-tools18_18.2.1.1-1_amd64.deb

Ld answered 31/7, 2023 at 10:54 Comment(2)
The ENV looks like you did this in Docker. The general syntax in the shell would be export ACCEPT_EULA=Y. I would expect this to be extremely specific to just this particular package.Bolster
@Bolster maybe not just to this package, but to a very limited set of packages that actually have any EULA to be accepted - and they can have different ENVs to be set for this purpose - which would still make this extremely specific.Extine

© 2022 - 2025 — McMap. All rights reserved.