Merge lp:~bzoltan/click/vivid-transition_mirrors into lp:ubuntu/vivid-proposed/click

Proposed by Zoltan Balogh on 2015-01-19
Status: Merged
Merge reported by: Michael Vogt
Merged at revision: not available
Proposed branch: lp:~bzoltan/click/vivid-transition_mirrors
Merge into: lp:ubuntu/vivid-proposed/click
Diff against target: 100 lines (+28/-5)
2 files modified
click/chroot.py (+26/-3)
debian/control (+2/-2)
To merge this branch: bzr merge lp:~bzoltan/click/vivid-transition_mirrors
Reviewer Review Type Date Requested Status
Michael Vogt 2015-01-19 Approve on 2015-01-26
Review via email: mp+246913@code.launchpad.net

Commit message

Transition of locally used mirror servers to the chroots.

Description of the change

Transition of locally used mirror servers to the chroots.

To post a comment you must log in.
Zoltan Balogh (bzoltan) wrote :

Some explanation on the MR:

I have chosen to use the local ports and archive mirror because other options seems to be less optimal:

a) There is a way to measure bandwidth to/from the apt's mirror support, but that give a geographically close mirror and not a mirror with a fast access

b) Measuring the bandwidth to mirrors and trying to find the most optimal would need way much more code and would be too complex for a fairly simple problem

I decided to use a strict and limited expression to find the locally used mirror. I accept only the /XX.archive.ubuntu.com $series main/ source line. In case I do not find the mirror the code falls back to the central archive what is a safe choice.

All in all, the job here is to make the Chinese app developer's life easy. I am sure that we can make a more generic and smarter solution to support Ubuntu mirrors, but this one I believe is safe and good enough for now. Also I think it is legit idea to use the same mirror in the chroots what is used on the SDK's host environment.

Rex Tsai (chihchun) wrote :

Feedback and summing-up of irc discussion

Ubuntu users are suggested to use [countrycode].archive.ubuntu.com, but most users will select a random mirror server from the software center config (software-properties) or intstaller. http://i.imgur.com/2EvQIrv.png It ends up the user will not have xx.archive.ubuntu.com in /etc/apt/sources.list as reference.

It would make more sense that user can pick a mirror server during the new `click root` setup
1. A dialogue for user to pick which mirror to use. [countrycode].[ports|archive].ubuntu.com
2. The dialogue should suggest the default or preferred mirror server for the user. software-properties use user's locale to guess where is the most close mirror site.

Please note only [countrycode].[ports|archive].ubuntu.com are guarantee up-to-date, the other mirror can delay for few weeks. So we only use [countrycode].[ports|archive].ubuntu.com for phone developer.

66. By Zoltan Balogh on 2015-01-21

Use the local archive mirror and figure out the ports mirror with geoip lookup

67. By Zoltan Balogh on 2015-01-21

remove redundant imports

68. By Zoltan Balogh on 2015-01-21

Use the official archive mirror

69. By Zoltan Balogh on 2015-01-21

Make it flake8 friendly

70. By Zoltan Balogh on 2015-01-22

remove unused local_mirror_server

71. By Zoltan Balogh on 2015-01-23

Handle exception when chroot is created without network and add dependecies

Michael Vogt (mvo) wrote :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'click/chroot.py'
--- click/chroot.py 2014-11-14 12:29:14 +0000
+++ click/chroot.py 2015-01-23 16:18:15 +0000
@@ -26,6 +26,8 @@
26 "ClickChrootDoesNotExistException",26 "ClickChrootDoesNotExistException",
27 ]27 ]
2828
29import urllib
30import urllib.request
29import os31import os
30import pwd32import pwd
31import re33import re
@@ -34,6 +36,7 @@
34import subprocess36import subprocess
35import sys37import sys
36from textwrap import dedent38from textwrap import dedent
39from xml.etree import ElementTree
3740
3841
39framework_base = {42framework_base = {
@@ -215,6 +218,21 @@
215 pass218 pass
216219
217220
221def get_geoip_country_code_prefix():
222 GEOIP_SERVER = "http://geoip.ubuntu.com/lookup"
223 try:
224 with urllib.request.urlopen(GEOIP_SERVER) as f:
225 xml_data = f.read()
226 try:
227 et = ElementTree.fromstring(xml_data)
228 return et.find("CountryCode").text.lower()+"."
229 except ElementTree.ParseError:
230 pass
231 except:
232 pass
233 return ""
234
235
218class ClickChroot:236class ClickChroot:
219237
220 DAEMON_POLICY = dedent("""\238 DAEMON_POLICY = dedent("""\
@@ -247,11 +265,14 @@
247 if chroots_dir is None:265 if chroots_dir is None:
248 chroots_dir = "/var/lib/schroot/chroots"266 chroots_dir = "/var/lib/schroot/chroots"
249 self.chroots_dir = chroots_dir267 self.chroots_dir = chroots_dir
268
269 self.country_code = get_geoip_country_code_prefix()
250 # this doesn't work because we are running this under sudo270 # this doesn't work because we are running this under sudo
251 if 'DEBOOTSTRAP_MIRROR' in os.environ:271 if 'DEBOOTSTRAP_MIRROR' in os.environ:
252 self.archive = os.environ['DEBOOTSTRAP_MIRROR']272 self.archive = os.environ['DEBOOTSTRAP_MIRROR']
253 else:273 else:
254 self.archive = "http://archive.ubuntu.com/ubuntu"274 self.archive = "http://%sarchive.ubuntu.com/ubuntu" \
275 % self.country_code
255 if "SUDO_USER" in os.environ:276 if "SUDO_USER" in os.environ:
256 self.user = os.environ["SUDO_USER"]277 self.user = os.environ["SUDO_USER"]
257 elif "PKEXEC_UID" in os.environ:278 elif "PKEXEC_UID" in os.environ:
@@ -331,7 +352,8 @@
331 mount=mount))352 mount=mount))
332353
333 def _generate_sources(self, series, native_arch, target_arch, components):354 def _generate_sources(self, series, native_arch, target_arch, components):
334 ports_mirror = "http://ports.ubuntu.com/ubuntu-ports"355 ports_mirror = "http://%sports.ubuntu.com/ubuntu-ports" \
356 % self.country_code
335 pockets = ['%s' % series]357 pockets = ['%s' % series]
336 for pocket in ['updates', 'security']:358 for pocket in ['updates', 'security']:
337 pockets.append('%s-%s' % (series, pocket))359 pockets.append('%s-%s' % (series, pocket))
@@ -467,7 +489,8 @@
467 proxy = os.environ["http_proxy"]489 proxy = os.environ["http_proxy"]
468 if not proxy:490 if not proxy:
469 proxy = subprocess.check_output(491 proxy = subprocess.check_output(
470 'unset x; eval "$(apt-config shell x Acquire::HTTP::Proxy)"; echo "$x"',492 'unset x; eval "$(apt-config shell x Acquire::HTTP::Proxy)"; \
493 echo "$x"',
471 shell=True, universal_newlines=True).strip()494 shell=True, universal_newlines=True).strip()
472 build_pkgs = [495 build_pkgs = [
473 "build-essential", "fakeroot",496 "build-essential", "fakeroot",
474497
=== modified file 'debian/control'
--- debian/control 2014-11-03 12:49:25 +0000
+++ debian/control 2015-01-23 16:18:15 +0000
@@ -3,7 +3,7 @@
3Priority: optional3Priority: optional
4Maintainer: Colin Watson <cjwatson@ubuntu.com>4Maintainer: Colin Watson <cjwatson@ubuntu.com>
5Standards-Version: 3.9.55Standards-Version: 3.9.5
6Build-Depends: debhelper (>= 9~), dh-autoreconf, intltool, python3:any (>= 3.2), python3-all:any, python3-setuptools, python3-apt, python3-debian, python3-gi, python3:any (>= 3.3) | python3-mock, pep8, python3-pep8, pyflakes, python3-sphinx, pkg-config, valac, gobject-introspection (>= 0.6.7), libgirepository1.0-dev (>= 0.6.7), libglib2.0-dev (>= 2.34), gir1.2-glib-2.0, libjson-glib-dev (>= 0.10), libgee-0.8-dev, libpackagekit-glib2-dev (>= 0.7.2), python3-coverage, python3-six, dh-systemd (>= 1.3)6Build-Depends: debhelper (>= 9~), dh-autoreconf, intltool, python3:any (>= 3.2), python3-all:any, python3-setuptools, python3-apt, python3-debian, python3-gi, python3:any (>= 3.3) | python3-mock, pep8, python3-pep8, pyflakes, python3-sphinx, pkg-config, valac, gobject-introspection (>= 0.6.7), libgirepository1.0-dev (>= 0.6.7), libglib2.0-dev (>= 2.34), gir1.2-glib-2.0, libjson-glib-dev (>= 0.10), libgee-0.8-dev, libpackagekit-glib2-dev (>= 0.7.2), python3-coverage, python3-six, python3-urllib3, dh-systemd (>= 1.3)
7Vcs-Bzr: https://code.launchpad.net/~ubuntu-managed-branches/click/click7Vcs-Bzr: https://code.launchpad.net/~ubuntu-managed-branches/click/click
8Vcs-Browser: http://bazaar.launchpad.net/~ubuntu-managed-branches/click/click/files8Vcs-Browser: http://bazaar.launchpad.net/~ubuntu-managed-branches/click/click/files
9X-Auto-Uploader: no-rewrite-version9X-Auto-Uploader: no-rewrite-version
@@ -40,7 +40,7 @@
40Package: python3-click40Package: python3-click
41Section: python41Section: python
42Architecture: any42Architecture: any
43Depends: ${misc:Depends}, ${python3:Depends}, gir1.2-click-0.4 (= ${binary:Version}), gir1.2-glib-2.0, python3-apt, python3-debian, python3-gi43Depends: ${misc:Depends}, ${python3:Depends}, gir1.2-click-0.4 (= ${binary:Version}), gir1.2-glib-2.0, python3-apt, python3-debian, python3-gi, python3-urllib3
44Conflicts: python3-click-package44Conflicts: python3-click-package
45Replaces: python3-click-package45Replaces: python3-click-package
46Provides: python3-click-package46Provides: python3-click-package

Subscribers

People subscribed via source and target branches

to all changes: