Aeris
Aeris

Reputation: 347

How to install .deb with dpkg non-interactively?

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?

Upvotes: 9

Views: 13914

Answers (3)

Ravikumar Kumarasamy
Ravikumar Kumarasamy

Reputation: 59

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

Upvotes: 1

tripleee
tripleee

Reputation: 189307

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.

Upvotes: 9

hek2mgl
hek2mgl

Reputation: 157927

You can pipe yes into it:

yes | dpkg -i package.deb

man yes

Upvotes: 16

Related Questions