I'm in this same situation as well. I checked out the source, and it appears to be designed this way.

This information is coming from running "apt-cache policy" and is parsed as explained by this comments:
   # If the user has multiple releases we should
   # only return the 'newest'.

   # Unstable is always the 'newest'

It's my opinion that this behavior is "wrong," and if it's going to continue to use apt-cache policy (instead of /etc/debian_version or something), it should be based off the highest priority [for c=main, which is already enforced]. I think maybe it should also enforce label=Debian, so we're not parsing the Debian-Security repositories, too.

I've attached a patch that addresses these issues, and changes the behavior how I've noted I feel it "should" behave.

-David R. Hedges

---------------

[EMAIL PROTECTED]:~$ apt-cache policy
Package files:
100 /var/lib/dpkg/status
    release a=now
990 http://security.debian.org lenny/updates/contrib Packages
    release v=None,o=Debian,a=testing,l=Debian-Security,c=contrib
    origin security.debian.org
990 http://security.debian.org lenny/updates/main Packages
    release v=None,o=Debian,a=testing,l=Debian-Security,c=main
    origin security.debian.org
500 http://ftp.us.debian.org unstable/main Packages
    release o=Debian,a=unstable,l=Debian,c=main
    origin ftp.us.debian.org
990 http://ftp.us.debian.org lenny/main Packages
    release o=Debian,a=testing,l=Debian,c=main
    origin ftp.us.debian.org
Pinned packages:

[EMAIL PROTECTED]:~$ /usr/bin/lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux unstable (sid)
Release:        unstable
Codename:       sid

[EMAIL PROTECTED]:~$ ./lsb-3.1/lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux testing (lenny)
Release:        testing
Codename:       lenny
--- /usr/bin/lsb_release        2007-07-25 08:49:12.000000000 -0500
+++ ./lsb_release       2008-04-08 19:41:18.000000000 -0500
@@ -127,48 +127,26 @@
     return data
 
 def guess_release_from_apt(origin='Debian', component='main',
-                           ignoresuites=('experimental')):
+                           ignoresuites=('experimental'),
+                           label='Debian'):
     releases = parse_apt_policy()
 
     if not releases:
         return None
 
-    # We only care about the specified origin and component
+    # We only care about the specified origin, component, and label
     releases = [x for x in releases if (
         x[1].get('origin', '') == origin and
-        x[1].get('component', '') == component)]
+        x[1].get('component', '') == component and
+        x[1].get('label', '') == label)]
     
     releases.sort()
     releases.reverse()
 
-    # If the user has multiple releases we should
-    # only return the 'newest'.
+    # We've sorted the list by descending priority, so the first entry should
+    # be the "main" release in use on the system
 
-    # Unstable is always the 'newest'
-    for (pri, rinfo) in releases:
-        if rinfo.get('suite', '') == 'unstable':
-            return rinfo
-    # After it goes testing
-    for (pri, rinfo) in releases:
-        if rinfo.get('suite', '') == 'testing':
-            return rinfo
-
-    # Finally, find the highest numeric value
-    highestrelease = 0
-    for (pri, rinfo) in releases:
-        if rinfo.get('suite', '') not in ignoresuites:
-            version = RELEASE_CODENAME_LOOKUP.get(unknown, rinfo.get('suite',''))
-            if version > highestrelease:
-                highestrelease = version
-
-    # And return it
-    for (pri, rinfo) in releases:
-        if rinfo.get('suite', '') not in ignoresuites:
-            version = RELEASE_CODENAME_LOOKUP.get(unknown, rinfo.get('suite',''))
-            if version == highestrelease:
-                return rinfo
-
-    return None
+    return releases[0][1]
 
 def guess_debian_release():
     distinfo = {'ID' : 'Debian'}

Reply via email to