5

I want to install to PC2 all the packages, that were installed by apt install on PC1. That is for Debian, but i think that since Debian and Ubuntu share same package system - the solution would be same. How to do that?

xakepp35
  • 307
  • What Ubuntu version are you referencing? What package manager are you using? – Zeiss Ikon Nov 13 '18 at 13:55
  • @ZeissIkon Package manager is apt. Version is not of importance, in context of question, lets take some generic latest version. – xakepp35 Nov 13 '18 at 13:56
  • 3
    A more "apt" place to ask is https://unix.stackexchange.com. – DK Bose Nov 13 '18 at 14:03
  • @WinEunuuchs2Unix Answer could be used, but question posted in another format. I wanted not to "migrate my WHOLE old system to new laptop" but rather to just deploy some software (all bins/libs, installed on a reference machine) across several (hundred) same workstations. – xakepp35 Nov 13 '18 at 16:19
  • @xakepp35 The basic tenants of exporting list of installed applications and reading that list to install on other machines still holds true. Often times differently worded questions are marked as duplicates when the duplicate's answers can be used. – WinEunuuchs2Unix Nov 13 '18 at 16:40

1 Answers1

5

First, make sure that /etc/apt/sources.list and /etc/apt/sources.list.d on PC2 are equal to those on PC1.

Then, on PC1, do

dpkg --get-selections > installed-packages
apt-key exportall > repo-keys

Transfer the files installed-packages and repo-keys to PC2, and do

sudo apt-get install dselect
sudo apt-key add repo-keys
sudo dpkg --set-selections < installed-packages
sudo apt-get dselect-upgrade -y

If you don't have any packages installed from PPA's you can skip the repo-keys commands.

Disclaimer: this used to work a few years ago, I haven't had the need to try it recently.

Jos
  • 29,224
  • What would happen, if some packages were installed offline, by dpkg -i super_private_nda_package.deb? Would a whole install fail? Or just that packages skipped? Or that packages with their dependencies? – xakepp35 Nov 13 '18 at 14:15
  • I believe super_private_nda_package would also end up in installed-packages. – Jos Nov 13 '18 at 14:18
  • I mean dselect-upgrade - would command fail when it determines that super_private does not exists? Or would it just skip that and install everything else? there are several possible behaviours, when you meet an error: rollback everything(as command never happened), stop at error(every package berore surer_ is installed, every package after it is not), or ignore error (every package, but super_ and its deps is installed) – xakepp35 Nov 13 '18 at 14:22
  • 1
    On PC2 the apt-get dselect-upgrade is basically an apt install [list of packages...], which checks if it can find all packages mentioned. If not, it stops and will not install anything. – Jos Nov 13 '18 at 14:25
  • So nothing would be installed, if some package on list "does not exist" (either sources.list differs, either package was downloaded offline and manually installed) Right? – xakepp35 Nov 13 '18 at 14:26
  • I think so, yes. – Jos Nov 13 '18 at 14:55