%pyproject_extras_subpkg: Only %ghost the dist-info directory, not the content

That way, accidentally unpackaged files within are reported as errors.

Currently, when %pyproject_extras_subpkg is used, the dist-info directory
is packaged as %ghost. When the main package does not have it,
the RPM build would succeed. The extras packages would have the python3dist()
requires and provides, but the main package would not.

By adding %dir after %ghost, we only package the directory
(which is enough for python3-rpm-generators to process it),
but the files in the directory are not included.
When not packaged in the main package, the RPM build fails.

This is a safeguard against packaging mistakes.

The visible difference is that rpm -ql/repoquery -l would only return the metadata directory.

See also https://src.fedoraproject.org/rpms/python-rpm-macros/pull-request/195

(cherry picked from Fedora commit fbd3dcd22b)
This commit is contained in:
Miro Hrončok 2025-10-16 16:19:19 +02:00
parent 630ed2ba04
commit e2ea1df9f7
3 changed files with 7 additions and 3 deletions

View File

@ -103,7 +103,7 @@ fi
# Process all *.dist-info dirs in sitelib/sitearch
for site_dir in ${site_dirs[@]}; do
for distinfo in %{buildroot}$site_dir/*.dist-info; do
echo "%ghost ${distinfo#%{buildroot}}" >> %{_pyproject_ghost_distinfo}
echo "%ghost %dir ${distinfo#%{buildroot}}" >> %{_pyproject_ghost_distinfo}
sed -i 's/pip/rpm/' ${distinfo}/INSTALLER
PYTHONPATH=%{_rpmconfigdir}/redhat \\
%{__python3} -B %{_rpmconfigdir}/redhat/pyproject_preprocess_record.py \\

View File

@ -14,7 +14,7 @@ License: MIT
# Increment Y and reset Z when new macros or features are added
# Increment Z when this is a bugfix or a cosmetic change
# Dropping support for EOL Fedoras is *not* considered a breaking change
Version: 1.18.4
Version: 1.18.5
Release: 1%{?dist}
# Macro files
@ -191,6 +191,10 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
%changelog
* Thu Oct 16 2025 Miro Hrončok <mhroncok@redhat.com> - 1.18.5-1
- %%pyproject_extras_subpkg: Only %%ghost the dist-info directory, not the content
- That way, accidentally unpackaged files within are reported as errors
* Mon Sep 01 2025 Miro Hrončok <mhroncok@redhat.com> - 1.18.4-1
- Don't exit from pyproject-srpm-macros implementation of %%pyproject_buildrequires
- Fixes: rhbz#2391290

View File

@ -67,7 +67,7 @@ grep -E 'flake8: (OK|commands succeeded)' toxlog %{?!with_flake8:&& exit 1 || tr
# Internal check for our macros
# making sure that %%{_pyproject_ghost_distinfo} has the right content
test -f %{_pyproject_ghost_distinfo}
test "$(cat %{_pyproject_ghost_distinfo})" == "%ghost %{python3_sitelib}/setuptools_scm-%{version}.dist-info"
test "$(cat %{_pyproject_ghost_distinfo})" == "%ghost %dir %{python3_sitelib}/setuptools_scm-%{version}.dist-info"
%files -n python3-setuptools_scm -f %{pyproject_files}