Panu Matilainen 5b4d98
From 53c9e8d00983b0d99caefc0ef94a18184c0ba85c Mon Sep 17 00:00:00 2001
Panu Matilainen 5b4d98
Message-Id: <53c9e8d00983b0d99caefc0ef94a18184c0ba85c.1488964568.git.pmatilai@redhat.com>
Panu Matilainen 5b4d98
In-Reply-To: <189b4f88c8e100155ec23a1e0b214bdc8473532a.1488964568.git.pmatilai@redhat.com>
Panu Matilainen 5b4d98
References: <189b4f88c8e100155ec23a1e0b214bdc8473532a.1488964568.git.pmatilai@redhat.com>
Panu Matilainen 5b4d98
From: Panu Matilainen <pmatilai@redhat.com>
Panu Matilainen 5b4d98
Date: Wed, 9 Nov 2016 09:16:48 +0200
Panu Matilainen 5b4d98
Subject: [PATCH 06/11] Fix debuginfo etc when subpackages have different
Panu Matilainen 5b4d98
 versions (RhBug:1051407)
Panu Matilainen 5b4d98
Panu Matilainen 5b4d98
Rpm has always been a bit dazed and confused when it comes to specs
Panu Matilainen 5b4d98
with sub-packages having different version etc from the main package.
Panu Matilainen 5b4d98
Many things work fine in that case .. except .. when they dont. Debuginfo
Panu Matilainen 5b4d98
picking up wrong versions (RhBug:1051407) is just one example, there
Panu Matilainen 5b4d98
are countless more in bugzilla wrt buildroot paths and whatnot.
Panu Matilainen 5b4d98
The simple and sane solution would be not piling on them macros
Panu Matilainen 5b4d98
from sub-packages, but that would surely break somebodys precious
Panu Matilainen 5b4d98
spec tricks.
Panu Matilainen 5b4d98
Panu Matilainen 5b4d98
The ugly but brutally simple and compatible solution to this all is to
Panu Matilainen 5b4d98
create separate set of macros when on the main package, this lets users
Panu Matilainen 5b4d98
in and out of rpm pick which one (latest or main) they want. To hopefully
Panu Matilainen 5b4d98
avoid stomping on anybodys toes, use uppercasing for the macro name (other
Panu Matilainen 5b4d98
variants like %pkg_release are awfully commonly used). Pile 'em on, yay!
Panu Matilainen 5b4d98
---
Panu Matilainen 5b4d98
 build/files.c         |  2 +-
Panu Matilainen 5b4d98
 build/parsePreamble.c | 11 ++++++++++-
Panu Matilainen 5b4d98
 macros.in             | 18 +++++++++---------
Panu Matilainen 5b4d98
 3 files changed, 20 insertions(+), 11 deletions(-)
Panu Matilainen 5b4d98
Panu Matilainen 5b4d98
diff --git a/build/files.c b/build/files.c
Panu Matilainen 5b4d98
index 6215bf8..2ede463 100644
Panu Matilainen 5b4d98
--- a/build/files.c
Panu Matilainen 5b4d98
+++ b/build/files.c
Panu Matilainen 5b4d98
@@ -1797,7 +1797,7 @@ static int generateBuildIDs(FileList fl)
Panu Matilainen 5b4d98
 	    int unique_debug_names =
Panu Matilainen 5b4d98
 		rpmExpandNumeric("%{?_unique_debug_names}");
Panu Matilainen 5b4d98
 	    if (unique_debug_names == 1)
Panu Matilainen 5b4d98
-		vra = rpmExpand("-%{version}-%{release}.%{_arch}", NULL);
Panu Matilainen 5b4d98
+		vra = rpmExpand("-%{VERSION}-%{RELEASE}.%{_arch}", NULL);
Panu Matilainen 5b4d98
 	}
Panu Matilainen 5b4d98
 
Panu Matilainen 5b4d98
 	/* Now add a subdir and symlink for each buildid found.  */
Panu Matilainen 5b4d98
diff --git a/build/parsePreamble.c b/build/parsePreamble.c
Panu Matilainen 5b4d98
index 933f734..6be4403 100644
Panu Matilainen 5b4d98
--- a/build/parsePreamble.c
Panu Matilainen 5b4d98
+++ b/build/parsePreamble.c
Panu Matilainen 5b4d98
@@ -909,8 +909,17 @@ static rpmRC handlePreambleTag(rpmSpec spec, Package pkg, rpmTagVal tag,
Panu Matilainen 5b4d98
 	goto exit;
Panu Matilainen 5b4d98
     }
Panu Matilainen 5b4d98
 
Panu Matilainen 5b4d98
-    if (macro)
Panu Matilainen 5b4d98
+    if (macro) {
Panu Matilainen 5b4d98
 	addMacro(spec->macros, macro, NULL, field, RMIL_SPEC);
Panu Matilainen 5b4d98
+	/* Add a separate uppercase macro for tags from the main package */
Panu Matilainen 5b4d98
+	if (pkg == spec->packages) {
Panu Matilainen 5b4d98
+	    char *m = xstrdup(macro);
Panu Matilainen 5b4d98
+	    for (char *p = m; *p; ++p)
Panu Matilainen 5b4d98
+		*p = rtoupper(*p);
Panu Matilainen 5b4d98
+	    addMacro(spec->macros, m, NULL, field, RMIL_SPEC);
Panu Matilainen 5b4d98
+	    free(m);
Panu Matilainen 5b4d98
+	}
Panu Matilainen 5b4d98
+    }
Panu Matilainen 5b4d98
     rc = RPMRC_OK;
Panu Matilainen 5b4d98
 exit:
Panu Matilainen 5b4d98
     return rc;	
Panu Matilainen 5b4d98
diff --git a/macros.in b/macros.in
Panu Matilainen 5b4d98
index 68bf391..4d90282 100644
Panu Matilainen 5b4d98
--- a/macros.in
Panu Matilainen 5b4d98
+++ b/macros.in
Panu Matilainen 5b4d98
@@ -180,7 +180,7 @@
Panu Matilainen 5b4d98
 #	the script.  See the script for details.
Panu Matilainen 5b4d98
 #
Panu Matilainen 5b4d98
 %__debug_install_post   \
Panu Matilainen 5b4d98
-   %{_rpmconfigdir}/find-debuginfo.sh %{?_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}"\
Panu Matilainen 5b4d98
+   %{_rpmconfigdir}/find-debuginfo.sh %{?_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}"\
Panu Matilainen 5b4d98
 %{nil}
Panu Matilainen 5b4d98
 
Panu Matilainen 5b4d98
 #	Template for debug information sub-package.
Panu Matilainen 5b4d98
@@ -232,7 +232,7 @@ package or when debugging this package.\
Panu Matilainen 5b4d98
 %_buildrootdir		%{_topdir}/BUILDROOT
Panu Matilainen 5b4d98
 
Panu Matilainen 5b4d98
 #	Build root path, where %install installs the package during build.
Panu Matilainen 5b4d98
-%buildroot		%{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}
Panu Matilainen 5b4d98
+%buildroot		%{_buildrootdir}/%{NAME}-%{VERSION}-%{RELEASE}.%{_arch}
Panu Matilainen 5b4d98
 
Panu Matilainen 5b4d98
 #	Directory where temporaray files can be created.
Panu Matilainen 5b4d98
 %_tmppath		%{_var}/tmp
Panu Matilainen 5b4d98
@@ -484,7 +484,7 @@ package or when debugging this package.\
Panu Matilainen 5b4d98
 
Panu Matilainen 5b4d98
 # Whether build-ids should be made unique between package version/releases
Panu Matilainen 5b4d98
 # when generating debuginfo packages. If set to 1 this will pass
Panu Matilainen 5b4d98
-# --ver-rel "%{version}-%{release}" to find-debuginfo.sh which will pass it
Panu Matilainen 5b4d98
+# --ver-rel "%{VERSION}-%{RELEASE}" to find-debuginfo.sh which will pass it
Panu Matilainen 5b4d98
 # onto debugedit --build-id-seed to be used to prime the build-id note hash.
Panu Matilainen 5b4d98
 %_unique_build_ids	1
Panu Matilainen 5b4d98
 
Panu Matilainen 5b4d98
@@ -705,9 +705,9 @@ package or when debugging this package.\
Panu Matilainen 5b4d98
   export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS\
Panu Matilainen 5b4d98
   RPM_DOC_DIR=\"%{_docdir}\"\
Panu Matilainen 5b4d98
   export RPM_DOC_DIR\
Panu Matilainen 5b4d98
-  RPM_PACKAGE_NAME=\"%{name}\"\
Panu Matilainen 5b4d98
-  RPM_PACKAGE_VERSION=\"%{version}\"\
Panu Matilainen 5b4d98
-  RPM_PACKAGE_RELEASE=\"%{release}\"\
Panu Matilainen 5b4d98
+  RPM_PACKAGE_NAME=\"%{NAME}\"\
Panu Matilainen 5b4d98
+  RPM_PACKAGE_VERSION=\"%{VERSION}\"\
Panu Matilainen 5b4d98
+  RPM_PACKAGE_RELEASE=\"%{RELEASE}\"\
Panu Matilainen 5b4d98
   export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE\
Panu Matilainen 5b4d98
   LANG=C\
Panu Matilainen 5b4d98
   export LANG\
Panu Matilainen 5b4d98
@@ -1146,7 +1146,7 @@ done \
Panu Matilainen 5b4d98
 %__scm_setup_hg(q)\
Panu Matilainen 5b4d98
 %{__hg} init %{-q} .\
Panu Matilainen 5b4d98
 %{__hg} add %{-q} .\
Panu Matilainen 5b4d98
-%{__hg} commit %{-q} --user "%{__scm_author}" -m "%{name}-%{version} base"
Panu Matilainen 5b4d98
+%{__hg} commit %{-q} --user "%{__scm_author}" -m "%{NAME}-%{VERSION} base"
Panu Matilainen 5b4d98
 
Panu Matilainen 5b4d98
 %__scm_apply_hg(qp:m:)\
Panu Matilainen 5b4d98
 %{__hg} import - %{-p:-p%{-p*}} %{-q} -m %{-m*} --user "%{__scm_author}"
Panu Matilainen 5b4d98
@@ -1158,7 +1158,7 @@ done \
Panu Matilainen 5b4d98
 %{__git} config user.email "%{__scm_usermail}"\
Panu Matilainen 5b4d98
 %{__git} add .\
Panu Matilainen 5b4d98
 %{__git} commit %{-q} -a\\\
Panu Matilainen 5b4d98
-	--author "%{__scm_author}" -m "%{name}-%{version} base"
Panu Matilainen 5b4d98
+	--author "%{__scm_author}" -m "%{NAME}-%{VERSION} base"
Panu Matilainen 5b4d98
 
Panu Matilainen 5b4d98
 %__scm_apply_git(qp:m:)\
Panu Matilainen 5b4d98
 %{__git} apply --index %{-p:-p%{-p*}} -\
Panu Matilainen 5b4d98
@@ -1181,7 +1181,7 @@ done \
Panu Matilainen 5b4d98
 %{__bzr} init %{-q}\
Panu Matilainen 5b4d98
 %{__bzr} whoami --branch "%{__scm_author}"\
Panu Matilainen 5b4d98
 %{__bzr} add .\
Panu Matilainen 5b4d98
-%{__bzr} commit %{-q} -m "%{name}-%{version} base"
Panu Matilainen 5b4d98
+%{__bzr} commit %{-q} -m "%{NAME}-%{VERSION} base"
Panu Matilainen 5b4d98
 
Panu Matilainen 5b4d98
 # bzr doesn't seem to have its own command to apply patches?
Panu Matilainen 5b4d98
 %__scm_apply_bzr(qp:m:)\
Panu Matilainen 5b4d98
-- 
Panu Matilainen 5b4d98
2.9.3
Panu Matilainen 5b4d98