def main(): p = option_parser() (options, args) = p.parse_args() RU.init_log(DEBUG if options.verbose else INFO) if not args: p.print_usage() sys.exit(1) # host_prof_specs = args[0] root = os.path.abspath(options.root) all_rpms = [x["name"] for x in RR.list_installed_rpms(root)] (excludes, removes) = make_excl_packages_list(options.ppaths, options.gpaths) remove_candidates = RU.select_from_list(removes, all_rpms) if options.use_dnf: (excludes, xs) = RED.compute_removed(remove_candidates, root, excludes) else: xs = RR.compute_removed(remove_candidates, root, excludes=excludes) data = dict(removed=xs, excludes=excludes) if options.output: anyconfig.dump(dict(data=data, ), options.output, forced_type="yaml") else: res = anyconfig.dumps(dict(data=data, ), forced_type="yaml") print(res)
def main(): p = option_parser() (options, args) = p.parse_args() RU.init_log(DEBUG if options.verbose else INFO) if not args: p.print_usage() sys.exit(1) rpmlist_path = args[0] if not options.dryrun and not os.path.exists(os.path.join(options.rpmsdir, 'redhat')): print("RPMs dir does not look exist under: " + options.rpmsdir) sys.exit(1) make_rpmdb(rpmlist_path, options.rpmsdir, options.root, options.sw_options, options.nprocs, options.dryrun)
def main(cmd_map=_ARGS_CMD_MAP): p = option_parser() (options, args) = p.parse_args() RU.init_log(DEBUG if options.verbose else INFO) if not args: p.print_usage() sys.exit(1) (cmd, rpms) = (args[0], args[1:]) cmd = cmd_map.get(cmd[0], cmd_map.get(cmd[:3], False)) if not cmd: print("Error: Invalid command: " + cmd) p.print_usage() sys.exit(1) root = os.path.abspath(options.root) all_rpms = [x["name"] for x in RR.list_installed_rpms(root)] if options.excludes: if is_file(options.excludes): excludes = load_list_from_file(options.excludes) else: excludes = options.excludes.split(',') excludes = RU.select_from_list(excludes, all_rpms) logging.info("%d RPMs found in given excludes list" % len(excludes)) else: excludes = [] if cmd == CMD_REMOVE: if not rpms: print("remove (erase) command requires RPMs: list of RPM names or " "glob/regex patterns, or a file contains RPM names or " "glob/regex patterns line by line") sys.exit(1) if len(rpms) == 1 and is_file(rpms[0]): rpms = load_list_from_file(rpms[0]) rpms = RU.select_from_list(rpms, all_rpms) if options.use_dnf: (excludes, xs) = RED.compute_removed(rpms, root, excludes) else: xs = RR.compute_removed(rpms, root, excludes=excludes) data = dict(removed=xs, ) elif cmd == CMD_STANDALONES: xs = sorted(RR.list_standalones(root, options.st_nrpms, excludes)) data = dict(standalones=xs, ) elif cmd == CMD_UPDATES: xs = [dict(name=x.name, version=x.version, release=x.release, arch=x.arch, epoch=int(x.epoch)) for x in RED.compute_updates(root, options.repos, True)] if options.latest: xs = RR.find_latests(xs) if options.format == 'simple': xfmt = "%(name)s-%(epoch)s:%(version)s-%(release)s.%(arch)s" xs = sorted(xfmt % x for x in xs) data = dict(updates=xs, ) else: xs = sorted(RR.get_leaves(root)) data = dict(leaves=xs, ) output = open(options.output, 'w') if options.output else sys.stdout if options.format != "simple": if options.output: anyconfig.dump(dict(data=data, ), options.output, forced_type=options.format) else: res = anyconfig.dumps(dict(data=data, ), forced_type=options.format) print(res) else: if options.output: ext = os.path.splitext(options.output)[1][1:] if ext in _FMT_CHOICES: anyconfig.dump(dict(data=data, ), options.output, forced_type=ext) else: with open(options.output, 'w') as out: for x in xs: out.write(x + '\n') else: for x in xs: print(x) output.close()
def main(cmd_map=_ARGS_CMD_MAP): p = option_parser() (options, args) = p.parse_args() RU.init_log(DEBUG if options.verbose else INFO) if not args: p.print_usage() sys.exit(1) (cmd, rpms) = (args[0], args[1:]) cmd = cmd_map.get(cmd[0], cmd_map.get(cmd[:3], False)) if not cmd: print("Error: Invalid command: " + cmd) p.print_usage() sys.exit(1) root = os.path.abspath(options.root) all_rpms = [x["name"] for x in RR.list_installed_rpms(root)] if options.excludes: if is_file(options.excludes): excludes = load_list_from_file(options.excludes) else: excludes = options.excludes.split(',') excludes = RU.select_from_list(excludes, all_rpms) logging.info("%d RPMs found in given excludes list" % len(excludes)) else: excludes = [] if cmd == CMD_REMOVE: if not rpms: print("remove (erase) command requires RPMs: list of RPM names or " "glob/regex patterns, or a file contains RPM names or " "glob/regex patterns line by line") sys.exit(1) if len(rpms) == 1 and is_file(rpms[0]): rpms = load_list_from_file(rpms[0]) rpms = RU.select_from_list(rpms, all_rpms) if options.use_dnf: (excludes, xs) = RED.compute_removed(rpms, root, excludes) else: xs = RR.compute_removed(rpms, root, excludes=excludes) data = dict(removed=xs, ) elif cmd == CMD_STANDALONES: xs = sorted(RR.list_standalones(root, options.st_nrpms, excludes)) data = dict(standalones=xs, ) elif cmd == CMD_UPDATES: xs = [ dict(name=x.name, version=x.version, release=x.release, arch=x.arch, epoch=int(x.epoch)) for x in RED.compute_updates(root, options.repos, True) ] if options.latest: xs = RR.find_latests(xs) if options.format == 'simple': xfmt = "%(name)s-%(epoch)s:%(version)s-%(release)s.%(arch)s" xs = sorted(xfmt % x for x in xs) data = dict(updates=xs, ) else: xs = sorted(RR.get_leaves(root)) data = dict(leaves=xs, ) output = open(options.output, 'w') if options.output else sys.stdout if options.format != "simple": if options.output: anyconfig.dump(dict(data=data, ), options.output, forced_type=options.format) else: res = anyconfig.dumps(dict(data=data, ), forced_type=options.format) print(res) else: if options.output: ext = os.path.splitext(options.output)[1][1:] if ext in _FMT_CHOICES: anyconfig.dump(dict(data=data, ), options.output, forced_type=ext) else: with open(options.output, 'w') as out: for x in xs: out.write(x + '\n') else: for x in xs: print(x) output.close()