def autobuild_dir(box, source_dir, basename, configure_options, stdout=None): name, version = guess_name_version(basename) log.info('Guessed application name "%s", version "%s"', name, version) # XXX(ot): disable package if something goes wrong? pkg = box.create_package(basename, app_name=name, app_version=version, enabled=False) if os.path.exists(os.path.join(source_dir, 'configure')): cmd_list = [ "./configure --prefix '%s' %s" % (pkg.path, configure_options), "make -j%d install" % cpu_count() ] elif os.path.exists(os.path.join(source_dir, 'setup.py')): envvars = '' if SETUPTOOLS_WORKAROUND: # Workaround two bugs of setuptools # (fixed in http://bugs.python.org/setuptools/issue54 ) # - Put the site-packages path in python's path # - Create the site-packages directory # XXX(ot): find a better solution # XXX(ot): this assumes that python inside the box is the same as the current python_version = '.'.join([str(x) for x in sys.version_info[:2]]) site_path = '%s/lib/python%s/site-packages/' % (pkg.path, python_version) envvars = 'PYTHONPATH="%s${PYTHONPATH:+:$PYTHONPATH}"' % site_path try: os.makedirs(site_path) except OSError: pass cmd_list = [ "%s python setup.py install --prefix '%s' %s" % (envvars, pkg.path, configure_options), ] else: raise UnsupportedPath('Do not know how to build source') log.info('Building and installing as package %s', pkg.name) for cmd in cmd_list: check_call(['bash', '-e', box.env_script, cmd], cwd=source_dir, stdout=stdout) box.enable_package(pkg)
def build(self, box, name_suffix='', stdout=None): appname = self.get_var('BPT_APP_NAME') version = self.get_var('BPT_APP_VERSION') # Check last box the sourcedir was built in bpt_status_file = os.path.join(self.path, '.bpt_status') if os.path.exists(bpt_status_file): bpt_status = load_info(bpt_status_file) last_box_id = bpt_status.get('last_box_id', box.box_id) if last_box_id != box.box_id: log.info( 'Intermediate files built for another package box. Cleaning first.' ) self.clean() # Write the current box_id store_info(bpt_status_file, dict(last_box_id=box.box_id)) if not box.check_platform(): raise UserError( 'Current platform is different from box\'s platform') pkg_name = '%s-%s%s' % (appname, version, name_suffix) pkg = box.create_package(pkg_name, app_name=appname, app_version=version, enabled=False) log.info('Building application %s, in sourcedir %s', appname, self._sourcedir) # Build sh_line = ('source "%s";' % BASE_SH_SCRIPT + 'cd "%s";' % self._sourcedir + 'export BPT_PKG_PREFIX="%s";' % pkg.path + 'export BPT_CPU_COUNT="%d";' % cpu_count() + 'source bpt-rules;' + 'bpt_download;' + 'bpt_unpack;' + 'bpt_build;') retcode = call(['bash', '-e', box.env_script, sh_line], stdout=stdout) if retcode != 0: raise UserError('FATAL: build script exited with status %s' % retcode) box.enable_package(pkg) return pkg
def build(self, box, name_suffix='', stdout=None): appname = self.get_var('BPT_APP_NAME') version = self.get_var('BPT_APP_VERSION') # Check last box the sourcedir was built in bpt_status_file = os.path.join(self.path, '.bpt_status') if os.path.exists(bpt_status_file): bpt_status = load_info(bpt_status_file) last_box_id = bpt_status.get('last_box_id', box.box_id) if last_box_id != box.box_id: log.info('Intermediate files built for another package box. Cleaning first.') self.clean() # Write the current box_id store_info(bpt_status_file, dict(last_box_id=box.box_id)) if not box.check_platform(): raise UserError('Current platform is different from box\'s platform') pkg_name = '%s-%s%s' % (appname, version, name_suffix) pkg = box.create_package(pkg_name, app_name=appname, app_version=version, enabled=False) log.info('Building application %s, in sourcedir %s', appname, self._sourcedir) # Build sh_line = ('source "%s";' % BASE_SH_SCRIPT + 'cd "%s";' % self._sourcedir + 'export BPT_PKG_PREFIX="%s";' % pkg.path + 'export BPT_CPU_COUNT="%d";' % cpu_count() + 'source bpt-rules;' + 'bpt_download;' + 'bpt_unpack;' + 'bpt_build;' ) retcode = call(['bash', '-e', box.env_script, sh_line], stdout=stdout) if retcode != 0: raise UserError('FATAL: build script exited with status %s' % retcode) box.enable_package(pkg) return pkg