Merge lp:~evfool/software-properties/lp997371 into lp:software-properties

Proposed by Robert Roth
Status: Merged
Merged at revision: 790
Proposed branch: lp:~evfool/software-properties/lp997371
Merge into: lp:software-properties
Diff against target: 95 lines (+32/-3)
2 files modified
add-apt-repository (+27/-1)
debian/manpages/add-apt-repository.1 (+5/-2)
To merge this branch: bzr merge lp:~evfool/software-properties/lp997371
Reviewer Review Type Date Requested Status
Michael Vogt Pending
Review via email: mp+110399@code.launchpad.net

Description of the change

This branch enhances add-apt-repository with the power to enable/disable distribution components (it almost has super-cow powers). As requested in my previous merge, instead of adding a new tool for enable/disable repo, this has been added into the add-apt-repository tool.

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 2012-06-12 09:54:46 +0000
3+++ add-apt-repository 2012-06-14 19:48:20 +0000
4@@ -4,11 +4,14 @@
5 import sys
6 import gettext
7 import locale
8+import re
9
10 from softwareproperties.SoftwareProperties import SoftwareProperties
11 from softwareproperties.ppa import DEFAULT_KEYSERVER, expand_ppa_line
12 from softwareproperties import lp_application_name
13+import aptsources
14 from aptsources.sourceslist import SourceEntry
15+from aptsources.distro import *
16 from optparse import OptionParser
17 from gettext import gettext as _
18 from urllib2 import HTTPError, URLError
19@@ -75,7 +78,7 @@
20 # correctly, see http://bugs.python.org/issue4391
21 # Shoudl be resolved by Python3
22 enc = locale.getpreferredencoding()
23- usage = """Usage: %prog <sourceline>
24+ usage = """Usage: %prog [options] <sourceline>
25
26 %prog is a script for adding apt sources.list entries.
27 It can be used to add any repository and also provides a shorthand
28@@ -86,6 +89,7 @@
29 a complete apt line in quotes,
30 a repo url and areas in quotes (areas defaults to 'main')
31 a PPA shortcut.
32+ a distro component
33
34 Examples:
35 apt-add-repository 'deb http://myserver/path/to/repo stable myrepo'
36@@ -93,6 +97,7 @@
37 apt-add-repository 'https://packages.medibuntu.org free non-free'
38 apt-add-repository http://extras.ubuntu.com/ubuntu
39 apt-add-repository ppa:user/repository
40+ apt-add-repository multiverse
41
42 If --remove is given the tool will remove the given sourceline from your
43 sources.list
44@@ -170,6 +175,27 @@
45
46 # add it
47 sp = SoftwareProperties(options=options)
48+ distro = aptsources.distro.get_distro()
49+ distro.get_sources(sp.sourceslist)
50+ components = [comp.name for comp in distro.source_template.components]
51+ if line in components:
52+ if options.remove:
53+ if line in distro.enabled_comps:
54+ distro.disable_component(line)
55+ print _("'%s' distribution component disabled for all sources.")%line
56+ else:
57+ print _("Error: '%s' distribution component is not enabled, can not disable it.")%line
58+ sys.exit(1)
59+ else:
60+ if line not in distro.enabled_comps:
61+ distro.enable_component(line)
62+ print _("'%s' distribution component enabled for all sources.")%line
63+ else:
64+ print _("Error: '%s' distribution component is already enabled.")%line
65+ sys.exit(1)
66+ sp.sourceslist.save()
67+ sys.exit(0)
68+
69 if options.remove:
70 (line, file) = expand_ppa_line(line.strip(), sp.distro.codename)
71 deb_line = sp.expand_http_line(line)
72
73=== modified file 'debian/manpages/add-apt-repository.1'
74--- debian/manpages/add-apt-repository.1 2011-11-21 15:33:26 +0000
75+++ debian/manpages/add-apt-repository.1 2012-06-14 19:48:20 +0000
76@@ -28,8 +28,8 @@
77
78 .SH REPOSITORY STRING
79 \fIREPOSITORY\fR can be either a line that can be added directly to
80-sources.list(5), or in the form ppa:<user>/<ppa-name> for adding Personal
81-Package Archives.
82+sources.list(5), in the form ppa:<user>/<ppa-name> for adding Personal
83+Package Archives, or a distribution component to enable.
84
85 In the first form, \fIREPOSITORY\fR will just be appended to
86 /etc/apt/sources.list.
87@@ -40,6 +40,9 @@
88 The GPG public key of the newly added PPA will also be downloaded and
89 added to apt's keyring.
90
91+In the third form, the given distribution component will be enabled for all
92+sources.
93+
94 .SH SEE ALSO
95 \fBsources.list\fR(5)
96

Subscribers

People subscribed via source and target branches

to status/vote changes: