Transfer installed software

November 4, 2007 - 1 minute read -
Free/Libre and Open Source Software Ubuntu

If you want to install the same packages that already have been installed on another system the following small script (export_list.py) could be of help:

#!/usr/bin/env python
import apt_pkg
from apt.progress import OpProgress

progress = OpProgress()
cache = apt_pkg.GetCache(progress)
depcache = apt_pkg.GetDepCache(cache)

for pkg in cache.Packages:
    if pkg.CurrentVer != None and depcache.IsAutoInstalled(pkg):
        print pkg.Name

It prints the names of all packages that have been installed explicitly and not as a dependency. It seems to be more elegant than just copying the dpkg selections.

Save the script to export_list.py and run it on the original system to create the list:

python export_list.py | xargs > list

Copy the list file to the new system and run the following command:

sudo apt-get install $(cat list)