Bug 1976363

Summary: %pyproject_save_files does not put paths with spaces to quotes and that fails the build
Product: [Fedora] Fedora Reporter: Miro Hrončok <mhroncok>
Component: pyproject-rpm-macrosAssignee: Miro Hrončok <mhroncok>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: mhroncok, pviktori, python-sig
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pyproject-rpm-macros-0-44.fc35 pyproject-rpm-macros-0-46.fc34 pyproject-rpm-macros-0-46.fc33 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-08-02 01:03:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Miro Hrončok 2021-06-25 20:51:19 UTC
There might be spaces in filenames (e.g. in setuptools, they are 🤯) and %{pyproject_files} generated by %pyproject_save_files contains them literally:

    ...
    /usr/lib/python3.10/site-packages/setuptools/command/launcher manifest.xml
    ...
    /usr/lib/python3.10/site-packages/setuptools/script (dev).tmpl
    ...


When used in the %files section, RPM considers the part before and after space as a separate file and fails with:

    File must begin with "/": manifest.xml
    File must begin with "/": (dev).tmpl


Escaping the space with a backslash does not help. Putting the entire line in "double quotes" helps.

Comment 1 Miro Hrončok 2021-06-25 21:20:19 UTC
A reproducer may be found in https://src.fedoraproject.org/rpms/python-setuptools/pull-request/70 (it has a workaround that links to this bugzilla that needs to be removed to reproduce)

Comment 2 Miro Hrončok 2021-06-29 11:34:00 UTC
This is what I have:

import string

def escape_rpm_path(path):
    """
    Escape special characters in paths
    E.g. a space in path otherwise makes RPM think it's multiple paths,
    unless we put it in "quotes".
    Or a literal % symbol in path might be expanded as a macro if not escaped.
    """
    if "%" in path:
        # path = path.replace("%", "%%") is not enough
        raise NotImplementedError("% symbol in paths, dunno")

    if any(symbol in path for symbol in string.whitespace):
        if '"' in path:
            raise NotImplementedError('" symbol in path with spaces, dunno')
        return f'"{path}"'

    # I wish all paths in the world would end up here:
    return path


The NotImplementedErrors are not ideal. I've asked: http://lists.rpm.org/pipermail/rpm-list/2021-June/002048.html

Comment 4 Fedora Update System 2021-07-19 07:58:58 UTC
FEDORA-2021-fe1bbcfd07 has been submitted as an update to Fedora 35. https://bodhi.fedoraproject.org/updates/FEDORA-2021-fe1bbcfd07

Comment 5 Fedora Update System 2021-07-19 08:01:19 UTC
FEDORA-2021-9874c0ec7b has been submitted as an update to Fedora 34. https://bodhi.fedoraproject.org/updates/FEDORA-2021-9874c0ec7b

Comment 6 Fedora Update System 2021-07-19 08:01:20 UTC
FEDORA-2021-ffa81019cf has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2021-ffa81019cf

Comment 7 Fedora Update System 2021-07-19 08:01:33 UTC
FEDORA-2021-fe1bbcfd07 has been pushed to the Fedora 35 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 8 Fedora Update System 2021-07-20 01:01:16 UTC
FEDORA-2021-ffa81019cf has been pushed to the Fedora 33 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-ffa81019cf`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-ffa81019cf

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 9 Fedora Update System 2021-07-20 01:47:12 UTC
FEDORA-2021-9874c0ec7b has been pushed to the Fedora 34 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-9874c0ec7b`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-9874c0ec7b

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 10 Fedora Update System 2021-07-24 01:18:19 UTC
FEDORA-2021-fcf5e2adc6 has been pushed to the Fedora 34 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-fcf5e2adc6`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-fcf5e2adc6

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 11 Fedora Update System 2021-07-24 01:24:56 UTC
FEDORA-2021-3d06d86fe9 has been pushed to the Fedora 33 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-3d06d86fe9`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-3d06d86fe9

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 12 Fedora Update System 2021-08-02 01:03:16 UTC
FEDORA-2021-fcf5e2adc6 has been pushed to the Fedora 34 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 13 Fedora Update System 2021-08-02 01:06:11 UTC
FEDORA-2021-3d06d86fe9 has been pushed to the Fedora 33 stable repository.
If problem still persists, please make note of it in this bug report.