def get_managed_bundles(cwd): res = list() bundles = parseBundles(cwd=cwd) tracUrl = getTracConfig(cwd=cwd).get('TracUrl') for (unused_id, bundle) in sorted(bundles.items()): res.append(common_interfaces.ManagedBundle(bundle, tracBaseUrl=tracUrl)) return res
def get_managed_bundle_infos(bundleIds, cwd): repoSuites = getBundleRepoSuites(bundleIds, cwd=cwd) bundles = parseBundles(repoSuites, selectIds=[str(s) for s in repoSuites], cwd=cwd) tracUrl = getTracConfig(cwd=cwd).get('TracUrl') res = [ common_interfaces.ManagedBundleInfo(bundle, tracBaseUrl=tracUrl) for bundle in bundles.values() ] return res
def cmd_stage(args): ''' Marks specified bundles to be put into a particular stage. ''' stageStatus = BundleStatus.getByStage(args.stage[0]) bundles = parseBundles(getBundleRepoSuites()) ids = set() if args.bundleName: ids = ids.union(args.bundleName) if args.candidates: candidates = filterBundles(bundles, stageStatus.getCandidates()) ids = ids.union([bundle.getID() for bundle in candidates]) markBundlesForStatus(bundles, ids, stageStatus, args.force)
def cmd_jsondeps(args): ''' Dump information about dependent bundles (sharing same binary packages with different versions) into a json file. ''' with apt_repos.suppress_unwanted_apt_pkg_messages() as forked: if forked: logger.info("Scanning Bundles") bundles = parseBundles(getBundleRepoSuites()) logger.info("Extracting Bundle-Dependencies") packages = list() for bid, bundle in sorted(bundles.items()): suite = bundle.getRepoSuite() if suite and bundle.getStatus( ) > BundleStatus.STAGING and bundle.getStatus( ) < BundleStatus.PRODUCTION: logger.debug("Querying Packages for {} [{}]".format( bid, bundle.getStatus())) suite.scan(True) res = suite.queryPackages(".", True, None, None, [ PackageField.BINARY_PACKAGE_NAME, PackageField.VERSION, PackageField.SUITE ]) packages.extend(res) bundleDeps = list() packageDeps = list() knownRelations = set() last = None for p in sorted(packages): (package, unused_version, suite) = p.getData() if package != last: last = package packageDeps.clear() for dep in packageDeps: rel = "{}:{}".format(suite, dep) if not rel in knownRelations: knownRelations.add(rel) bundleDeps.append([str(suite), str(dep)]) packageDeps.append(suite) with open(args.outputFilename[0], "w", encoding="utf-8") as jsonFile: print(json.dumps(sorted(bundleDeps, reverse=True), sort_keys=True, indent=4), file=jsonFile) logger.info( "Bundle-Dependencies SUCCESSFULLY dumped to file '{}'".format( args.outputFilename[0]))
def cmd_jsondump(args): ''' Dump bundle-infos to a json file. ''' with open(args.outputFilename[0], "w", encoding="utf-8") as jsonFile: logger.info("Scanning Bundles") bundles = parseBundles(getBundleRepoSuites()) config = getTracConfig() tracUrl = config.get('TracUrl') parentTicketsField = config.get('UseParentTicketsFromInfoField') logger.info("Extracting Bundle-Infos") bundleInfos = list() for bid, bundle in sorted(bundles.items()): logger.debug("Extracting Infos for {}".format(bid)) bundleInfos.append( __extractBundleInfos(bundle, tracUrl, parentTicketsField)) print(json.dumps(bundleInfos, sort_keys=True, indent=4), file=jsonFile) logger.info("Bundles-Infos SUCCESSFULLY dumped to file '{}'".format( args.outputFilename[0]))
def mark_bundles_for_target(bundleIds, target, ignoreTargetFromInfoFile, cwd): res = [] with common_app_server.logging_redirect_for_webapp() as logs: try: repo = git.Repo(cwd) ensure_clean_git_repo(repo) bundles = parseBundles(getBundleRepoSuites(bundleIds, cwd=cwd), cwd=cwd) reprepro_bundle_compose.markBundlesForTarget( bundles, bundleIds, target, cwd, ignoreTargetFromInfoFile) msg = "MARKED for target '{}'\n\n - {}".format( target, "\n - ".join(sorted(bundleIds))) if len(bundleIds) == 1: msg = "MARKED {} for target '{}'".format( "".join(bundleIds), target) git_commit(repo, [BUNDLES_LIST_FILE], msg) except GitNotCleanException as e: logger.error(e) finally: res = logs.toBackendLogEntryList() return res
def cmd_list(args): ''' List all bundles grouped by their status / stage. ''' bundles = parseBundles(getBundleRepoSuites()) tracUrl = getTracConfig().get('TracUrl') nl = "" for status in BundleStatus: if args.stage and not status.getStage() == args.stage: continue selected = filterBundles( bundles, status if not args.candidates else status.getCandidates()) if len(selected) > 0: headline = "{}{} '{}'{}:".format( nl, "Bundles with status" if not args.candidates else "Candidates for status", status, " (stage '" + status.getStage() + "')" if status.getStage() else "") if True: # make it switchable later? print("{}\n{}".format(headline, "=" * len(headline))) listBundles(selected, tracUrl) nl = "\n"
def mark_bundles_for_status(bundleIds, status, cwd): res = [] with common_app_server.logging_redirect_for_webapp() as logs: try: repo = git.Repo(cwd) ensure_clean_git_repo(repo) bundles = parseBundles(cwd=cwd) reprepro_bundle_compose.markBundlesForStatus(bundles, bundleIds, status, force=True, checkOwnSuite=False, cwd=cwd) msg = "MARKED for status '{}'\n\n - {}".format( status, "\n - ".join(sorted(bundleIds))) if len(bundleIds) == 1: msg = "MARKED {} for status '{}'".format( "".join(bundleIds), status) git_commit(repo, [BUNDLES_LIST_FILE], msg) except GitNotCleanException as e: logger.error(e) finally: res = logs.toBackendLogEntryList() return res
def cmd_apply(args): ''' Applies the bundles list to the reprepro configuration for all target suites. ''' bundles = parseBundles(getBundleRepoSuites()) createTargetRepreproConfigs(bundles)