Fix questionable uses of %{name} and %{version} in the spec

%{name} and %{version} refer to the name and version strings of the
package that will be built and shouldn't be used for things that
do not honor those macros. Such as pre-existing or predetermined
filenames.

De-facto packaging practises over multiple decade liberally (ab)use
these and various other macros in places they don't belong - if rpm itself
doesn't follow its own rules then how can we expect anybody else to do so...

This doesn't change anything as is, but enables both Name: and Version:
to be changed arbitrarily without breaking the package build, which is
how it should optimally be. If this was strictly followed then scl-utils
would've been a walk in the park. Relatively speaking.
This commit is contained in:
Panu Matilainen 2020-04-23 10:56:28 +03:00
parent 931d61f432
commit 1b2c14f39a
1 changed files with 14 additions and 11 deletions

View File

@ -25,10 +25,10 @@
%global rpmver 4.15.90
%global snapver git14971
%global rel 8
%global rel 9
%global srcver %{version}%{?snapver:-%{snapver}}
%global srcdir %{?snapver:testing}%{!?snapver:%{name}-%(echo %{version} | cut -d'.' -f1-2).x}
%global srcver %{rpmver}%{?snapver:-%{snapver}}
%global srcdir %{?snapver:testing}%{!?snapver:rpm-%(echo %{rpmver} | cut -d'.' -f1-2).x}
%if %{with bdb}
%define bdbver 5.3.15
@ -42,7 +42,7 @@ Name: rpm
Version: %{rpmver}
Release: %{?snapver:0.%{snapver}.}%{rel}%{?dist}
Url: http://www.rpm.org/
Source0: http://ftp.rpm.org/releases/%{srcdir}/%{name}-%{srcver}.tar.bz2
Source0: http://ftp.rpm.org/releases/%{srcdir}/rpm-%{srcver}.tar.bz2
%if %{with bdb} && %{with int_bdb}
Source1: db-%{bdbver}.tar.gz
%endif
@ -301,7 +301,7 @@ Requires: rpm-libs%{_isa} = %{version}-%{release}
%endif
%prep
%autosetup -n %{name}-%{srcver} %{?with_int_bdb:-a 1} -p1
%autosetup -n rpm-%{srcver} %{?with_int_bdb:-a 1} -p1
%if %{with bdb} && %{with int_bdb}
ln -s db-%{bdbver} db
@ -383,7 +383,7 @@ for be in %{?with_ndb:ndb} %{?with_sqlite:sqlite} %{?with_bdb:bdb}; do
cp -va ${be}/. $RPM_BUILD_ROOT/var/lib/rpm/
done
%find_lang %{name}
%find_lang rpm
find $RPM_BUILD_ROOT -name "*.la"|xargs rm -f
@ -396,7 +396,7 @@ rm -f $RPM_BUILD_ROOT/%{_fileattrsdir}/{perl*,python*}
make check || (cat tests/rpmtests.log; exit 1)
%endif
%files -f %{name}.lang
%files -f rpm.lang
%license COPYING
%doc CREDITS doc/manual/[a-z]*
@ -515,15 +515,15 @@ make check || (cat tests/rpmtests.log; exit 1)
%{_mandir}/man8/rpmsign.8*
%files -n python3-%{name}
%{python3_sitearch}/%{name}/
%{python3_sitearch}/%{name}-%{version}*.egg-info
%{python3_sitearch}/rpm/
%{python3_sitearch}/rpm-%{rpmver}*.egg-info
%files devel
%{_mandir}/man8/rpmgraph.8*
%{_bindir}/rpmgraph
%{_libdir}/librp*[a-z].so
%{_libdir}/pkgconfig/%{name}.pc
%{_includedir}/%{name}/
%{_libdir}/pkgconfig/rpm.pc
%{_includedir}/rpm/
%files cron
%{_sysconfdir}/cron.daily/rpm
@ -534,6 +534,9 @@ make check || (cat tests/rpmtests.log; exit 1)
%doc doc/librpm/html/*
%changelog
* Thu Apr 23 2020 Panu Matilainen <pmatilai@redhat.com> - 4.15.90-0.git14971.9
- Fix questionable uses of %%{name} and %%{version} in the spec
* Wed Apr 22 2020 Panu Matilainen <pmatilai@redhat.com> - 4.15.90-0.git14971.8
- Fix regression(s) on build dependency resolution