Transfer installed software

Category: 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
fromapt.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)

 
  1. Miles Davidian

    Saturday, 24-11-07 16:52

    I got a :

    fromapt.progress import OpProgress
    ^
    SyntaxError: invalid syntax

    What does happen ?
  2. Neil Greenwood

    Wednesday, 07-11-07 12:37

    I think there's a bug in the script, which is causing the reported problems.

    if pkg.CurrentVer != None and depcache.IsAutoInstalled(pkg):

    should be

    if pkg.CurrentVer != None and !depcache.IsAutoInstalled(pkg):

    shouldn't it? Otherwise you're only displaying the automatically installed packages.
  3. Fred Fred

    Monday, 05-11-07 21:43

    @Sebastian Heinlein :
    I am also seeing the problem reported by beerfan and I am using a fresh install of Gutsy (not an upgrade).
  4. Sebastian Heinlein

    Monday, 05-11-07 05:31

    @beerfan:

    perhaps you have upgraded your system from an older version of ubuntu. all packages that have been installed pre-feisty are marked as manually installed.
  5. Lord of the Universe

    Monday, 05-11-07 00:01

    Johan Svedberg: that's what I checked in to say, but you forgot "apt-get dselect-upgrade" as the last step.
1 2 3 Next
 

CAPTCHA image for SPAM prevention