Build fixes for non-Windows
[moonshot.git] / builder
diff --git a/builder b/builder
index 81415f7..0b45f46 100755 (executable)
--- a/builder
+++ b/builder
@@ -18,6 +18,8 @@ packages = []  # Set of packages to build
 prefix = "/usr/local/moonshot"
 root_command = "fakeroot"
 
+schroot_command = ""
+
 class CommandError(exceptions.StandardError):
     pass
 
@@ -28,7 +30,7 @@ class Schroot(object):
         '''Initialize a new schroot option from the named
         schroot. Unless the named schroot starts with session:, then a
         new session schroot is created.'''
-        if name.startswith('session:'):
+        if not name.startswith('session:'):
             self.name = command_output(('schroot', '-b',
                                         '-c', name))
             self.end_session = True
@@ -67,11 +69,15 @@ def command_output(args) :
 def build(package):
     with current_directory(package):
         run_cmd(('autoreconf', '-i', '-f'))
-        configure_command = ' '.join(['./configure'] + configure_opts)
+        configure_command = ' '.join([
+                                      './configure'] + configure_opts)
+        if len(schroot_command) > 0:
+            configure_command = schroot_command + " -- " \
+                + configure_command
         print configure_command
         sys.stdout.flush()
         run_cmd(configure_command, shell=True)
-        run_cmd('make')
+        run_cmd(schroot_command + ' make', shell=True)
 
 def make_install(package):
     with current_directory(package):
@@ -119,20 +125,26 @@ opt.usage = "%prog [options] [packages]"
 prefix = options.prefix
 root_command = options.root_command
 configure_opts = ['--prefix', prefix,
-                  "LDFLAGS='-Wl,-L "+prefix+"/lib"
-                  + " -Wl,-R"+prefix+"/lib'",
-                  'CPPFLAGS="-I '+prefix+'/include"']
+                  "LDFLAGS='-Wl,-L"+prefix+"/lib -Wl,-L/usr/lib/freeradius"
+                  + " -Wl,-rpath="+prefix+"/lib'",
+                  'CPPFLAGS="-I '+prefix+'/include"',
+                  '--with-system-libtool', '--with-system-libltdl',
+                  '--enable-tls', '--with-gssapi='+prefix,
+                  "--with-xmltooling="+prefix, 
+                  ]
 if options.configure_opts is not None: 
     configure_opts.extend(options.configure_opts)
 
 our_schroot = None
 if options.schroot is not None:
     our_schroot = Schroot(options.schroot)
-    root_command = "schroot -r -c " + our_schroot.name
+    schroot_command = "schroot -r -c " + our_schroot.name
+    root_command = schroot_command + " -u root"
 
 all_packages = read_packages()
 if len(packages) == 0: packages = all_packages
 
+os.umask(022)
 
 try:
     for p in all_packages:
@@ -140,7 +152,7 @@ try:
         make_install(p)
 except CommandError as c:
     print "Error:" + str(c.args)
-    del our_schroot
+    our_schroot = None
     exit(1)
 finally: del our_schroot