[Pkg-ocaml-maint-commits] r5943 - in /trunk/packages/edos-debcheck/trunk/debian: changelog contrib/ contrib/add-sources.py control

zack at users.alioth.debian.org zack at users.alioth.debian.org
Tue Aug 12 22:10:39 UTC 2008


Author: zack
Date: Tue Aug 12 22:10:38 2008
New Revision: 5943

URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/?sc=1&rev=5943
Log:
add contributed script debian/contrib/add-sources.py, used to mangle
Packages/Sources to detect unbuildable packages

Added:
    trunk/packages/edos-debcheck/trunk/debian/contrib/
    trunk/packages/edos-debcheck/trunk/debian/contrib/add-sources.py   (with props)
Modified:
    trunk/packages/edos-debcheck/trunk/debian/changelog
    trunk/packages/edos-debcheck/trunk/debian/control

Modified: trunk/packages/edos-debcheck/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/packages/edos-debcheck/trunk/debian/changelog?rev=5943&op=diff
==============================================================================
--- trunk/packages/edos-debcheck/trunk/debian/changelog (original)
+++ trunk/packages/edos-debcheck/trunk/debian/changelog Tue Aug 12 22:10:38 2008
@@ -13,6 +13,8 @@
     - add 00dpatch.conf to ease usage of dpatch-edit-patch
     - 04quiet_option: new patch adding support for a -quiet command line
       option, when given extra messages such as timing are suppressed
+  * add contributed script debian/contrib/add-sources.py, used to mangle
+    Packages/Sources to detect unbuildable packages
 
  -- Ralf Treinen <treinen at debian.org>  Tue, 08 Jan 2008 09:04:21 +0100
 

Added: trunk/packages/edos-debcheck/trunk/debian/contrib/add-sources.py
URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/packages/edos-debcheck/trunk/debian/contrib/add-sources.py?rev=5943&op=file
==============================================================================
--- trunk/packages/edos-debcheck/trunk/debian/contrib/add-sources.py (added)
+++ trunk/packages/edos-debcheck/trunk/debian/contrib/add-sources.py Tue Aug 12 22:10:38 2008
@@ -1,0 +1,114 @@
+#!/usr/bin/python
+
+# Given as input a Packages and a Sources file, produces as output a new
+# Packages containing fake "source---FOO" packages which are installable if and
+# only if the corresponding source package (FOO) has satisfiable build
+# dependencies.
+
+# Copyright (C) 2008 Stefano Zacchiroli <zack at debian.org>
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
+
+# $Id$
+
+import string
+import sys
+
+from debian_bundle import deb822
+
+if len(sys.argv) != 3:
+    print 'Usage: cat Packages | add-sources Sources ARCH > Packages.new'
+    sys.exit(2)
+
+sources_file = sys.argv[1]
+architecture = sys.argv[2]
+
+def pkg_of_src(src):
+    global architecture
+    pkg = deb822.Packages()
+    pkg['Package'] = 'source---' + src['Package']
+
+    def dep_for_me(dep):
+        for_me = None
+        if dep['arch'] is None:
+            for_me = True
+        elif dep['arch']:
+            (polarity, _) = dep['arch'][0]
+            if polarity:    # list is inclusive
+                for_me = (True, architecture) in dep['arch']
+            else:   # list is exclusive
+                for_me = not ((False, architecture) in dep['arch'])
+        else:
+            for_me = False
+        #print 'ZZZ FOR_ME', for_me
+        return for_me
+
+    def mk_bin_rels(fields, relations):
+        def strip_arch(dep):
+            dep['arch'] = None
+            return dep
+
+        def get_rels(fields, relations):
+            rels = []
+            for name in fields:
+                if relations.has_key(name):
+                    rels.extend(relations[name])
+            return rels
+
+        src_rels = get_rels(fields, relations)
+        bin_rels = []
+        for or_deps in src_rels:
+            my_or_deps = map(strip_arch, filter(dep_for_me, or_deps))
+            if my_or_deps:
+                bin_rels.append(my_or_deps)
+
+        return bin_rels
+
+    def str_of_relations(rels):
+        # XXX this is cut and paste from python-debian's deb822.py, more
+        # precisely it matches the str() method of the PkgRelation class
+        # TODO to be removed as soon as python-debian 0.1.12 hits unstable
+        def pp_arch(arch_spec):
+            (excl, arch) = arch_spec
+            if excl:
+                return arch
+            else:
+                return '!' + arch
+        def pp_atomic_dep(dep):
+            s = dep['name']
+            if dep.has_key('version') and dep['version'] is not None:
+                s += ' (%s %s)' % dep['version']
+            if dep.has_key('arch') and dep['arch'] is not None:
+                s += ' [%s]' % string.join(map(pp_arch, dep['arch']))
+            return s
+        pp_or_dep = lambda deps: string.join(map(pp_atomic_dep, deps), ' | ')
+        return string.join(map(pp_or_dep, rels), ', ')
+
+    for field in ['Version', 'Priority', 'Section', 'Maintainer']:
+        if src.has_key(field):
+            pkg[field] = src[field]
+    bin_depends = mk_bin_rels(['build-depends', 'build-depends-indep'],
+            src.relations)
+    if bin_depends:
+        #pkg['Depends'] = deb822.PkgRelation.str(bin_depends)
+        pkg['Depends'] = str_of_relations(bin_depends)
+    bin_conflicts = mk_bin_rels(['build-conflicts', 'build-conflicts-indep'],
+            src.relations)
+    if bin_conflicts:
+        #pkg['Conflicts'] = deb822.PkgRelation.str(bin_conflicts)
+        pkg['Conflicts'] = str_of_relations(bin_conflicts)
+    pkg['Description'] = 'dummy counterpart of "%s" source package' % \
+            src['Package']
+    pkg['Description'] += "\n I don't exist, go away."
+
+    return pkg
+
+#for pkg in deb822.Packages.iter_paragraphs(sys.stdin):
+for line in sys.stdin:
+    print line,
+for src in deb822.Sources.iter_paragraphs(file(sources_file)):
+    pkg = pkg_of_src(src)
+    print pkg
+

Propchange: trunk/packages/edos-debcheck/trunk/debian/contrib/add-sources.py
------------------------------------------------------------------------------
    svn:executable = *

Propchange: trunk/packages/edos-debcheck/trunk/debian/contrib/add-sources.py
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: trunk/packages/edos-debcheck/trunk/debian/control
URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/packages/edos-debcheck/trunk/debian/control?rev=5943&op=diff
==============================================================================
--- trunk/packages/edos-debcheck/trunk/debian/control (original)
+++ trunk/packages/edos-debcheck/trunk/debian/control Tue Aug 12 22:10:38 2008
@@ -12,6 +12,7 @@
 Package: edos-debcheck
 Architecture: any
 Depends: ${shlibs:Depends}, ${F:OCamlRun}
+Recommends: python-debian
 Description: Checks whether dependencies of Debian packages can be satisfied
  This software checks for every package of a distribution (in the
  Debian format .deb) whether it is possible to satisfy its




More information about the Pkg-ocaml-maint-commits mailing list