I need to add a ppa to remote servers using a python script. The bash equivalent of what I want to do is:
$ add-apt-repository ppa:user/ppa-name
I'm assuming it would look something like this:
import apt
cache = apt.Cache()
# ?? add the ppa here ??
cache.update()
cache.open(None)
cache['package_from_ppa'].mark_install()
cache.upgrade()
cache.commit()
but I haven't been able to find much in the apt module source related to adding repositories.
taken from the current (in 11.04 natty) add-apt-repository code:
from softwareproperties.SoftwareProperties import SoftwareProperties
sp = SoftwareProperties()
sp.add_source_from_line(ppa_name)
sp.sourceslist.save()
You should of cause add checks for errors, etc... look at the currently installed version like this:
less `which add-apt-repository`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With