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
=== modified file 'add-apt-repository'
--- add-apt-repository 2010-03-26 10:18:47 +0000
+++ add-apt-repository 2010-07-19 20:31:45 +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()
4659
=== modified file 'softwareproperties/ppa.py'
--- softwareproperties/ppa.py 2010-04-14 07:04:11 +0000
+++ softwareproperties/ppa.py 2010-07-19 20:31:45 +0000
@@ -21,6 +21,7 @@
2121
22from threading import Thread22from threading import Thread
23from urllib2 import urlopen, Request, URLError23from urllib2 import urlopen, Request, URLError
24import urllib
24import re25import re
25import subprocess26import subprocess
26import apt_pkg27import apt_pkg
@@ -43,8 +44,11 @@
43 sourceslistd = apt_pkg.Config.FindDir("Dir::Etc::sourceparts")44 sourceslistd = apt_pkg.Config.FindDir("Dir::Etc::sourceparts")
44 line = "deb http://ppa.launchpad.net/%s/%s/ubuntu %s main" % (45 line = "deb http://ppa.launchpad.net/%s/%s/ubuntu %s main" % (
45 ppa_owner, ppa_name, distro_codename)46 ppa_owner, ppa_name, distro_codename)
47
48 encode = lambda s: urllib.quote(s,'').replace('-','%2D').replace('%','-')
49
46 file = "%s/%s-%s-%s.list" % (50 file = "%s/%s-%s-%s.list" % (
47 sourceslistd, ppa_owner, ppa_name, distro_codename)51 sourceslistd, encode(ppa_owner), encode(ppa_name), encode(distro_codename))
48 return (line, file)52 return (line, file)
4953
5054

Subscribers

People subscribed via source and target branches

to status/vote changes: