Don't run apt-cache if /etc/lsb-release exists.
authorSteve Langasek <steve.langasek@ubuntu.com>
Tue, 21 Feb 2012 15:49:04 +0000 (16:49 +0100)
committerDidier Raboud <odyx@debian.org>
Mon, 27 Feb 2012 12:32:39 +0000 (13:32 +0100)
Since /etc/lsb-release overrides detected information, there's no
need to try and detect that information if lsb-release contains
everything we need.  This saves us calling the hugely expensive
apt-cache.

lsb_release.py

index 5c6cb9ac00c9270650b2d4aa040618e3baf79f28..92088584734702f102197da2fc63bf6b50770125 100644 (file)
@@ -284,9 +284,15 @@ def get_lsb_information():
     return distinfo
 
 def get_distro_information():
-    distinfo = guess_debian_release()
-    distinfo.update(get_lsb_information())
-    return distinfo
+    lsbinfo = get_lsb_information()
+    # OS is only used inside guess_debian_release anyway
+    for key in ('ID', 'RELEASE', 'CODENAME', 'DESCRIPTION',):
+        if key not in lsbinfo:
+            distinfo = guess_debian_release()
+            distinfo.update(lsbinfo)
+            return distinfo
+    else:
+        return lsbinfo
 
 def test():
     print get_distro_information()