[SOLVED] Installing same packages on 2 systems

I have just installed ubuntu mate on a mac intel.

I would like to install all the packages i have on my other pc, is there an automated way to do so?

i have tried dpkg --get-selections > selections.txt on my pc,

then on the mac intel

dpkg --set-selections < selections.txt

i get only errors package not found in the state database and not avaible or so (in italian, sorry pacchetto non presente nel database di stato nè di disponibilità)

Thank you in advance.

The last post in the following thread is a real gem:
https://ubuntuforums.org/showthread.php?t=2355157&page=2
The code (python3) from the post really works.

#!/usr/bin/env python3

import subprocess, re

def run(*args, **kwargs):
  return str(subprocess.check_output(*args, **kwargs), 'utf_8')

def getManualPkgs():
  installerPkgs=run(['zcat', '/var/log/installer/initial-status.gz']).split('\n')
  manualPkgs=run(['apt-mark', 'showmanual']).split('\n')
  for raw_line in installerPkgs:
    if not(raw_line.startswith('Package:')): continue
    line=re.sub(r'^Package:\s*', '', raw_line, flags=re.I)
    if line in manualPkgs: manualPkgs.remove(line)

  return manualPkgs

if __name__ == '__main__':
  print('\n'.join(getManualPkgs()))

Save it, say to lstpkg.py file, run it like
python3 lstpkg.py > my-packages.txt and get the list of your manually installed packages in the mentioned text file.

To install them from the list try some of the methods discussed here:

1 Like

Thank you!!

Also

$ sudo apt-get install $(dpkg --get-selections |grep -v deinstall |grep install |cut -f1)

seems to do the moreless the same.

You are welcome!

Not that simple, I'm afraid, for dpkg --get-selections |grep -v deinstall |grep install |cut -f1 returns exactly what apt-mark showmanual does. And the list contains a lot of packages belonging to the system itself, say xorg, xserver, etc.

Cited script strips down system packages from the list using /var/log/installer/initial-status.gz as the reference.

Sorry for the late reply, tried thank you it has worked fine (with apt install and the list obtained with the python script)