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
1=== modified file 'add-apt-repository'
2--- add-apt-repository 2010-03-26 10:18:47 +0000
3+++ add-apt-repository 2010-07-16 12:12:43 +0000
4@@ -6,6 +6,8 @@
5 import locale
6
7 from softwareproperties.SoftwareProperties import SoftwareProperties
8+from softwareproperties.ppa import expand_ppa_line
9+from aptsources.sourceslist import SourceEntry
10 from optparse import OptionParser
11 from gettext import gettext as _
12
13@@ -24,6 +26,9 @@
14 parser = OptionParser(usage)
15 # FIXME: provide a --sources-list-file= option that
16 # puts the line into a specific file in sources.list.d
17+ parser.add_option("-r", "--remove", action="store_true",
18+ dest="remove", default=False,
19+ help="remove repository from sources.list.d directory")
20 (options, args) = parser.parse_args()
21
22 if os.geteuid() != 0:
23@@ -37,9 +42,17 @@
24 # force new ppa file to be 644 (LP: #399709)
25 os.umask(0022)
26
27- sp = SoftwareProperties(options)
28+ sp = SoftwareProperties()
29 line = args[0]
30- if not sp.add_source_from_line(line):
31- print _("Error: '%s' invalid" % line)
32- sys.exit(1)
33- sp.sourceslist.save()
34+ if options.remove:
35+ (line, file) = expand_ppa_line(line.strip(), sp.distro.codename)
36+ source_entry = SourceEntry(line, file)
37+ try:
38+ sp.remove_source(source_entry)
39+ except ValueError:
40+ print _("Error: '%s' doesn't exists in a sourcelist file" % line)
41+ else:
42+ if not sp.add_source_from_line(line):
43+ print _("Error: '%s' invalid" % line)
44+ sys.exit(1)
45+ sp.sourceslist.save()

Subscribers

People subscribed via source and target branches

to status/vote changes: