def __init__(self, pkgdir): # XXX(ot): better exceptions? metadata version handling? self._path = pkgdir self._name = os.path.basename(pkgdir) self._dict = load_info(_pkg_info_file(pkgdir)) # Sanity check for k in ['app_name', 'app_version', 'enabled']: if k not in self._dict: raise UserError('Invalid package')
def __init__(self, pkgdir): # XXX(ot): better exceptions? metadata version handling? self._path = pkgdir self._name = os.path.basename(pkgdir) self._dict = load_info(_pkg_info_file(pkgdir)) # Sanity check for k in ["app_name", "app_version", "enabled"]: if k not in self._dict: raise UserError("Invalid package")
def __init__(self, box_path): self._path = os.path.abspath(box_path) try: box_info = load_info(os.path.join(self.path, "bpt_meta", "box_info")) except (OSError, IOError): raise UserError("Invalid box: impossible to read box_info") try: self._id = box_info["id"] self._platform = box_info["platform"] except KeyError, exc: raise UserError('Invalid box_info: missing "%s"', str(exc))
def __init__(self, box_path): self._path = os.path.abspath(box_path) try: box_info = load_info( os.path.join(self.path, 'bpt_meta', 'box_info')) except (OSError, IOError): raise UserError('Invalid box: impossible to read box_info') try: self._id = box_info['id'] self._platform = box_info['platform'] except KeyError, exc: raise UserError('Invalid box_info: missing "%s"', str(exc))
def __init__(self, box_path): self._path = os.path.abspath(box_path) try: box_info = load_info(os.path.join(self.path, 'bpt_meta', 'box_info')) except (OSError, IOError): raise UserError('Invalid box: impossible to read box_info') try: self._id = box_info['id'] self._platform = box_info['platform'] except KeyError, exc: raise UserError('Invalid box_info: missing "%s"', str(exc))
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
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 + "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