From e2ea1df9f719b20f8e6287a8d59c9314fd6c062d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Thu, 16 Oct 2025 16:19:19 +0200 Subject: [PATCH] %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 fbd3dcd22bd1206e3ec066ad8cd0a2eaebf80583) --- macros.pyproject | 2 +- pyproject-rpm-macros.spec | 6 +++++- tests/python-setuptools_scm.spec | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/macros.pyproject b/macros.pyproject index cf56ef9..6bf5d01 100644 --- a/macros.pyproject +++ b/macros.pyproject @@ -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 \\ diff --git a/pyproject-rpm-macros.spec b/pyproject-rpm-macros.spec index 158e379..de2d0a3 100644 --- a/pyproject-rpm-macros.spec +++ b/pyproject-rpm-macros.spec @@ -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 - 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 - 1.18.4-1 - Don't exit from pyproject-srpm-macros implementation of %%pyproject_buildrequires - Fixes: rhbz#2391290 diff --git a/tests/python-setuptools_scm.spec b/tests/python-setuptools_scm.spec index 6d4f1be..f5ad5c9 100644 --- a/tests/python-setuptools_scm.spec +++ b/tests/python-setuptools_scm.spec @@ -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}