diff options
| author | Julian Andres Klode <jak@debian.org> | 2009-08-02 18:23:28 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2009-08-02 18:23:28 +0200 |
| commit | 08674e660118758f32d220a26b4a525459317293 (patch) | |
| tree | 1f432fb38a147d2d47af63faa46ee398b2b2c717 | |
| parent | 992629cbd46b9cf830b8ab95e30f56bbcab4d724 (diff) | |
| download | python-apt-08674e660118758f32d220a26b4a525459317293.tar.gz | |
Only recommend lsb-release instead of depending on it. Default to
Debian unstable if lsb_release is not available.
| -rw-r--r-- | aptsources/distinfo.py | 13 | ||||
| -rw-r--r-- | aptsources/distro.py | 25 | ||||
| -rw-r--r-- | debian/changelog | 4 | ||||
| -rw-r--r-- | debian/control | 4 |
4 files changed, 33 insertions, 13 deletions
diff --git a/aptsources/distinfo.py b/aptsources/distinfo.py index 2e5fd7bc..0614bd1c 100644 --- a/aptsources/distinfo.py +++ b/aptsources/distinfo.py @@ -21,9 +21,11 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA +import errno import os import gettext from os import getenv +from subprocess import Popen, PIPE import ConfigParser import re @@ -160,10 +162,13 @@ class DistInfo: #match_mirror_line = re.compile(r".+") if not dist: - pipe = os.popen("lsb_release -i -s") - dist = pipe.read().strip() - pipe.close() - del pipe + try: + dist = Popen(["lsb_release", "-i", "-s"], + stdout=PIPE).communicate()[0].strip() + except OSError, exc: + if exc.errno != errno.ENOENT: + print 'WARNING: lsb_release failed, using defaults:', exc + dist = "Debian" self.dist = dist diff --git a/aptsources/distro.py b/aptsources/distro.py index 5398d4a3..2cbad9fb 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -437,6 +437,20 @@ class UbuntuDistribution(Distribution): Distribution.get_mirrors( self, mirror_template="http://%s.archive.ubuntu.com/ubuntu/") +def _lsb_release(): + """Call lsb_release --all and return a mapping.""" + from subprocess import Popen, PIPE + import errno + result = {'Codename': 'sid', 'Distributor ID': 'Debian', + 'Description': 'Debian GNU/Linux unstable (sid)', + 'Release': 'unstable'} + try: + out = Popen(['lsb_release', '--all'], stdout=PIPE).communicate()[0] + result.update(l.split(":\t") for l in out.split("\n") if ':\t' in l) + except OSError, exc: + if exc.errno != errno.ENOENT: + print 'WARNING: lsb_release failed, using defaults:', exc + return result def get_distro(id=None, codename=None, description=None, release=None): """ @@ -448,12 +462,11 @@ def get_distro(id=None, codename=None, description=None, release=None): """ # make testing easier if not (id and codename and description and release): - lsb_info = [] - for lsb_option in ["-i", "-c", "-d", "-r"]: - pipe = os.popen("lsb_release %s -s" % lsb_option) - lsb_info.append(pipe.read().strip()) - del pipe - (id, codename, description, release) = lsb_info + result = _lsb_release() + id = result['Distributor ID'] + codename = result['Codename'] + description = result['Description'] + release = result['Release'] if id == "Ubuntu": return UbuntuDistribution(id, codename, description, release) elif id == "Debian": diff --git a/debian/changelog b/debian/changelog index 928493ad..5f1f2967 100644 --- a/debian/changelog +++ b/debian/changelog @@ -32,8 +32,10 @@ python-apt (0.7.92) UNRELEASED; urgency=low - Merge Configuration,ConfigurationPtr,ConfigurationSub into one type. - Simplify the whole build process by using a single setup.py. - The documentation has been restructured and enhanced with tutorials. + - Only recommend lsb-release instead of depending on it. Default to + Debian unstable if lsb_release is not available. - -- Julian Andres Klode <jak@debian.org> Wed, 15 Jul 2009 14:56:24 +0200 + -- Julian Andres Klode <jak@debian.org> Sun, 02 Aug 2009 16:35:42 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/debian/control b/debian/control index 69bca37a..6b96a6be 100644 --- a/debian/control +++ b/debian/control @@ -24,8 +24,8 @@ Vcs-Browser: http://bzr.debian.org/loggerhead/apt/python-apt/debian-sid/changes Package: python-apt Architecture: any -Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, lsb-release -Recommends: iso-codes, libjs-jquery +Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends} +Recommends: lsb-release, iso-codes, libjs-jquery Breaks: debdelta (<< 0.28~) Provides: ${python:Provides} Suggests: python-apt-dbg, python-gtk2, python-vte |
