Fix debuginfo etc when subpackages have different versions (RhBug:1051407)

Rpm has always been a bit dazed and confused when it comes to specs
with sub-packages having different version etc from the main package.
Many things work fine in that case .. except .. when they dont. Debuginfo
picking up wrong versions (RhBug:1051407) is just one example, there
are countless more in bugzilla wrt buildroot paths and whatnot.
The simple and sane solution would be not piling on them macros
from sub-packages, but that would surely break somebodys precious
spec tricks.

The ugly but brutally simple and compatible solution to this all is to
create separate set of macros when on the main package, this lets users
in and out of rpm pick which one (latest or main) they want. To hopefully
avoid stomping on anybodys toes, use uppercasing for the macro name (other
variants like %pkg_release are awfully commonly used). Pile 'em on, yay!
This commit is contained in:
Panu Matilainen 2016-11-09 09:16:48 +02:00
parent fb47bc09f8
commit ccdb1aa5c6
3 changed files with 20 additions and 11 deletions

View File

@ -1790,7 +1790,7 @@ static int generateBuildIDs(FileList fl)
int unique_debug_names =
rpmExpandNumeric("%{?_unique_debug_names}");
if (unique_debug_names == 1)
vra = rpmExpand("-%{version}-%{release}.%{_arch}", NULL);
vra = rpmExpand("-%{VERSION}-%{RELEASE}.%{_arch}", NULL);
}
/* Now add a subdir and symlink for each buildid found. */

View File

@ -916,8 +916,17 @@ static rpmRC handlePreambleTag(rpmSpec spec, Package pkg, rpmTagVal tag,
goto exit;
}
if (macro)
if (macro) {
rpmPushMacro(spec->macros, macro, NULL, field, RMIL_SPEC);
/* Add a separate uppercase macro for tags from the main package */
if (pkg == spec->packages) {
char *m = xstrdup(macro);
for (char *p = m; *p; ++p)
*p = rtoupper(*p);
rpmPushMacro(spec->macros, m, NULL, field, RMIL_SPEC);
free(m);
}
}
rc = RPMRC_OK;
exit:
return rc;

View File

@ -172,7 +172,7 @@
# the script. See the script for details.
#
%__debug_install_post \
%{_rpmconfigdir}/find-debuginfo.sh %{?_smp_mflags} %{?_missing_build_ids_terminate_build:--strict-build-id} %{?_include_minidebuginfo:-m} %{?_include_gdb_index:-i} %{?_unique_build_ids:--ver-rel "%{version}-%{release}"} %{?_unique_debug_names:--unique-debug-arch "%{_arch}"} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
%{_rpmconfigdir}/find-debuginfo.sh %{?_smp_mflags} %{?_missing_build_ids_terminate_build:--strict-build-id} %{?_include_minidebuginfo:-m} %{?_include_gdb_index:-i} %{?_unique_build_ids:--ver-rel "%{VERSION}-%{RELEASE}"} %{?_unique_debug_names:--unique-debug-arch "%{_arch}"} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
%{nil}
# Template for debug information sub-package.
@ -232,7 +232,7 @@ package or when debugging this package.\
%_buildrootdir %{_topdir}/BUILDROOT
# Build root path, where %install installs the package during build.
%buildroot %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}
%buildroot %{_buildrootdir}/%{NAME}-%{VERSION}-%{RELEASE}.%{_arch}
# Directory where temporaray files can be created.
%_tmppath %{_var}/tmp
@ -484,7 +484,7 @@ package or when debugging this package.\
# Whether build-ids should be made unique between package version/releases
# when generating debuginfo packages. If set to 1 this will pass
# --ver-rel "%{version}-%{release}" to find-debuginfo.sh which will pass it
# --ver-rel "%{VERSION}-%{RELEASE}" to find-debuginfo.sh which will pass it
# onto debugedit --build-id-seed to be used to prime the build-id note hash.
%_unique_build_ids 1
@ -706,9 +706,9 @@ package or when debugging this package.\
export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS\
RPM_DOC_DIR=\"%{_docdir}\"\
export RPM_DOC_DIR\
RPM_PACKAGE_NAME=\"%{name}\"\
RPM_PACKAGE_VERSION=\"%{version}\"\
RPM_PACKAGE_RELEASE=\"%{release}\"\
RPM_PACKAGE_NAME=\"%{NAME}\"\
RPM_PACKAGE_VERSION=\"%{VERSION}\"\
RPM_PACKAGE_RELEASE=\"%{RELEASE}\"\
export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE\
LANG=C\
export LANG\
@ -1093,7 +1093,7 @@ package or when debugging this package.\
%__scm_setup_hg(q)\
%{__hg} init %{-q} .\
%{__hg} add %{-q} .\
%{__hg} commit %{-q} --user "%{__scm_author}" -m "%{name}-%{version} base"
%{__hg} commit %{-q} --user "%{__scm_author}" -m "%{NAME}-%{VERSION} base"
%__scm_apply_hg(qp:m:)\
%{__hg} import - %{-p:-p%{-p*}} %{-q} -m %{-m*} --user "%{__scm_author}"
@ -1105,7 +1105,7 @@ package or when debugging this package.\
%{__git} config user.email "%{__scm_usermail}"\
%{__git} add .\
%{__git} commit %{-q} -a\\\
--author "%{__scm_author}" -m "%{name}-%{version} base"
--author "%{__scm_author}" -m "%{NAME}-%{VERSION} base"
%__scm_apply_git(qp:m:)\
%{__git} apply --index %{-p:-p%{-p*}} -\
@ -1128,7 +1128,7 @@ package or when debugging this package.\
%{__bzr} init %{-q}\
%{__bzr} whoami --branch "%{__scm_author}"\
%{__bzr} add .\
%{__bzr} commit %{-q} -m "%{name}-%{version} base"
%{__bzr} commit %{-q} -m "%{NAME}-%{VERSION} base"
# bzr doesn't seem to have its own command to apply patches?
%__scm_apply_bzr(qp:m:)\