def main(): import argparse global _options count = {} parser = argparse.ArgumentParser(description="Cleanups SRC_URI using mirrors://") parser.add_argument("packages", metavar="N", type=str, nargs="*", help="packages to check") parser.add_argument("-a", "--all", action="store_true", help="check all packages") parser.add_argument("-v", "--verbose", action="store_true", help="be verbose") parser.add_argument( "-d", "--diff", action="store_true", help="generate ebuild diff (default: print package name and message)" ) parser.add_argument( "-A", "--vanilla", action="store_true", help="use only Vanilla remote ids defined in current /usr/portage/metadata/dtd/metadata.dtd", ) parser.add_argument( "-p", "--preserve", action="store_true", help="if a remote id is found with the same type, preserve the existing remote id", ) parser.add_argument("-C", "--check", action="store_true", help="check if existing tags are valid") parser.add_argument( "-c", "--check-all", action="store_true", help="also check if all tags are valid (existing and generated)" ) args = parser.parse_args() _options = args if args.vanilla in sys.argv: global _accepted_types _accepted_types = types_from_dtd() if args.all: for package in get_cpvs(): upstream_remote_id_package(Package(package)) elif args.packages: for query in args.packages: upstream_remote_id(query) else: for package in sys.stdin.readlines(): upstream_remote_id(package.replace("\n", ""))
def main(): import argparse global _generate_diff, _thirdpartymirrors count = {} parser = argparse.ArgumentParser(description="Cleanups SRC_URI using mirrors://") parser.add_argument("packages", metavar="N", type=str, nargs="*", help="packages to check") parser.add_argument("-a", "--all", action="store_true", help="check all packages") parser.add_argument( "-d", "--diff", action="store_true", help="generate ebuild diff (default: print package name and message)" ) parser.add_argument( "-c", "--count", action="store_true", help="generate a list of widely used URI prefix that should use a mirror:// instead", ) parser.add_argument("-m", "--thirdpartymirrors", action="append", help="use this thirdpartymirrors file") args = parser.parse_args() _generate_diff = args.diff _thirdpartymirrors = args.thirdpartymirrors if not args.count: build_mirrors() action = check_package else: action = lambda x: add_package_prefix(x, count) if args.all: for package in get_cpvs(): action(Package(package)) elif args.packages: for query in args.packages: check_query(query, action) else: for package in sys.stdin.readlines(): check_query(package.replace("\n", ""), action) if args.count: end_prefix_count(count)