Include freeradius in build
authorSam Hartman <hartmans@debian.org>
Fri, 28 Mar 2014 10:26:30 +0000 (06:26 -0400)
committerSam Hartman <hartmans@debian.org>
Fri, 28 Mar 2014 10:26:30 +0000 (06:26 -0400)
Both for master and Centos

builder
freeradius-server
rpm-builder
rpm_packages
source_packages

diff --git a/builder b/builder
index 7438909..9a924ca 100755 (executable)
--- a/builder
+++ b/builder
@@ -70,7 +70,10 @@ def build(package):
     with current_directory(package):
         try: os.makedirs( "m4")
         except OSError: pass
-        run_cmd(('autoreconf', '-i', '-f'))
+        #On Centos, freeradius produces an invalid configure script
+        # They check in a configure script anyway so we don't need autoconf
+        if package != "freeradius-server":
+            run_cmd(('autoreconf', '-i', '-f'))
         configure_command = [
                                       './configure'] + configure_opts
         if len(schroot_command) > 0:
@@ -83,7 +86,10 @@ def build(package):
             try: os.mkdir('doc/api')
             except: pass
             #Currently freeradius's make dist is broken
-            if not package == "freeradius-server":
+            if package == "freeradius-server":
+                run_cmd(root_command + " git archive --prefix=freeradius-server/ HEAD |gzip -9 >freeradius-server.tar.gz", shell=True)
+                run_cmd('cp *.tar.gz freeradius-server.spec ' +dist_dir, shell=True)
+            else: #not specially handled
                 run_cmd(root_command +' make dist-gzip', shell=True)
                 run_cmd('cp *.tar.gz ' +dist_dir, shell=True)
         run_cmd(schroot_command + ' make -j3', shell=True)
index 2c1491f..f4f8b6a 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 2c1491fc310f2afd09ba661a308b12d681c37a31
+Subproject commit f4f8b6ac2edb4119e636705800f8be98c43914f5
index bfcfa54..e7a9d91 100755 (executable)
@@ -20,13 +20,53 @@ tar_file = None
 class CommandError(exceptions.StandardError):
     pass
 
-def is_tarball(name):
-    return re.match('^.*\\.tar\\.gz', name)
-
-def trim_tarball(t):
+# Centos 6.5 does not have collections.OrderedDict
+# This implementation provides the minimal functionality of OrderedDict that we need
+# It works here, but should not be counted on for anything else.
+class OrderedDict(dict):
+
+    def __setitem__(self,k, v):
+        if k not in self:
+            self.keylist.append(k)
+        return             super(OrderedDict,self).__setitem__(k,v)
+
+    def __init__(self, *args, **kwargs):
+        super(OrderedDict,self).__init__(*args, **kwargs)
+        self.keylist = []
+
+    def values(self):
+        return map( lambda(elt): self[elt], self.keylist)
+
+builder_by_type = {
+    '.tar.gz': lambda(t): run_cmd([ 'rpmbuild', '-ta', t]),
+    '.spec':
+    lambda(s): run_cmd(['rpmbuild', '--define', '_sourcedir '+os.getcwd(),
+                        '-ba', s]),
+    }
+
+
+def find_type(name):
+    match = re.match('^.*(\\.tar\\.gz|\\.spec)$', name)
+    if match:
+        return match.group(1)
+    else: return None
+        
+
+# The following regexp is not quite right.
+# One place is the rpm_packages file.
+# The other is the directory listing.
+# The rpm_packages file might have entries like shibboleth/xmltooling
+# Where as the distributions directory might have xmltooling-1.5.tar.gz
+# Two requirements for correct operation:
+# trim_target produces unique results for everything in rpm_packages
+# trim_target correctly trims what's in the packages file to the same
+# thing it trims the tar file or spec file to.
+#
+def trim_target(t):
     match = re.match('([^/-]*/)?([^-/]+)', t)
     return match.group(2)
 
+    
 @contextmanager
 def current_directory(dir):
     "Change the current directory as a context manager; when the context exits, return."
@@ -50,7 +90,7 @@ def command_output(args) :
     return output.strip()
 
 def build(package):
-    run_cmd(['rpmbuild', '-ta', package])
+    return builder_by_type[find_type(package)](package)
 
 
 
@@ -86,14 +126,20 @@ if len(args) == 0:
     exit(1)
 dist_dir = args[0]
 packages = args[1:]
-
 if len(packages) == 0: packages = read_packages()
-package_order = {}
-count = 0
-tarballs = filter(is_tarball, os.listdir(dist_dir))
+package_order = OrderedDict()
 for t in packages:
-    package_order[trim_tarball(t)] = count
-    count += 1
+    package_order[trim_target(t)] = None
+
+for t in os.listdir(dist_dir):
+    target_type = find_type(t)
+    if target_type is None: continue
+    trimmed = trim_target(t)
+    if target_type == ".spec":
+        package_order[trimmed] = t
+    else:
+        if trimmed not in package_order: package_order[trimmed] = t
+
     
 
 os.umask(022)
@@ -102,9 +148,12 @@ try:
     run_cmd([ 'rm', '-rf',
               os.path.expanduser("~/rpmbuild")])
     run_cmd([ 'rpmdev-setuptree'])
+    for f in os.listdir("rpm-sources"):
+        copy("rpm-sources/" + f, dist_dir)
+
     with current_directory(dist_dir):
-        tarballs.sort (key = lambda x: package_order[trim_tarball(x)])
-        for t in tarballs:
+        for t in package_order.values():
+            if t is None: continue
             build(t)
     if tar_file is not None:
         with current_directory(os.path.expanduser("~/rpmbuild")):
index e74b5af..c0c4e3e 100644 (file)
@@ -10,4 +10,6 @@ jansson
 moonshot-ui
 mech_eap
 trust_router
+freeradius-server
+
 #cyrus-sasl
index 527543d..4180db7 100644 (file)
@@ -11,3 +11,4 @@ ui
 moonshot
 #cyrus-sasl
 trust_router
+freeradius-server