Merge lp:~mac9416/software-properties/add-apt-repo-remove-opt into lp:software-properties

Proposed by mac9416
Status: Merged
Merged at revision: 610
Proposed branch: lp:~mac9416/software-properties/add-apt-repo-remove-opt
Merge into: lp:software-properties
Diff against target: 45 lines (+18/-5)
1 file modified
add-apt-repository (+18/-5)
To merge this branch: bzr merge lp:~mac9416/software-properties/add-apt-repo-remove-opt
Reviewer Review Type Date Requested Status
Ubuntu Core Development Team Pending
Review via email: mp+30094@code.launchpad.net

Description of the change

This fixes Bug #446216 by adding a --remove command line option to add-apt-repository.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'add-apt-repository'
--- add-apt-repository 2010-03-26 10:18:47 +0000
+++ add-apt-repository 2010-07-16 12:12:43 +0000
@@ -6,6 +6,8 @@
6import locale6import locale
77
8from softwareproperties.SoftwareProperties import SoftwareProperties8from softwareproperties.SoftwareProperties import SoftwareProperties
9from softwareproperties.ppa import expand_ppa_line
10from aptsources.sourceslist import SourceEntry
9from optparse import OptionParser11from optparse import OptionParser
10from gettext import gettext as _12from gettext import gettext as _
1113
@@ -24,6 +26,9 @@
24 parser = OptionParser(usage)26 parser = OptionParser(usage)
25 # FIXME: provide a --sources-list-file= option that 27 # FIXME: provide a --sources-list-file= option that
26 # puts the line into a specific file in sources.list.d28 # puts the line into a specific file in sources.list.d
29 parser.add_option("-r", "--remove", action="store_true",
30 dest="remove", default=False,
31 help="remove repository from sources.list.d directory")
27 (options, args) = parser.parse_args()32 (options, args) = parser.parse_args()
2833
29 if os.geteuid() != 0:34 if os.geteuid() != 0:
@@ -37,9 +42,17 @@
37 # force new ppa file to be 644 (LP: #399709)42 # force new ppa file to be 644 (LP: #399709)
38 os.umask(0022)43 os.umask(0022)
3944
40 sp = SoftwareProperties(options) 45 sp = SoftwareProperties()
41 line = args[0]46 line = args[0]
42 if not sp.add_source_from_line(line):47 if options.remove:
43 print _("Error: '%s' invalid" % line)48 (line, file) = expand_ppa_line(line.strip(), sp.distro.codename)
44 sys.exit(1)49 source_entry = SourceEntry(line, file)
45 sp.sourceslist.save()50 try:
51 sp.remove_source(source_entry)
52 except ValueError:
53 print _("Error: '%s' doesn't exists in a sourcelist file" % line)
54 else:
55 if not sp.add_source_from_line(line):
56 print _("Error: '%s' invalid" % line)
57 sys.exit(1)
58 sp.sourceslist.save()

Subscribers

People subscribed via source and target branches

to status/vote changes: