diff options
| -rw-r--r-- | aptsources/distro.py | 34 | ||||
| -rw-r--r-- | debian/changelog | 9 |
2 files changed, 43 insertions, 0 deletions
diff --git a/aptsources/distro.py b/aptsources/distro.py index f75aa06b..e11f113c 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -457,6 +457,13 @@ class UbuntuDistribution(Distribution): self, mirror_template="http://%s.archive.ubuntu.com/ubuntu/") +class UbuntuRTMDistribution(UbuntuDistribution): + ''' Class to support specific Ubuntu RTM features ''' + + def get_mirrors(self): + self.main_server = self.source_template.base_uri + + def _lsb_release(): """Call lsb_release --idrc and return a mapping.""" from subprocess import Popen, PIPE @@ -475,6 +482,24 @@ def _lsb_release(): return result +def _system_image_channel(): + """Get the current channel from system-image-cli -i if possible.""" + from subprocess import Popen, PIPE + import errno + try: + out = Popen( + ['system-image-cli', '-i'], stdout=PIPE, + universal_newlines=True).communicate()[0] + for l in out.splitlines(): + if l.startswith('channel: '): + return l.split(': ', 1)[1] + except OSError as exc: + if exc.errno != errno.ENOENT: + logging.warning( + 'system-image-cli failed, using defaults: %s' % exc) + return None + + def get_distro(id=None, codename=None, description=None, release=None): """ Check the currently used distribution and return the corresponding @@ -490,8 +515,17 @@ def get_distro(id=None, codename=None, description=None, release=None): codename = result['Codename'] description = result['Description'] release = result['Release'] + if id == "Ubuntu": + channel = _system_image_channel() + if channel is not None and "ubuntu-rtm/" in channel: + id = "Ubuntu-RTM" + codename = channel.rsplit("/", 1)[1].split("-", 1)[0] + description = codename + release = codename if id == "Ubuntu": return UbuntuDistribution(id, codename, description, release) + if id == "Ubuntu-RTM": + return UbuntuRTMDistribution(id, codename, description, release) elif id == "Debian": return DebianDistribution(id, codename, description, release) else: diff --git a/debian/changelog b/debian/changelog index 95852649..672ab6e0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +python-apt (0.9.3.11) UNRELEASED; urgency=low + + [ Colin Watson ] + * Add template for the "Ubuntu-RTM" derived distribution. + * Detect whether a system is running Ubuntu-RTM by way of + "system-image-cli -i". Not perfect but close enough. + + -- Michael Vogt <mvo@debian.org> Wed, 24 Sep 2014 11:36:00 +0200 + python-apt (0.9.3.10) unstable; urgency=medium * python/tag.cc: ensure that the final \n is there when |
