Merge lp:~rodrigo-moya/system-service/fix-aptconf-issues into lp:system-service

Proposed by Rodrigo Moya
Status: Merged
Merged at revision: 59
Proposed branch: lp:~rodrigo-moya/system-service/fix-aptconf-issues
Merge into: lp:system-service
Diff against target: 54 lines (+10/-16)
1 file modified
backend/system-service-d (+10/-16)
To merge this branch: bzr merge lp:~rodrigo-moya/system-service/fix-aptconf-issues
Reviewer Review Type Date Requested Status
Ubuntu Core Development Team Pending
Review via email: mp+79963@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks! Merged and pushed to oneirici-proposed.

In trunk I added a regression test

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'backend/system-service-d'
2--- backend/system-service-d 2011-07-21 08:09:18 +0000
3+++ backend/system-service-d 2011-10-20 14:05:41 +0000
4@@ -176,13 +176,6 @@
5 confdir = apt_pkg.Config.FindDir("Dir::Etc")
6 if not self._verify_proxy(proxy_type, new_proxy):
7 return False
8- # check for the easy case (no proxy setting in the config)
9- old_proxy = self._apt_proxy(proxy_type)
10- if old_proxy == "":
11- f=open(os.path.join(confdir, "apt.conf"),"a")
12- f.write("Acquire::%s::proxy \"%s\";\n" % (proxy_type, new_proxy))
13- f.close()
14- return True
15 # now the difficult case (search the apt configuration files)
16 # build the list of apt configuration files first
17 apt_conffiles = [os.path.join(confdir,"apt.conf.d",n) for n in
18@@ -193,18 +186,17 @@
19 new_content = []
20 found = False
21 for line in open(f):
22- if line.lower().startswith("acquire::%s::proxy" % proxy_type):
23+ # Only replace the Acquire::%s::proxy entry, not other more
24+ # complicated forms of the proxy settings
25+ if line.lower().startswith("acquire::%s::proxy " % proxy_type):
26 found = True
27 line = "Acquire::%s::proxy \"%s\";\n" % (proxy_type, new_proxy)
28- # FIXME: scan for more complicated forms of the proxy
29- # settings and/or scan for the proxy string and just
30- # replace this
31 new_content.append(line)
32 # if we found/replaced the proxy, write it out now
33- if found:
34- open(f,"w").write("".join(new_content))
35- return True
36- return False
37+ if not found:
38+ new_content.append("Acquire::%s::proxy \"%s\";\n" % (proxy_type, new_proxy))
39+ open(f,"w").write("".join(new_content))
40+ return True
41
42 def _write_etc_environment_proxy(self, proxy_type, new_proxy):
43 if not self._verify_proxy(proxy_type, new_proxy):
44@@ -245,7 +237,9 @@
45 new_content = []
46 found = False
47 for line in open(f):
48- if line.lower().startswith("acquire::%s::proxy" % proxy_type):
49+ # Only remove the Acquire::%s::proxy entry, not other more
50+ # complicated forms of the proxy settings
51+ if line.lower().startswith("acquire::%s::proxy " % proxy_type):
52 found = True
53 else:
54 new_content.append(line)

Subscribers

People subscribed via source and target branches