Merge branch 'master' into debian
authorSam Hartman <hartmans@debian.org>
Sun, 31 Oct 2010 21:38:26 +0000 (17:38 -0400)
committerSam Hartman <hartmans@debian.org>
Sun, 31 Oct 2010 21:38:26 +0000 (17:38 -0400)
Conflicts:
shibboleth/opensaml2
shibboleth/xmltooling

.gitmodules
debian-builder [new file with mode: 0755]
shibboleth/opensaml2
shibboleth/xmltooling
source_packages [new file with mode: 0644]

index 7978646..c333e09 100644 (file)
@@ -1,24 +1,24 @@
 [submodule "mod_auth_kerb"]
        path = mod_auth_kerb
-       url = ../mod_auth_kerb.git
+       url = http://www.project-moonshot.org/git/mod_auth_kerb.git
 [submodule "radsecproxy"]
        path = libradsec
        url = git://git.nordu.net/radsecproxy.git
 [submodule "shibboleth/opensaml2"]
        path = shibboleth/opensaml2
-       url = ../shibboleth/opensaml2.git
+       url = http://www.project-moonshot.org/git/shibboleth/opensaml2.git
 [submodule "shibboleth/sp"]
        path = shibboleth/sp
-       url = ../shibboleth/sp.git
+       url = http://www.project-moonshot.org/git/shibboleth/sp.git
 [submodule "shibboleth/xmltooling"]
        path = shibboleth/xmltooling
-       url = ../shibboleth/xmltooling.git
+       url = http://www.project-moonshot.org/git/shibboleth/xmltooling.git
 [submodule "cyrus-sasl"]
        path = cyrus-sasl
-       url = ../cyrus-sasl
+       url = http://www.project-moonshot.org/git/cyrus-sasl
 [submodule "shibboleth/resolver"]
        path = shibboleth/resolver
-       url = ../shibboleth/resolver.git
+       url = http://www.project-moonshot.org/git/shibboleth/resolver.git
 [submodule "libeap"]
        path = libeap
-       url = ../libeap.git
+       url = http://www.project-moonshot.org/git/libeap.git
diff --git a/debian-builder b/debian-builder
new file mode 100755 (executable)
index 0000000..d371780
--- /dev/null
@@ -0,0 +1,169 @@
+#!/usr/bin/python
+
+'''A script to build Debian packages using sbuild from a source
+directory rather than a source package. Also, if multiple packages are
+built, previous packages are available to satisfy
+dependencies. Requires that the build-place be available from the
+chroot.
+'''
+
+from contextlib import contextmanager
+import os, subprocess, exceptions
+import re
+import sys
+from optparse import OptionParser
+from shutil import copy
+
+import debian.changelog, debian.deb822
+
+
+# These variables can be overridden by options. If packages is not
+# set, then it is read from the source_packages file
+packages = []  # Set of packages to build
+distribution = "sid"
+build_place = os.path.join(os.getcwd(), 'debian_build')
+
+class CommandError(exceptions.StandardError):
+    pass
+
+@contextmanager
+def current_directory(dir):
+    "Change the current directory as a context manager; when the context exits, return."
+    cwd = os.getcwd()
+    os.chdir(dir)
+    yield
+    os.chdir(cwd)
+
+
+def run_cmd(args, **kwords):
+    rcode =  subprocess.call( args, **kwords)
+    if rcode <> 0:
+        raise CommandError(args)
+
+def command_output(args) :
+    p = subprocess.Popen(args, stdout=subprocess.PIPE)
+    output = p.communicate()
+    output = output[0]
+    if p.returncode != 0:
+        raise CommandError(args)
+    return output
+
+def dsc_files(dsc) :
+    '''Describe all the files included in dsc, wich is a string name
+    of a dsc package. dsc itself is included'''
+    package = debian.deb822.Dsc(file(dsc))
+    internal_files = map( lambda(x): x['name'], package['Files'])
+    internal_files.append(dsc)
+    return internal_files
+
+def build(package):
+    with current_directory(package):
+        cl = debian.changelog.Changelog(file('debian/changelog'))
+        package_name = cl.package
+        package_version = str(cl.version)
+        orig_tgz = package_name+'_'+ cl.upstream_version + ".orig.tar.gz"
+        dsc_name = package_name+"_"+package_version + ".dsc"
+        print "==> Package: ", package_name
+        source_format = command_output(('dpkg-source', '--print-format', '.'))
+        if "native" not in source_format:
+            run_cmd( ('pristine-tar', 'checkout', '../'+orig_tgz))
+    package_path = os.path.split(package)
+    with current_directory(os.path.join ('.', *package_path[0:len(package_path)-1])) :
+        package_path = package_path[len(package_path)-1]
+        try:
+            run_cmd(("dpkg-source", '-b', '-i', package_path))
+            for f in dsc_files(dsc_name):
+                copy(f, build_place)
+        finally:
+            for f in dsc_files(dsc_name):
+                try: os.unlink(f)
+                except OSError: pass
+    with current_directory(build_place):
+        sb = ['sbuild', '-n', '-d', distribution, '--setup-hook',
+    build_place + '/add_source']
+        if sbuild_opts is not None: sb += sbuild_opts
+        sb.append(dsc_name)
+        print " ".join(sb)
+        sys.stdout.flush()
+        run_cmd(sb)
+
+def gen_package_files() :
+    '''Generate package files in build_place and a script
+    build_place/add_source that can be used as a sbuild setup hook to
+    include the package files. Unfortunately, apt doesn't have a
+    mechanism for asserting that a package file is trusted when it is
+    local. We could generate a unique gpg key, generate signed
+    releases files and trust that key. It's easier to simply touch the
+    release.gpg in apt's lists directory, which turns out to do what
+    we need.'''
+    # Rather than substuting the release file directly, we create gpg
+    # release files for any  local package list. That's easier than
+    # encoding apt's ideas about what characters to escape.
+    script = '''#!/bin/sh
+    set -e
+    echo deb file:{build_place} ./ >>/etc/apt/sources.list
+    apt-get update
+    touch $(ls /var/lib/apt/lists/_*Packages \
+        |sed -e s:Packages\$:Release.gpg:)
+    '''.format (
+        build_place = build_place
+        )
+    f = file(build_place + "/add_source", "w")
+    f.write(script)
+    f.close()
+    with current_directory(build_place):
+        run_cmd(('chmod', 'a+x', 'add_source'))
+        run_cmd( 'dpkg-scanpackages . >Packages',
+                 shell = True)
+
+
+def read_packages():
+    '''Read in the packages file from source_packages
+    '''
+    try: pf = file("source_packages")
+    except IOError:
+        print "Error: source_packages file not found"
+        exit(1)
+    def is_comment(line):
+        if re.match("^\\s*#", line): return False
+        if "#" in line: raise ValueError(
+            "Source package line contains a comment but not at beginning")
+        return True
+    return map(lambda(x): x.rstrip(),
+        filter(is_comment, pf.readlines()))
+
+
+# main program
+opt = OptionParser()
+opt.add_option('-b', '--build-place',
+               dest='build_place', help="Write resulting packages to BUILD_PLACE",
+               default=build_place)
+opt.add_option('-d', '--distribution',
+               help="Set the Debian distribution to DISTRIBUTION",
+               dest="distribution",
+               default=distribution
+               )
+opt.add_option('-s', '--sbuild-opt',
+               action='append', dest='sbuild_opts',
+               help='Specify an option to be sent to sbuild')
+opt.usage = "%prog [options] [packages]"
+(options, packages) = opt.parse_args()
+build_place = options.build_place
+distribution = options.distribution
+sbuild_opts = options.sbuild_opts
+
+if len(packages) == 0: packages = read_packages()
+
+try:
+    os.makedirs(build_place)
+except OSError: pass
+
+try:
+    for p in packages:
+        gen_package_files()
+        build(p)
+except CommandError as c:
+    print "Error:" + str(c.args)
+    exit(1)
+
+    
index 4fd67fc..18d1f38 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 4fd67fc08a6e1773419f51f7f58904cc013e0124
+Subproject commit 18d1f3824aabfb06bfbcbbc7845ca2f3cddd4c9f
index fbf40fe..d15449b 160000 (submodule)
@@ -1 +1 @@
-Subproject commit fbf40fe5dba573334df067d95b6f18b68d8f70b8
+Subproject commit d15449bd5b32c113613c4e7842d771b91360251e
diff --git a/source_packages b/source_packages
new file mode 100644 (file)
index 0000000..f5f9a72
--- /dev/null
@@ -0,0 +1,5 @@
+# This file contains a list of directories containing 
+# Debian source packages one per line.
+# Lines starting with # are comments
+shibboleth/xmltooling
+shibboleth/opensmal2