def make_packages(cls, packages): """builds a sets of package rules and returns the dict from package name to package version Args: packages (list) - list of package rules to build Returns: dict from package name to package version Raises: Error - one or more of the packages could not be created """ pkg_prefix = Packages.get_valid_package_prefix( GitUtil.get_latest_commit()[0:6]) tmp_fn = '%d_%d' % (int(time.time()), random.randint(1, 1e5)) cmd = 'flash --pkg_version_prefix=%s --pkg_version_path=%s run %s' % \ (pkg_prefix, tmp_fn, ' '.join(packages)) process = subprocess.Popen(['/bin/bash', '-c', cmd]) process.wait() if not process.returncode == 0: if os.path.exists(tmp_fn): # delete the temporary package file if it exists os.remove(tmp_fn) raise Error('one of more of the packages cannot be created') # construct the release yaml from the temp package list packages = {} with open(tmp_fn, 'r') as f: packages = yaml.safe_load(f) os.remove(tmp_fn) # delete the temporary package file return packages
def make_packages(cls, packages): """builds a sets of package rules and returns the dict from package name to package version Args: packages (list) - list of package rules to build Returns: dict from package name to package version Raises: Error - one or more of the packages could not be created """ pkg_prefix = Packages.get_valid_package_prefix( GitUtil.get_latest_commit()[0:6]) tmp_fn = '%d_%d' % (int(time.time()), random.randint(1, 1e5)) cmd = 'flash --pkg_version_prefix=%s --pkg_version_path=%s run %s' % \ (pkg_prefix, tmp_fn, ' '.join(packages)) process = subprocess.Popen(['/bin/bash', '-c', cmd]) process.wait() if not process.returncode == 0: if os.path.exists(tmp_fn): # delete the temporary package file if it exists os.remove(tmp_fn) raise Error('one of more of the packages cannot be created') # construct the release yaml from the temp package list packages = {} with open(tmp_fn, 'r') as f: packages = yaml.safe_load(f) os.remove(tmp_fn) # delete the temporary package file return packages
def run(self): """build and create the package Returns: tuple(string, string) the package name followed by the package version name """ if not Flags.ARGS.pkg_version_prefix: Flags.ARGS.pkg_version_prefix = Packages.get_valid_package_prefix( GitUtil.get_latest_commit()[0:6]) version = self._packager.make_package(self._rule) if Flags.ARGS.pkg_version_path: with open(Flags.ARGS.pkg_version_path, 'a') as f: config = {} config[version[0]] = version[1] f.write('%s' % yaml.safe_dump(config, default_flow_style=False)) return version