From 3bec6a9a7acddaea64b594ce7e55f581a50a72b1 Mon Sep 17 00:00:00 2001 From: Steve Traylen Date: Sep 22 2025 09:02:27 +0000 Subject: dist-repo, optionally include or exclude drafts Two new options to koji dist-repo. * `--with-draft` will consider a draft build as the latest build. * `--without-draft` will ignore draft builds and just typically take the latest non-draft build. The default remains and if dist-repo encounters a draft build with out one of the above options dist-repo will continue to exit. Motivation here is to allow dist-repo to be used against tags containing draft builds which is currently not possible. Examples: A tag containing two builds: * myrpm-1.1-37.el9.x86_64.rpm NOT DRAFT * myrpm-1.1-38.el9.x86_64.rpm DRAFT ``` koji dist-repo mytag9al-testing FAILED: BuildError: Draft build: myrpm-1.1-38.el9,draft_4 is not allowed ``` ``` koji dist-repo mytag9al-testing --with-draft Deploys the DRAFT one. ``` ``` koji dist-repo mytag9al-testing --without-draft Deploys the NOT DRAFT one. ``` --- diff --git a/builder/kojid b/builder/kojid index 2f7f948..196a54b 100755 --- a/builder/kojid +++ b/builder/kojid @@ -6581,11 +6581,11 @@ enabled=1 arch=a, latest=opts['latest'], inherit=opts['inherit'], - rpmsigs=True) + rpmsigs=True, + draft=None if opts['with_draft'] in (None, True) else False) for build in builds: - # disable draft for distRepo so far - if build.get('draft'): + if opts['with_draft'] == None and build.get('draft'): raise koji.BuildError("Draft build: %s is not allowed" % build['nvr']) builddirs[build['id']] = koji.pathinfo.build(build) rpms += list(rpm_iter) diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 4d77859..3eaf759 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -7959,6 +7959,10 @@ def handle_dist_repo(options, session, args): parser.add_option("--no-skip-stat", action='store_false', default=None, dest='skip_stat', help="Don't skip rpm stat during createrepo " "(override default builder setting)") + parser.add_option("--with-draft", action='store_true', default=None, dest='with_draft', + help="Include any draft builds in the tag") + parser.add_option("--without-draft", action='store_false', default=None, dest='with_draft', + help="Exclude any draft builds in the tag") task_opts, args = parser.parse_args(args) if len(args) < 1: parser.error('You must provide a tag to generate the repo from') @@ -8049,6 +8053,7 @@ def handle_dist_repo(options, session, args): 'zck': task_opts.zck, 'zck_dict_dir': task_opts.zck_dict_dir, 'write_signed_rpms': task_opts.write_signed_rpms, + 'with_draft': task_opts.with_draft, } if task_opts.latest_n: opts['latest'] = task_opts.latest_n diff --git a/tests/test_cli/test_dist_repo.py b/tests/test_cli/test_dist_repo.py index d0e07f8..1b50011 100644 --- a/tests/test_cli/test_dist_repo.py +++ b/tests/test_cli/test_dist_repo.py @@ -396,6 +396,8 @@ Options: builder setting) --no-skip-stat Don't skip rpm stat during createrepo (override default builder setting) + --with-draft Include any draft builds in the tag + --without-draft Exclude any draft builds in the tag """ % self.progname)