#587 Extra arguments passed after -- are split on whitespace
Closed: Fixed 2 years ago by onosek. Opened 2 years ago by churchyard.

Try this:

$ fedpkg --release rawhide prep -- --define 'python_wheel_dir XXX'
...
error: Macro %python_wheel_dir has empty body
Could not execute prep: Failed to execute command.

With the debug output, we see what happens:

$ fedpkg --debug --verbose --release rawhide prep -- --define 'python_wheel_dir XXX'
Creating repo object from /home/churchyard/rpmbuild/fedora-scm/python-virtualenv
Not downloading already downloaded virtualenv-20.10.0.tar.gz
Initiating a koji session to https://koji.fedoraproject.org/kojihub
Extra args '['--define', 'python_wheel_dir XXX']' are passed to rpmbuild command
Running: rpmbuild --define '_sourcedir /home/churchyard/rpmbuild/fedora-scm/python-virtualenv' --define '_specdir /home/churchyard/rpmbuild/fedora-scm/python-virtualenv' --define '_builddir /home/churchyard/rpmbuild/fedora-scm/python-virtualenv' --define '_srcrpmdir /home/churchyard/rpmbuild/fedora-scm/python-virtualenv' --define '_rpmdir /home/churchyard/rpmbuild/fedora-scm/python-virtualenv' --define '_rpmfilename %%{ARCH}/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm' --define 'dist %{?distprefix}.fc36' --define 'fedora 36' --eval '%undefine rhel' --define 'fc36 1' --eval '%undefine fc33' --define python_wheel_dir XXX --nodeps -bp /home/churchyard/rpmbuild/fedora-scm/python-virtualenv/python-virtualenv.spec


error: Macro %python_wheel_dir has empty body
Could not execute prep: Failed to execute command.
Traceback (most recent call last):
  File "/usr/bin/fedpkg", line 33, in <module>
    sys.exit(load_entry_point('fedpkg==1.41', 'console_scripts', 'fedpkg')())
  File "/usr/lib/python3.9/site-packages/fedpkg/__main__.py", line 87, in main
    sys.exit(client.args.command())
  File "/usr/lib/python3.9/site-packages/pyrpkg/cli.py", line 2568, in prep
    self.cmd.prep(builddir=self.args.builddir,
  File "/usr/lib/python3.9/site-packages/pyrpkg/__init__.py", line 2967, in prep
    self._run_command(cmd, shell=True)
  File "/usr/lib/python3.9/site-packages/pyrpkg/__init__.py", line 1178, in _run_command
    raise rpkgError('Failed to execute command.')
pyrpkg.errors.rpkgError: Failed to execute command.

Special attention to --define python_wheel_dir XXX, I would expect it to be --define 'python_wheel_dir XXX' as that is what I passed on the command line.

A workaround is to escape the space:

$ fedpkg --release rawhide prep -- --define 'python_wheel_dir\ XXX'

I believe that at this point, everything is alright:

Extra args '['--define', 'python_wheel_dir XXX']' are passed to rpmbuild command

But later on, Commands. _run_command(shell=True) runs and it does ' '.join(cmd) which joins the individual parts of the command as strings.

As a solution, I believe one of the two approaches might work:

  1. more robust but requires plenty changes: Use shlex.join(cmd) instead of regular join, but don't add all the --define arguments as strings but as lists.
  2. feels hacky but might be easier: Only call shlex.join() on extra_args before appending it to cmd

Commit 8cdc041 relates to this ticket

Metadata Update from @onosek:
- Issue set to the milestone: 1.65

2 years ago

Login to comment on this ticket.

Metadata
Related Pull Requests
  • #629 Merged 2 years ago
  • #603 Merged 2 years ago