Example #1
0
def main():
    """ Main entrypoint for sinkhole
    """
    # top-level parser
    parser = argparse.ArgumentParser(description="sinkhole")
    parser.add_argument("--revision", action="store")
    parser.add_argument("--config", action="store", required=True)
    subparsers = parser.add_subparsers(dest="subcommand")
    subparsers.required = True

    # reposync
    parser_reposync = subparsers.add_parser("reposync",
                                            help="Sync repositories")
    parser_reposync.add_argument("--destdir", action="store", required=True)
    parser_reposync.add_argument("--repofile",
                                 action="append",
                                 dest="repofns",
                                 required=True)
    parser_reposync.add_argument("--include", action="append", default=None)
    parser_reposync.add_argument("--exclude", action="append", default=None)

    # kojidownload
    parser_koji = subparsers.add_parser("kojidownload",
                                        help="Download builds from Koji")
    parser_koji.add_argument("--profile",
                             action="store",
                             default="koji",
                             help="Koji instance to retrieve builds from")
    parser_koji.add_argument("--arch", action="store", nargs="+", default=None)
    parser_koji.add_argument("--builds",
                             action="store",
                             nargs="+",
                             required=True)
    parser_koji.add_argument("--destdir", action="store", required=True)

    # config_file
    parser_config = subparsers.add_parser("config_file",
                                          help="Use config file")

    # Run appropriate command
    args = parser.parse_args()

    config = Config.read_config(args.config) if args.config else Config()

    if args.subcommand == "reposync":
        config.output_dir = args.destdir
        reposync = Reposync(args.repofns, args.include, args.exclude)
        reposync.run()
    elif args.subcommand == "kojidownload":
        config.output_dir = args.destdir
        kojid = KojiDownloader(args.profile, args.builds, args.arch)
        kojid.run()
    else:
        sources = SourceBuilder.build()
        for source in sources:
            source.run()
        rm = RepoMasher(config.output_dir, revision=args.revision)
        rm.run()
Example #2
0
    def test_read_config(self):
        """Check that configuration file are properly parsed
        """
        data = StringIO("""[main]
workers = 8
output_dir = output/
releasever = 28
basearch = x86_64

[sources.fedora]
type=repofile
repofile=sources/fedora.repo
constraints=sources/fedora_constraints
""")
        config = Config.read_config(data)
        assert config.workers == 8
        assert config.output_dir == "output/"
        assert config.default_substitutions["releasever"] == "28"
        assert config.default_substitutions["basearch"] == "x86_64"