X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=builder;h=4f7e477c0f0dafc5f6ae179a4dd2fff6eca2cfca;hb=504bbd8f12f895ce7aa06920b999498aa75abd59;hp=2bc3a21dff2ee29802d49ee23a12f0a6953e11cf;hpb=48f128b619dea474291620a57304db8d3975139c;p=moonshot.git diff --git a/builder b/builder index 2bc3a21..4f7e477 100755 --- 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 @@ -66,12 +68,25 @@ def command_output(args) : def build(package): with current_directory(package): + try: os.makedirs( "m4") + except OsError: pass run_cmd(('autoreconf', '-i', '-f')) - configure_command = ' '.join(['./configure'] + configure_opts) - print configure_command + configure_command = [ + './configure'] + configure_opts + if len(schroot_command) > 0: + configure_command = schroot_command.split(' ') \ + + configure_command + print ' '.join(configure_command) sys.stdout.flush() - run_cmd(configure_command, shell=True) - run_cmd('make') + run_cmd(configure_command, shell=False) + if dist: + try: os.mkdir('doc/api') + except: pass + #Currently freeradius's make dist is broken + if not package == "freeradius-server": + 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) def make_install(package): with current_directory(package): @@ -81,7 +96,6 @@ def make_install(package): run_cmd(install_command, shell=True) - def read_packages(): '''Read in the packages file from source_packages ''' @@ -114,35 +128,59 @@ 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,-R"+prefix+"/lib'", - 'CPPFLAGS="-I '+prefix+'/include"'] + "LDFLAGS=-Wl,-L"+prefix+"/lib -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) +tar_file = options.tar_file +if tar_file is not None: dist = True our_schroot = None if options.schroot is not None: our_schroot = Schroot(options.schroot) - root_command = "schroot -r -c " + our_schroot.name + schroot_command_base = "schroot -r -c " + our_schroot.name + root_command = schroot_command_base + " -u root --" + schroot_command = schroot_command_base + ' --' 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) + if packages[-1] == p : break 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 - - -