Support --dist and --tar-file swiwtches in builder
[moonshot.git] / builder
diff --git a/builder b/builder
index 83c25e5..4fec9a1 100755 (executable)
--- a/builder
+++ b/builder
@@ -77,6 +77,11 @@ def build(package):
         print configure_command
         sys.stdout.flush()
         run_cmd(configure_command, shell=True)
+        if dist:
+            try: os.mkdir('doc/api')
+            except: pass
+            run_cmd(schroot_command +' make dist-gzip', shell=True)
+            run_cmd('cp *.tar.gz ' +dist_dir, shell=True)
         run_cmd(schroot_command + ' make', shell=True)
 
 def make_install(package):
@@ -87,7 +92,6 @@ def make_install(package):
         run_cmd(install_command, shell=True)
         
 
-
 def read_packages():
     '''Read in the packages file from source_packages
     '''
@@ -120,20 +124,31 @@ opt.add_option('-s', '--schroot',
                dest="schroot",
                help="Specify name of schroot to use for build;"
                "implicitly sets root_command")
+opt.add_option( '--dist', action='store_true',
+                default=False, dest='dist',
+                help = 'make dist-gzip in addition to the build'
+                )
+opt.add_option('--tar-file',
+               dest='tar_file',
+               help = 'Tar up resulting distributions in given tar file',
+               default = None)
 opt.usage = "%prog [options] [packages]"
 (options, packages) = opt.parse_args()
 prefix = options.prefix
 root_command = options.root_command
+dist = options.dist
 configure_opts = ['--prefix', prefix,
                   "LDFLAGS='-Wl,-L"+prefix+"/lib -Wl,-L/usr/lib/freeradius"
-                  + " -Wl,-rpath"+prefix+"/lib'",
+                  + " -Wl,-rpath="+prefix+"/lib'",
                   'CPPFLAGS="-I '+prefix+'/include"',
                   '--with-system-libtool', '--with-system-libltdl',
-                  '--enable-tls',
+                  '--enable-tls', '--with-gssapi='+prefix,
                   "--with-xmltooling="+prefix, 
                   ]
 if options.configure_opts is not None: 
     configure_opts.extend(options.configure_opts)
+tar_file = options.tar_file
+if tar_file is not None: dist = True
 
 our_schroot = None
 if options.schroot is not None:
@@ -145,16 +160,22 @@ all_packages = read_packages()
 if len(packages) == 0: packages = all_packages
 
 os.umask(022)
+if dist:
+    try:
+        os.mkdir('distributions')
+    except: pass
+    dist_dir = os.path.join(os.getcwd(), 'distributions')
 
 try:
     for p in all_packages:
         if p in packages: build(p)
         make_install(p)
+    if tar_file is not None:
+        with current_directory(dist_dir):
+            run_cmd(['tar', '-cf', tar_file,
+                     '.'])
 except CommandError as c:
     print "Error:" + str(c.args)
     our_schroot = None
     exit(1)
 finally: del our_schroot
-
-    
-