From f487f5cd260ee4029c7545ffb7126997ded75600 Mon Sep 17 00:00:00 2001 From: Guillermo N Date: Jul 18 2025 19:22:23 +0000 Subject: [PATCH 1/2] type: fix typo in requirements README. Signed-off-by: Guillermo N. --- diff --git a/requirements/README.rst b/requirements/README.rst index 4e94bca..166c182 100644 --- a/requirements/README.rst +++ b/requirements/README.rst @@ -3,4 +3,5 @@ Requirements * pypi.txt: contains Python packages that can be installed from PyPI via ``pip``. Some of required packages are not available in PyPI as of writing - this README file. They has to be installed from package manager too. + this README file. They have to be installed from package manager too. + From 04338101aa86d383e993358f349872fd0056168a Mon Sep 17 00:00:00 2001 From: Guillermo N Date: Jul 28 2025 11:37:37 +0000 Subject: [PATCH 2/2] `install`: add rpmbuild arguments `--with` and `--without` This commit introduces two new command-line flags for on-the-fly modification of `rpmbuild` arguments directly from the `install` subcommand: - `--with `: Appends a build condition (bcond) to `rpmbuild` arguments. - `--without `: Removes or disables a build condition (bcond) from `rpmbuild` arguments. These flags address the feature requested on `fedpkg` downstream repo. Resolves: https://pagure.io/fedpkg/issue/541 Signed-off-by: Guillermo N. --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index a0fbb6d..41a84c2 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -2763,7 +2763,7 @@ class Commands(object): self.kojisession.uploadWrapper(file, path, name=name, callback=callback) def install(self, arch=None, short=False, builddir=None, nocheck=False, - buildrootdir=None, define=None, extra_args=None): + buildrootdir=None, define=None, extra_args=None, installargs=None): """Run ``rpmbuild -bi`` optionally for a specific arch, short-circuit it, @@ -2771,6 +2771,8 @@ class Commands(object): Logs the output and returns nothing + :param list installargs: Modifiers for rpmbuild defaults (similar to + 'extra_args' but derived from different command-line parsing). :param str arch: specify a specific arch. :param list define: specify a list of rpmbuild macros. :param bool short: short-circuit it. @@ -2787,6 +2789,8 @@ class Commands(object): # setup the rpm command cmd = ['rpmbuild'] cmd.extend(self.rpmdefines) + if installargs: + cmd.extend(installargs) if builddir: # Tack on a new builddir to the end of the defines cmd.extend(["--define", "_builddir %s" % os.path.abspath(builddir)]) @@ -2905,6 +2909,8 @@ class Commands(object): written into current working directory and in format `.build-{version}-{release}.log`. + :param list localargs: Modifiers for rpmbuild defaults (similar to + 'extra_args' but derived from different command-line parsing). :param str arch: to optionally build for a specific arch. :param list define: optional list of rpmbuild macros. :param str hashtype: an alternative algorithm used for payload file diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py index 8f5ae40..10c6fd4 100644 --- a/pyrpkg/cli.py +++ b/pyrpkg/cli.py @@ -1030,6 +1030,13 @@ class cliClient(object): '--nocheck', action='store_true', help='nocheck install') + # Pass --with/without options to rpmbuild + install_parser.add_argument( + '--with', help='Enable configure option (bcond) for the build', + dest='bcond_with', action='append') + install_parser.add_argument( + '--without', help='Disable configure option (bcond) for the build', + dest='bcond_without', action='append') install_parser.set_defaults(command=self.install, default=False) def register_lint(self): @@ -2449,13 +2456,25 @@ class cliClient(object): def install(self): self.sources() + + installargs = [] + + if self.args.bcond_with: + for arg in self.args.bcond_with: + installargs.extend(['--with', arg]) + + if self.args.bcond_without: + for arg in self.args.bcond_without: + installargs.extend(['--without', arg]) + self.cmd.install(builddir=self.args.builddir, arch=self.args.arch, define=self.args.define, extra_args=self.extra_args, short=self.args.short_circuit, nocheck=self.args.nocheck, - buildrootdir=self.args.buildrootdir,) + buildrootdir=self.args.buildrootdir, + installargs=installargs) def lint(self): self.cmd.lint(self.args.info, self.args.rpmlintconf) diff --git a/tests/test_cli.py b/tests/test_cli.py index ae532b0..f734c43 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -865,6 +865,7 @@ class TestInstall(CliTestCase): cli_cmd = [ 'rpkg', '--path', self.cloned_repo_path, '--release', 'rhel-6', '-q', 'install', '--nocheck', '--arch', 'i686', + '--with', 'a', '--without', 'b', '--builddir', builddir, '--buildrootdir', buildrootdir ] @@ -874,6 +875,7 @@ class TestInstall(CliTestCase): spec = os.path.join(cli.cmd.path, cli.cmd.spec) rpmbuild = ['rpmbuild'] + cli.cmd.rpmdefines + [ + '--with', 'a', '--without', 'b', '--define', '_builddir %s' % builddir, '--target', 'i686', '--nocheck', '--quiet', '--define', '_buildrootdir %s' % buildrootdir,