## Description: add some description ## Origin/Author: add some origin or author ## Bug: bug URL diff -Nur -x '*.orig' -x '*~' software-properties-0.75.10/add-apt-repository software-properties-0.75.10.new/add-apt-repository --- software-properties-0.75.10/add-apt-repository 2010-04-14 14:05:59.000000000 -0500 +++ software-properties-0.75.10.new/add-apt-repository 2010-07-15 20:03:28.375309011 -0500 @@ -6,6 +6,8 @@ import locale from softwareproperties.SoftwareProperties import SoftwareProperties +from softwareproperties.ppa import expand_ppa_line +from aptsources.sourceslist import SourceEntry from optparse import OptionParser from gettext import gettext as _ @@ -24,6 +26,9 @@ parser = OptionParser(usage) # FIXME: provide a --sources-list-file= option that # puts the line into a specific file in sources.list.d + parser.add_option("-r", "--remove", action="store_true", + dest="remove", default=False, + help="remove repository from sources.list.d directory") (options, args) = parser.parse_args() if os.geteuid() != 0: @@ -37,9 +42,17 @@ # force new ppa file to be 644 (LP: #399709) os.umask(0022) - sp = SoftwareProperties(options) + sp = SoftwareProperties() line = args[0] - if not sp.add_source_from_line(line): - print _("Error: '%s' invalid" % line) - sys.exit(1) - sp.sourceslist.save() + if options.remove: + (line, file) = expand_ppa_line(line.strip(), sp.distro.codename) + source_entry = SourceEntry(line, file) + try: + sp.remove_source(source_entry) + except ValueError: + print _("Error: '%s' doesn't exists in a sourcelist file" % line) + else: + if not sp.add_source_from_line(line): + print _("Error: '%s' invalid" % line) + sys.exit(1) + sp.sourceslist.save()