Merge lp:~mac9416/software-properties/illegalcharfix into lp:software-properties

Proposed by mac9416
Status: Merged
Merge reported by: Michael Vogt
Merged at revision: not available
Proposed branch: lp:~mac9416/software-properties/illegalcharfix
Merge into: lp:software-properties
Diff against target: 68 lines (+23/-6)
2 files modified
add-apt-repository (+18/-5)
softwareproperties/ppa.py (+5/-1)
To merge this branch: bzr merge lp:~mac9416/software-properties/illegalcharfix
Reviewer Review Type Date Requested Status
Ubuntu Core Development Team Pending
Review via email: mp+30334@code.launchpad.net

Description of the change

This fixes Bug #579669 which points out that add-apt-repository will create a sources.list.d file with illegal characters (as defined by the sources.list man page) if there are illegal characters in a PPA name.

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

A slightly modified version got merged into trunk

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-19 20:31:45 +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()
46
47=== modified file 'softwareproperties/ppa.py'
48--- softwareproperties/ppa.py 2010-04-14 07:04:11 +0000
49+++ softwareproperties/ppa.py 2010-07-19 20:31:45 +0000
50@@ -21,6 +21,7 @@
51
52 from threading import Thread
53 from urllib2 import urlopen, Request, URLError
54+import urllib
55 import re
56 import subprocess
57 import apt_pkg
58@@ -43,8 +44,11 @@
59 sourceslistd = apt_pkg.Config.FindDir("Dir::Etc::sourceparts")
60 line = "deb http://ppa.launchpad.net/%s/%s/ubuntu %s main" % (
61 ppa_owner, ppa_name, distro_codename)
62+
63+ encode = lambda s: urllib.quote(s,'').replace('-','%2D').replace('%','-')
64+
65 file = "%s/%s-%s-%s.list" % (
66- sourceslistd, ppa_owner, ppa_name, distro_codename)
67+ sourceslistd, encode(ppa_owner), encode(ppa_name), encode(distro_codename))
68 return (line, file)
69
70

Subscribers

People subscribed via source and target branches

to status/vote changes: