Fix: Treat x86_64_v2 as x86_64 in architecture checks

This commit is contained in:
Eduard Abdullin 2025-05-31 03:21:45 +00:00 committed by root
commit f21873bdc8
3 changed files with 385 additions and 2 deletions

View File

@ -0,0 +1,214 @@
From d1c270a9d9415573a68e605b1c20e30937793446 Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
Date: Tue, 2 Apr 2024 13:21:00 +0300
Subject: [PATCH 1/2] Ensure binary and source headers are identified as such
after parse
The two commits improve source and binary package header detection right
after spec parse, fixing #2819 in the process. Details in commits.
Backported from commits:
8703ce740f24d7b7c443cce74fccf08df00e89c2
dc47a50c6345a25b861305d8aa8ae464098834ff
Fixes: RHEL-87383
---
build/build.c | 1 +
build/files.c | 14 --------------
build/pack.c | 2 --
build/parseSpec.c | 10 ++++++++++
lib/headerutil.c | 9 ++++++++-
tests/rpmquery.at | 2 ++
tests/rpmspec.at | 21 +++++++++++++++++++++
7 files changed, 42 insertions(+), 17 deletions(-)
diff --git a/build/build.c b/build/build.c
index f2cf98c8b..c35fd137a 100644
--- a/build/build.c
+++ b/build/build.c
@@ -393,6 +393,7 @@ static rpmRC buildSpec(rpmts ts, BTA_t buildArgs, rpmSpec spec, int what)
!(spec->flags & RPMSPEC_FORCE)) {
/* Create buildreqs package */
char *nvr = headerGetAsString(spec->packages->header, RPMTAG_NVR);
+ free(spec->sourceRpmName);
rasprintf(&spec->sourceRpmName, "%s.buildreqs.nosrc.rpm", nvr);
free(nvr);
/* free sources to not include them in the buildreqs package */
diff --git a/build/files.c b/build/files.c
index c403c806e..429ae1d61 100644
--- a/build/files.c
+++ b/build/files.c
@@ -2661,16 +2661,6 @@ exit:
return fl.processingFailed ? RPMRC_FAIL : RPMRC_OK;
}
-static void genSourceRpmName(rpmSpec spec)
-{
- if (spec->sourceRpmName == NULL) {
- char *nvr = headerGetAsString(spec->packages->header, RPMTAG_NVR);
- rasprintf(&spec->sourceRpmName, "%s.%ssrc.rpm", nvr,
- spec->noSource ? "no" : "");
- free(nvr);
- }
-}
-
rpmRC processSourceFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags)
{
struct Source *srcPtr;
@@ -2688,7 +2678,6 @@ rpmRC processSourceFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags)
oneshot = 1;
}
- genSourceRpmName(spec);
/* Construct the file list and source entries */
argvAdd(&files, spec->specFile);
for (srcPtr = spec->sources; srcPtr != NULL; srcPtr = srcPtr->next) {
@@ -3130,7 +3119,6 @@ rpmRC processBinaryFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
elf_version (EV_CURRENT);
#endif
check_fileList = newStringBuf();
- genSourceRpmName(spec);
buildroot = rpmGenPath(spec->rootDir, spec->buildRoot, NULL);
if (rpmExpandNumeric("%{?_debuginfo_subpackages}")) {
@@ -3186,8 +3174,6 @@ rpmRC processBinaryFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
if (pkg->fileList == NULL)
continue;
- headerPutString(pkg->header, RPMTAG_SOURCERPM, spec->sourceRpmName);
-
nvr = headerGetAsString(pkg->header, RPMTAG_NVRA);
rpmlog(RPMLOG_NOTICE, _("Processing files: %s\n"), nvr);
free(nvr);
diff --git a/build/pack.c b/build/pack.c
index f7dac6d9a..9eb304642 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -796,13 +796,11 @@ rpmRC packageSources(rpmSpec spec, char **cookie)
{
Package sourcePkg = spec->sourcePackage;
rpmRC rc;
- uint32_t one = 1;
/* Add some cruft */
headerPutString(sourcePkg->header, RPMTAG_RPMVERSION, VERSION);
headerPutString(sourcePkg->header, RPMTAG_BUILDHOST, spec->buildHost);
headerPutUint32(sourcePkg->header, RPMTAG_BUILDTIME, &(spec->buildTime), 1);
- headerPutUint32(sourcePkg->header, RPMTAG_SOURCEPACKAGE, &one, 1);
/* Include spec in parsed and expanded form */
headerPutString(sourcePkg->header, RPMTAG_SPEC, getStringBuf(spec->parsed));
diff --git a/build/parseSpec.c b/build/parseSpec.c
index 3929c0a26..e64b23af2 100644
--- a/build/parseSpec.c
+++ b/build/parseSpec.c
@@ -648,11 +648,13 @@ static void initSourceHeader(rpmSpec spec)
{
Package sourcePkg = spec->sourcePackage;
struct Source *srcPtr;
+ uint32_t one = 1;
if (headerIsEntry(sourcePkg->header, RPMTAG_NAME))
return;
/* Only specific tags are added to the source package header */
+ headerPutUint32(sourcePkg->header, RPMTAG_SOURCEPACKAGE, &one, 1);
headerCopyTags(spec->packages->header, sourcePkg->header, sourceTags);
/* Add the build restrictions */
@@ -694,8 +696,15 @@ static void initSourceHeader(rpmSpec spec)
}
}
}
+ if (spec->sourceRpmName == NULL) {
+ char *nvr = headerGetAsString(spec->packages->header, RPMTAG_NVR);
+ rasprintf(&spec->sourceRpmName, "%s.%ssrc.rpm", nvr,
+ spec->noSource ? "no" : "");
+ free(nvr);
+ }
/* Provide all package NEVRs that would be built */
+ /* Insert RPMTAG_SOURCERPM to all packages as well */
for (Package p = spec->packages; p != NULL; p = p->next) {
if (p->fileList) {
Header h = sourcePkg->header;
@@ -704,6 +713,7 @@ static void initSourceHeader(rpmSpec spec)
headerPutUint32(h, RPMTAG_PROVIDEFLAGS, &dsflags, 1);
headerPutString(h, RPMTAG_PROVIDEVERSION, rpmdsEVR(p->ds));
}
+ headerPutString(p->header, RPMTAG_SOURCERPM, spec->sourceRpmName);
}
}
diff --git a/lib/headerutil.c b/lib/headerutil.c
index fab210ff2..15aa246ef 100644
--- a/lib/headerutil.c
+++ b/lib/headerutil.c
@@ -14,7 +14,14 @@
int headerIsSource(Header h)
{
- return (!headerIsEntry(h, RPMTAG_SOURCERPM));
+ /* Positive identification of a source package */
+ if (headerIsEntry(h, RPMTAG_SOURCEPACKAGE))
+ return 1;
+ /* Positive identification of a binary package */
+ if (headerIsEntry(h, RPMTAG_SOURCERPM))
+ return 0;
+ /* Dunno, guess so (as per traditional behavior) */
+ return 1;
}
Header headerCopy(Header h)
diff --git a/tests/rpmquery.at b/tests/rpmquery.at
index 7d604ad6e..f8c7db56b 100644
--- a/tests/rpmquery.at
+++ b/tests/rpmquery.at
@@ -1069,6 +1069,7 @@ runroot rpmspec -q --qf "[[%{*:tagnum}\n]]" --srpm /data/SPECS/mini.spec
1016
1021
1022
+1106
],
[])
@@ -1086,6 +1087,7 @@ License
Group
Os
Arch
+Sourcepackage
],
[])
RPMTEST_CLEANUP
diff --git a/tests/rpmspec.at b/tests/rpmspec.at
index e8914589c..ffae01ef2 100644
--- a/tests/rpmspec.at
+++ b/tests/rpmspec.at
@@ -357,3 +357,24 @@ make DESTDIR=$RPM_BUILD_ROOT install
]],
[])
RPMTEST_CLEANUP
+
+AT_SETUP([rpmspec -q --rpms and --srpm])
+AT_KEYWORDS([rpmspec query])
+RPMTEST_CHECK([
+runroot rpmspec -q --rpms --target s390x \
+ /data/SPECS/hello.spec
+],
+[0],
+[hello-1.0-1.s390x
+],
+[])
+
+RPMTEST_CHECK([
+runroot rpmspec -q --srpm \
+ /data/SPECS/hello.spec
+],
+[0],
+[hello-1.0-1.src
+],
+[])
+RPMTEST_CLEANUP
--
2.49.0

View File

@ -0,0 +1,163 @@
From 75122bd6421526f41ad784036f63a022e9aca4b5 Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
Date: Thu, 15 Feb 2024 09:26:38 +0200
Subject: [PATCH 2/2] Add support for spec local file attributes and generators
Allow declaring file attributes from the spec via %_local_file_attrs
macro. This allows enabling file attributes and their dependency
generators even if they are only shipped in the package itself and are
not yet installed.
The names need to be separated by colons (:).
Co-authored-by: Florian Festi <ffesti@redhat.com>
Backported from commits:
d3b7b0e3280dbc66bd39cd851af32f16fd863f1b
c167ef8bdaecdd2e306ec896c919607ba9cceb6f
Fixes: RHEL-84057
---
build/rpmfc.c | 32 +++++++++++++----
docs/manual/dependency_generators.md | 10 ++++++
tests/rpmbuild.at | 52 ++++++++++++++++++++++++++++
3 files changed, 88 insertions(+), 6 deletions(-)
diff --git a/build/rpmfc.c b/build/rpmfc.c
index 4b67a9bae..fb07f6626 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -1124,20 +1124,40 @@ static int initAttrs(rpmfc fc)
ARGV_t files = NULL;
char * attrPath = rpmExpand("%{_fileattrsdir}/*.attr", NULL);
int nattrs = 0;
+ ARGV_t all_attrs = NULL;
- /* Discover known attributes from pathnames + initialize them */
+ /* Discover known attributes from pathnames */
if (rpmGlob(attrPath, NULL, &files) == 0) {
- nattrs = argvCount(files);
- fc->atypes = xcalloc(nattrs + 1, sizeof(*fc->atypes));
- for (int i = 0; i < nattrs; i++) {
+ int nfiles = argvCount(files);
+ for (int i = 0; i < nfiles; i++) {
char *bn = basename(files[i]);
bn[strlen(bn)-strlen(".attr")] = '\0';
- fc->atypes[i] = rpmfcAttrNew(bn);
+ argvAdd(&all_attrs, bn);
}
- fc->atypes[nattrs] = NULL;
argvFree(files);
}
+
+ /* Get file attributes from _local_file_attrs macro */
+ char * local_attr_names = rpmExpand("%{?_local_file_attrs}", NULL);
+ ARGV_t local_attrs = argvSplitString(local_attr_names, ":", ARGV_SKIPEMPTY);
+ int nlocals = argvCount(local_attrs);
+ for (int i = 0; i < nlocals; i++) {
+ argvAddUniq(&all_attrs, local_attrs[i]);
+ }
+
+ /* Initialize attr objects */
+ nattrs = argvCount(all_attrs);
+ fc->atypes = xcalloc(nattrs + 1, sizeof(*fc->atypes));
+
+ for (int i = 0; i < nattrs; i++) {
+ fc->atypes[i] = rpmfcAttrNew(all_attrs[i]);
+ }
+ fc->atypes[nattrs] = NULL;
+
free(attrPath);
+ free(local_attr_names);
+ argvFree(local_attrs);
+ argvFree(all_attrs);
return nattrs;
}
diff --git a/docs/manual/dependency_generators.md b/docs/manual/dependency_generators.md
index 5538bb4c7..0f851fc50 100644
--- a/docs/manual/dependency_generators.md
+++ b/docs/manual/dependency_generators.md
@@ -116,6 +116,16 @@ shelling out to execute a script that calls `basename`:
%__foo_provides() %{basename:%{1}}
```
+## Using File Attributes in their own Package
+
+Normally file attributes and their dependency generators are shipped in separate packages that need to be installed before the package making use of them can be build.
+
+Since rpm 4.20 the names of file attributes from the package itself can be put into the *_local_file_attrs* macro separated by colons (:). The macros that normally go into the *\*.attr* files still need to be defined (the dependency generators typically pointing to some Source files or some files in the install root).
+
+This mechanism can be used for both file attributes the package ships to be installed but also for file attributes that are used during the own building process only.
+
+For the former packagers need to be aware that a previus version of the package might be installed on the system the package is build on. Thus the Spec file must set all macros used in the past and undefine the ones not longer being used.
+
## Tweaking Dependency Generators
Technically, all aspects of file attributes and the generator helpers they use can be overridden from spec by (re)defining the related macros, but packagers should generally avoid this, as the attributes and their names are subject to change, depending on rpm version and which packages are present during build. Unwanted dependencies can be filtered with a separate set of macros which are intended primarily for use in spec files:
diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at
index ad7c40600..5bd8ee402 100644
--- a/tests/rpmbuild.at
+++ b/tests/rpmbuild.at
@@ -913,6 +913,58 @@ runroot rpm -qp --requires /build/RPMS/noarch/shebang-0.1-1.noarch.rpm|grep -v ^
[])
RPMTEST_CLEANUP
+AT_SETUP([Local dependency generator])
+AT_KEYWORDS([build])
+RPMTEST_CHECK([
+RPMDB_INIT
+
+runroot rpmbuild -bb --quiet \
+ --define '_local_file_attrs my_test_attr' \
+ --define '__my_test_attr_provides() foo(%{basename:%{1}})' \
+ --define '__my_test_attr_path .*' \
+ /data/SPECS/shebang.spec
+runroot rpm -qp --provides /build/RPMS/noarch/shebang-0.1-1.noarch.rpm|grep -v ^rpmlib
+],
+[0],
+[foo(shebang)
+shebang = 0.1-1
+],
+[])
+
+RPMTEST_CHECK([
+RPMDB_INIT
+
+runroot rpmbuild -bb --quiet \
+ --define '_local_file_attrs script' \
+ --define '__script_provides() foobar(%{basename:%{1}})' \
+ /data/SPECS/shebang.spec
+runroot rpm -qp --provides /build/RPMS/noarch/shebang-0.1-1.noarch.rpm|grep -v ^rpmlib
+],
+[0],
+[foobar(shebang)
+shebang = 0.1-1
+],
+[])
+
+RPMTEST_CHECK([
+RPMDB_INIT
+
+runroot rpmbuild -bb --quiet \
+ --define '_local_file_attrs my_test_attr:script' \
+ --define '__my_test_attr_provides() foo(%{basename:%{1}})' \
+ --define '__my_test_attr_path .*' \
+ --define '__script_provides() foobar(%{basename:%{1}})' \
+ /data/SPECS/shebang.spec
+runroot rpm -qp --provides /build/RPMS/noarch/shebang-0.1-1.noarch.rpm|grep -v ^rpmlib
+],
+[0],
+[foo(shebang)
+foobar(shebang)
+shebang = 0.1-1
+],
+[])
+RPMTEST_CLEANUP
+
AT_SETUP([elf dependencies])
AT_KEYWORDS([build])
RPMDB_INIT
--
2.49.0

View File

@ -27,7 +27,7 @@
%global rpmver 4.19.1.1
#global snapver rc1
%global baserelease 14
%global baserelease 15
%global sover 10
%global srcver %{rpmver}%{?snapver:-%{snapver}}
@ -162,6 +162,8 @@ rpm-4.18.90-weak-user-group.patch
0004-Talk-about-rpmsign-in-the-rpmsign-man-page.patch
0005-Revert-Drop-redundant-argument-from-rpmcliTransactio.patch
0001-Store-configurable-digest-s-on-packages-from-verific.patch
0001-Ensure-binary-and-source-headers-are-identified-as-s.patch
0002-Add-support-for-spec-local-file-attributes-and-gener.patch
# These are not yet upstream
rpm-4.7.1-geode-i686.patch
@ -649,9 +651,13 @@ fi
%doc %{_defaultdocdir}/rpm/API/
%changelog
* Tue Apr 29 2025 Eduard Abdullin <eabdullin@almalinux.org> - 4.19.1.1-14.alma.1
* Sat May 31 2025 Eduard Abdullin <eabdullin@almalinux.org> - 4.19.1.1-15.alma.1
- Fix: Treat x86_64_v2 as x86_64 in architecture checks
* Thu May 29 2025 Michal Domonkos <mdomonko@redhat.com> - 4.19.1.1-15
- Add support for spec local file attributes and generators (RHEL-84057)
- Ensure binary and source headers are identified as such (RHEL-87383)
* Thu Apr 24 2025 Michal Domonkos <mdomonko@redhat.com> - 4.19.1.1-14
- Store configurable digest(s) on packages in rpmdb (RHEL-84062)
- Fix command references in rpmsign(8) man page, take II (RHEL-73173)