← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~mvo/launchpad/maintenance-check-precise into lp:launchpad

 

Michael Vogt has proposed merging lp:~mvo/launchpad/maintenance-check-precise into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~mvo/launchpad/maintenance-check-precise/+merge/82125

This branch makes the support-timeframe information that gets added to the "Packages" file in ubuntu more flexible for the upcomming 12.04 LTS release.

When 10.04 (lucid) was released we added "Supported: {5y,3y,18m}" tags into the Packages file that is stored on archive.ubuntu.com. This was needed because the individual packages get a different support time based on the "seed" they are in. The server packages are longer supported than the ubuntu-desktop packages etc. The additional information makes it trivial people to check the support status of a particular package and also allows scripts like "ubuntu-support-status" to work. 

For the upcoming 12.04 the timeframe is changed compared to lucid. The desktop packages are also supported for 5y and there may be architecture changes. The current code in LP is not flexible enough to handle different set of rules for LTS releases, it expected that the rules are all the same. This branch fixes this by adding a UbuntuMaintenance class that can than be used to extend for LTS releases.

Please note that I'm NOT a LP developer, this is a drive-by fix and I did not run ran the testsuite (as outlined in https://dev.launchpad.net/PatchSubmission) yet. 

The QA I have done on this to run:
$ python launchpad/trunk/cronscripts/publishing/maintenance-check.py lucid > /tmp/lucid-old-code
$ python  launchpad/maintenance-check-precise/cronscripts/publishing/maintenance-check.py lucid > /tmp/lucid-new-code
$ diff -u /tmp/lucid-old-code /tmp/lucid-new-code
(and the same for maverick).
-- 
https://code.launchpad.net/~mvo/launchpad/maintenance-check-precise/+merge/82125
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~mvo/launchpad/maintenance-check-precise into lp:launchpad.
=== modified file 'cronscripts/publishing/maintenance-check.py'
--- cronscripts/publishing/maintenance-check.py	2010-11-25 13:34:33 +0000
+++ cronscripts/publishing/maintenance-check.py	2011-11-14 11:19:29 +0000
@@ -2,9 +2,6 @@
 #
 # python port of the nice maintainace-check script by  Nick Barcet
 #
-# taken from:
-#  https://code.edge.launchpad.net/~mvo/ubuntu-maintenance-check/python-port
-# (where it will vanish once taken here)
 
 # this warning filter is only needed on older versions of python-apt,
 # once the machine runs lucid it can be removed
@@ -22,6 +19,33 @@
 
 from optparse import OptionParser
 
+
+class UbuntuMaintenance(object):
+    """ Represents the support timeframe for a regular ubuntu release """
+    
+    # architectures that are full supported (including LTS time)
+    PRIMARY_ARCHES = ["i386", "amd64"]
+
+    # architectures we support (but not for LTS time)
+    SUPPORTED_ARCHES = PRIMARY_ARCHES + ["armel"]
+
+    # what defines the seeds is documented in wiki.ubuntu.com/SeedManagement
+    SERVER_SEEDS = ["supported-server", "server-ship"]
+    DESKTOP_SEEDS = ["ship", "supported-desktop", "supported-desktop-extra"]
+    SUPPORTED_SEEDS = ["all"]
+
+    # normal support timeframe
+    # time, seeds
+    SUPPORT_TIMEFRAME = [
+        ("18m", SUPPORTED_SEEDS),
+        ]
+
+    # distro names that we check the seeds for
+    DISTRO_NAMES = [
+        "ubuntu",
+        ]
+
+
 # This is fun! We have a bunch of cases for 10.04 LTS
 #
 #  - distro "ubuntu" follows SUPPORT_TIMEFRAME_LTS but only for
@@ -30,41 +54,43 @@
 #    considered *but* only follow SUPPORT_TIMEFRAME
 #  - anything that is in armel follows SUPPORT_TIMEFRAME
 #
-
-# codename of the lts releases
-LTS_RELEASES = ["dapper", "hardy", "lucid"]
-
-# architectures that are full supported (including LTS time)
-PRIMARY_ARCHES = ["i386", "amd64"]
-
-# architectures we support (but not for LTS time)
-SUPPORTED_ARCHES = PRIMARY_ARCHES + ["armel"]
-
-# what defines the seeds is documented in wiki.ubuntu.com/SeedManagement
-SERVER_SEEDS = ["supported-server", "server-ship"]
-DESKTOP_SEEDS = ["ship", "supported-desktop", "supported-desktop-extra"]
-SUPPORTED_SEEDS = ["all"]
-
-# normal support timeframe
-# time, seeds, arches
-SUPPORT_TIMEFRAME = [
-    ("18m", SUPPORTED_SEEDS),
-]
-
-# lts support timeframe
-# time, seeds, arches
-SUPPORT_TIMEFRAME_LTS = [
-    ("5y", SERVER_SEEDS),
-    ("3y", DESKTOP_SEEDS),
-    ("18m", SUPPORTED_SEEDS),
-]
-
-# distro names and if they get LTS support (order is important)
-DISTRO_NAMES_AND_LTS_SUPPORT = [
-    ("ubuntu", True),
-    ("kubuntu", True),
-    ("netbook", False),
-    ]
+class LucidUbuntuMaintenance(UbuntuMaintenance):
+    """ Represents the support timeframe for a 10.04 (lucid) LTS release, 
+        the exact rules differ from LTS release to LTS release 
+    """
+
+    # lts support timeframe, order is important, least supported must be last
+    # time, seeds
+    SUPPORT_TIMEFRAME = [
+        ("5y",  UbuntuMaintenance.SERVER_SEEDS),
+        ("3y",  UbuntuMaintenance.DESKTOP_SEEDS),
+        ("18m", UbuntuMaintenance.SUPPORTED_SEEDS),
+    ]
+
+    # on a LTS this is significant, it defines what names get LTS support
+    DISTRO_NAMES = [
+        "ubuntu", 
+        "kubuntu",
+    ]
+
+class PreciseUbuntuMaintenance(UbuntuMaintenance):
+    """ The support timeframe for the 12.04 (precise) LTS release.
+        This changes the timeframe for desktop packages from 3y to 5y
+    """
+
+    # lts support timeframe, order is important, least supported must be last
+    # time, seeds
+    SUPPORT_TIMEFRAME = [
+        ("5y", UbuntuMaintenance.SERVER_SEEDS),
+        ("5y", UbuntuMaintenance.DESKTOP_SEEDS),
+        ("18m", UbuntuMaintenance.SUPPORTED_SEEDS),
+    ]
+
+    # on a LTS this is significant, it defines what names get LTS support
+    DISTRO_NAMES = [
+        "ubuntu", 
+    ]
+
 
 # Names of the distribution releases that are not supported by this
 # tool. All later versions are supported.
@@ -100,6 +126,18 @@
 SUPPORT_TAG = "Supported"
 
 
+
+# python-apt compat, the fallback can be removed once the code
+# runs on lucid or newer
+try:
+    AcquireProgress = apt.progress.base.AcquireProgress
+    OpProgress = apt.progress.base.OpProgress
+except AttributeError:
+    # really old (hardy) interface
+    AcquireProgress = apt.progress.FetchProgress
+    OpProgress = apt.progress.OpProgress
+
+
 def get_binaries_for_source_pkg(srcname):
     """ Return all binary package names for the given source package name.
 
@@ -168,7 +206,7 @@
     # open cache with our just prepared rootdir
     cache = apt.Cache(rootdir=rootdir)
     try:
-        cache.update(apt.progress.FetchProgress())
+        cache.update(AcquireProgress())
     except SystemError:
         logging.exception("cache.update() failed")
 
@@ -317,6 +355,12 @@
             sys.exit(1)
     else:
         distro = "lucid"
+    
+    # maintenance class to use
+    klass = globals().get("%sUbuntuMaintenance" % distro.capitalize())
+    if klass is None:
+        klass = UbuntuMaintenance
+    ubuntu_maintenance = klass()
 
     # make sure our deb-src information is up-to-date
     create_and_update_deb_src_source_list(distro)
@@ -332,7 +376,7 @@
 
     # go over the distros we need to check
     pkg_support_time = {}
-    for (name, lts_supported) in DISTRO_NAMES_AND_LTS_SUPPORT:
+    for name in ubuntu_maintenance.DISTRO_NAMES:
 
         # get basic structure file
         try:
@@ -342,26 +386,25 @@
             continue
 
         # get dicts of pkgname -> support timeframe string
-        support_timeframe = SUPPORT_TIMEFRAME
-        if lts_supported and distro in LTS_RELEASES:
-            support_timeframe = SUPPORT_TIMEFRAME_LTS
-        else:
-            support_timeframe = SUPPORT_TIMEFRAME
+        support_timeframe = ubuntu_maintenance.SUPPORT_TIMEFRAME
         get_packages_support_time(
             structure, name, pkg_support_time, support_timeframe)
 
     # now go over the bits in main that we have not seen (because
     # they are not in any seed and got added manually into "main"
-    for arch in PRIMARY_ARCHES:
+    for arch in ubuntu_maintenance.PRIMARY_ARCHES:
         rootdir="./aptroot.%s" % distro
         apt_pkg.Config.Set("APT::Architecture", arch)
         cache = apt.Cache(rootdir=rootdir)
         try:
-            cache.update(apt.progress.FetchProgress())
+            cache.update(AcquireProgress())
         except SystemError:
             logging.exception("cache.update() failed")
-        cache.open(apt.progress.OpProgress())
+        cache.open(OpProgress())
         for pkg in cache:
+            # ignore multiarch package names
+            if ":" in pkg.name:
+                continue
             if not pkg.name in pkg_support_time:
                 pkg_support_time[pkg.name] = support_timeframe[-1][0]
                 logging.warn(
@@ -410,12 +453,12 @@
             # go over the supported arches, they are divided in
             # first-class (PRIMARY) and second-class with different
             # support levels
-            for arch in SUPPORTED_ARCHES:
+            for arch in ubuntu_maintenance.SUPPORTED_ARCHES:
                 # ensure we do not overwrite arch-specific overwrites
                 pkgname_and_arch = "%s/%s" % (pkgname, arch)
                 if pkgname_and_arch in pkg_support_time:
                     break
-                if arch in PRIMARY_ARCHES:
+                if arch in ubuntu_maintenance.PRIMARY_ARCHES:
                     # arch with full LTS support
                     print "%s %s %s" % (
                         pkgname_and_arch, SUPPORT_TAG,
@@ -425,4 +468,4 @@
                     # support_timeframe
                     print "%s %s %s" % (
                         pkgname_and_arch, SUPPORT_TAG,
-                        SUPPORT_TIMEFRAME[0][0])
+                        ubuntu_maintenance.SUPPORT_TIMEFRAME[-1][0])