2

After adding some PPAs from Launchpad to my repositiory (add-apt-repository) I want to install them automatically. As far as I know there is no command to install all new PPAs after apt-get update. And I can't run a script installing all new PPAs manually, because the install name of some PPAs differ to the name they have on the launchpad website/API.

9
  • 3
    It is unclear what is "install all PPAs". You can install packages from the connected ppa. Or just run sudo apt-get upgrade to install newer versions of already installed packages.
    – Pilot6
    Oct 6, 2015 at 15:21
  • The normal way to go if you want to install a programm from a PPA, you have to do the following steps: 1. add-apt-repository ppa 2. apt-get update 3. install ppa. But the name which is necessary for the install command can differ from the name given on the launchpad site. That's why a automatic installation of a PPA is not always possible. clear?
    – Maximilian
    Oct 6, 2015 at 15:36
  • There is no action "install ppa". PPA is an archive with packages.
    – Pilot6
    Oct 6, 2015 at 15:37
  • I mean something like the 3. and 4. example here
    – Maximilian
    Oct 6, 2015 at 15:38
  • 1
    A PPA can have many many many packages to install. There's no automatic way to guess which one you might want.
    – ssta
    Oct 6, 2015 at 15:46

1 Answer 1

2

I understand you want to add a PPA to your system and automatically install all packages for your release and architecture that it provides.

Disclaimer: I am absolutely unsure if what you want to do is a good idea. But if you're truly insistent and proceed with caution, be my guest.

The lists of packages that can be installed from a repository are downloaded and stored in

/var/lib/apt/lists/

when apt-get update runs.

Those list files contain in plain text basically the information displayed when you do apt-cache show <package>. In particular each package has a field Package: <name-of-package>

Find here a Python script, that extracts all those Package fields and strings the package names together. Save it as whatever.py and run as ./whatever.py <packagelist>. It will print the appropriate apt-get install command, but does not execute it (it couldn't because you're not running this as root, are you...?). This is up to you, and I strongly suggest you try with -s (simulate) first!

#!/usr/bin/env python

import sys
import re

if len(sys.argv)<2:
        print "Usage: "+sys.argv[0]+" PACKAGELIST"
        quit()

try:
        packages = []
        infile = open(sys.argv[1],'r')
        for line in infile:
                p = re.match(r"Package: (\S+)", line)
                if p:
                        packages.append(p.group(1))
        infile.close()
        print "apt-get install -s "+" ".join(packages)

except IOError:
        print "File "+sys.argv[1]+" not found."

For example:

enter image description here

If this produces truly the result you desire depends on the PPA and the packages in there.

Use at your own risk.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .