E
E
Evgeny Vorobyov2020-12-03 16:37:43
Debian
Evgeny Vorobyov, 2020-12-03 16:37:43

How to import and export the configuration of installed packages (with a caveat)?

Good afternoon, comrades.
Debian 9.
Please help me write the script. It is necessary to merge the list of installed packages from the server, but this must be done in a tricky way. On the server, some packages are installed locally from deb files and cannot be installed from the repositories (in particular, the tricky version of postgresql). Their installed versions are pinned.
dpkg --get-selections and dpkg --set-selections are not very suitable because of this. How can a set of apt packages be ported to a new system, properly installing certain versions of them from a local source?
As an option, I’m thinking ... you can somehow import packages via --set-selection, but specifying the folder with deb files as a priority, so that dpkg first of all goes through the packages from there, and only then (if there are no necessary ones) install them from the repositories ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Yuriev, 2020-12-03
@astrave

your question already has the answer.
if you don’t know how the priorities of the repositories are configured, then it is configured in the /etc/apt/preferences file , read here
to create your own local / network repository, there are a bunch of solutions that it’s too lazy to remember all of them. I like aptly ( article on Habré )
UPD:
export via dpkg :

not the correct option
dpkg --get-selections | grep -v deinstall > list.txt
dpkg --get-selections|grep -v deinstall|awk '{print $1}' > list.txt

import through apt (otherwise my advice with apt settings will be inappropriate):
apt install -y $(< list.txt)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question