On Thu, Jan 10, 2008 at 03:50:58PM -0500, Steve Magoun wrote:
> For the Ubuntu Mobile effort we have a new arch - LPIA - that's  
> essentially the same as i386. One of the problems we've run into is  
> that package updates sometimes build for i386 but not LPIA, so the  
> LPIA version of the package is either out of date or missing. Two  
> examples from gutsy: The x264 package built for i386 but FTBFS for  
> LPIA. The freetype1 package got stuck on a dependency wait for LPIA,  
> while the i386 version built fine.
> 
> We (the folks working on Ubuntu Mobile) would like to make sure this  
> doesn't happen in the future; is there a good way for us to track the  
> delta between i386 and LPIA? I found http://qa.ubuntuwire.com/ftbfs  
> but that doesn't give a concise diff of the two architectures.

Hi Steve,

I've been meaning to get back to you about this for a while, but haven't
got round to preparing anything particularly nice. Matt pointed out that
it might be a good plan just to provide you with the tools you need and
let you get on with it. :-)

I have a program called 'suite-diff', which I wrote some time back and
have been polishing occasionally; it compares two Packages (or Sources)
files and reports on the version differences between them in various
ways. You will need to have the python-apt package installed to run it.
You invoke it like this:

  ./suite-diff.py <Packages1> <Packages2> <mode>

<Packages1> might be
http://archive.ubuntu.com/ubuntu/dists/hardy/main/binary-i386/Packages.gz,
and <Packages2> might be
http://ports.ubuntu.com/ubuntu-ports/dists/hardy/main/binary-lpia/Packages.gz,
for instance.

There are quite a few different possible values for <mode>, and I'm not
sure exactly which one you want:

  lt: list any packages in <Packages1> Less Than <Packages2>
  le: list any packages in <Packages1> Less than or Equal to <Packages2>
  eq: list any packages in <Packages1> EQual to <Packages2>
  ne: list any packages in <Packages1> Not Equal to <Packages2>
  ge: list any packages in <Packages1> Greater than or Equal to <Packages2>
  gt: list any packages in <Packages1> Greater Than <Packages2>

You can also add '-ne' (No version is Earlier than any version) or '-nl'
(No version is Later than any version) to the mode; so for instance if
you say 'lt-nl' it will list all packages in <Packages1> that are at a
version less than <Packages2> and treat a missing package as being
equivalent to an enormously high version that's greater than anything
else.

I'm not sure that any of these modes is precisely what you want, but you
should be able to come up with something useful by running this in
various combinations. Note that it doesn't actually take account of
whether a build failed in Launchpad or simply hasn't been tried yet; it
just looks at whatever's in the archive.

Let me know if you have any problems and I can help you out.

Cheers,

-- 
Colin Watson                                       [EMAIL PROTECTED]
#! /usr/bin/env python

import sys
import os
import atexit
import shutil

import apt_pkg

tempdir = None

class UsageError(Exception): pass

def ensure_tempdir():
    global tempdir
    if not tempdir:
        import tempfile
        tempdir = tempfile.mkdtemp(prefix='suite-diff')
        atexit.register(shutil.rmtree, tempdir)

def decompress_open(tagfile):
    if tagfile.startswith('http:') or tagfile.startswith('ftp:'):
        import urllib
        url = tagfile
        tagfile = urllib.urlretrieve(url)[0]

    if tagfile.endswith('.gz'):
        import gzip
        import tempfile
        ensure_tempdir()
        decompressed = tempfile.mktemp(dir=tempdir)
        fin = gzip.GzipFile(filename=tagfile)
        fout = open(decompressed, 'wb')
        fout.write(fin.read())
        fout.close()
        return open(decompressed, 'r')
    else:
        return open(tagfile, 'r')

def tagfiletodict(tagfile):
    suite = {}
    p = apt_pkg.ParseTagFile(decompress_open(tagfile))
    while p.Step() == 1:
        suite[p.Section["Package"]] = p.Section["Version"]
    return suite

def main():
    if len(sys.argv) < 3 or len(sys.argv) > 4:
        raise UsageError

    tagfile1 = sys.argv[1]
    tagfile2 = sys.argv[2]
    if len(sys.argv) > 3:
        mode = sys.argv[3]
    else:
        mode = 'ne'

    if mode.endswith('-nl'):
        no_version = '9999999:9999999'
        mode = mode[:-3]
    elif mode.endswith('-ne'):
        no_version = '0~0~0'
        mode = mode[:-3]
    else:
        no_version = None

    if mode == 'lt':
        compare = lambda x, y: apt_pkg.VersionCompare(x, y) < 0
        display = '<'
    elif mode == 'le':
        compare = lambda x, y: apt_pkg.VersionCompare(x, y) <= 0
        display = '<='
    elif mode == 'eq':
        compare = lambda x, y: x == y
        display = '=='
    elif mode == 'ne':
        compare = lambda x, y: x != y
        display = '!='
    elif mode == 'ge':
        compare = lambda x, y: apt_pkg.VersionCompare(x, y) >= 0
        display = '>='
    elif mode == 'gt':
        compare = lambda x, y: apt_pkg.VersionCompare(x, y) > 0
        display = '>'
    else:
        raise UsageError

    apt_pkg.InitSystem()

    suite1 = tagfiletodict(tagfile1)
    suite2 = tagfiletodict(tagfile2)

    keys1 = set(suite1.keys())
    keys2 = set(suite2.keys())

    for package in sorted(keys1 | keys2):
        if package not in suite1 and package not in suite2:
            continue
        if package in suite1:
            version1 = suite1[package]
            display1 = version1
        elif no_version is not None:
            version1 = no_version
            display1 = 'none'
        else:
            continue
        if package in suite2:
            version2 = suite2[package]
            display2 = version2
        elif no_version is not None:
            version2 = no_version
            display2 = 'none'
        else:
            continue
        if compare(version1, version2):
            print "%s: %s %s %s" % (package, display1, display, display2)

if __name__ == '__main__':
    try:
        main()
    except UsageError:
        sys.exit("Usage: suite-diff.py <Packages> <Packages> "
                 "[lt|le|eq|ne|ge|gt]")
-- 
Ubuntu-mobile mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-mobile

Reply via email to