diff --git a/bin/repotool b/bin/repotool index cd6214c..810e99a 100755 --- a/bin/repotool +++ b/bin/repotool @@ -11,15 +11,17 @@ import logging @click.option('-l', '--log-file', required=False, type=click.Path(), default='/var/log/repotool.log', help='Log file (defaults to /var/log/repotool.log)') +@click.option('-n', '--no-update', is_flag=True, + help='do not update repo metadata after download (RHEL 8 repos)') @click.option('-r', '--repoid', required=True, help='repo id to query') @click.option('-p', '--path', required=True, type=click.Path(exists=True), help='repo path') -@click.option('-v', '--verbose', is_flag=True, +@click.option('-v', '--verbose', is_flag=True, help='verbose output') -def updateRepo(repoid, path, config, log_file, verbose): +def updateRepo(repoid, path, config, log_file, no_update, verbose): args = [ - "/usr/bin/reposync", "--plugins", "--downloadcomps", + "/usr/bin/reposync", "--plugins", "--downloadcomps", "--norepopath", "-c", config, "-r", repoid, "-p", path ] @@ -42,27 +44,30 @@ def updateRepo(repoid, path, config, log_file, verbose): if verbose: click.echo("Successfully synced %s" % repoid) logging.info("Successfully synced %s", repoid) - - # createrepo --update -v /var/repos/centos/7/centosplus/x86_64/ - logging.info("Updating metadata for %s", repoid) - if verbose: - click.echo("Updating metadata for %s" % repoid) - - crepo = subprocess.Popen( - ["/usr/bin/createrepo", "--update", path], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE - ) - out, err = crepo.communicate() - - if crepo.returncode != 0: - logging.critical(err) - click.echo(err) - else: + + if not no_update: + # createrepo --update -v /var/repos/centos/7/centosplus/x86_64/ + logging.info("Updating metadata for %s", repoid) if verbose: - click.echo(out) - click.echo("Successfully updated metadata for %s" % repoid) - logging.info("Successfully updated metadata for %s", repoid) + click.echo("Updating metadata for %s" % repoid) + + crepo = subprocess.Popen( + ["/usr/bin/createrepo", "--update", "--groupfile comps.xml", path], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) + out, err = crepo.communicate() + + if crepo.returncode != 0: + logging.critical(err) + click.echo(err) + else: + if verbose: + click.echo(out) + click.echo("Successfully updated metadata for %s" % repoid) + logging.info("Successfully updated metadata for %s", repoid) + if __name__ == '__main__': updateRepo() +