Backport some patches from upstream

(cherry picked from commit 20927880aed58dc64076e646f44bb5e549fe39ec)
This commit is contained in:
hugel 2024-09-04 09:53:36 +08:00 committed by openeuler-sync-bot
parent 4d85ad6e75
commit a8f11b97d7
5 changed files with 511 additions and 1 deletions

View File

@ -0,0 +1,242 @@
From 826cbb8869e7d640fe3c2582a3a8dacf393e1ee0 Mon Sep 17 00:00:00 2001
From: Michal Domonkos <mdomonko@redhat.com>
Date: Wed, 21 Aug 2024 15:02:36 +0200
Subject: [PATCH] Fix -V option usage in our tests
Conflict:adapt context because 760eb8638 is not merged
Reference:https://github.com/rpm-software-management/rpm/commit/826cbb8869e7d640fe3c2582a3a8dacf393e1ee0
Coupling -V with -a when querying for specific packages makes little
sense and only causes the order of the output lines to depend on the
database ordering.
This is known to vary between the ndb and sqlite backends in particular,
confusing some of the tests that expect the lines to be in a specific
order.
While at it, fix all such questionable usages, even those that only
entail one package argument.
Fixes: #3242
---
tests/rpme.at | 16 ++++++++--------
tests/rpmverify.at | 38 +++++++++++++++++++-------------------
2 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/tests/rpme.at b/tests/rpme.at
index ead757579..058d929fd 100644
--- a/tests/rpme.at
+++ b/tests/rpme.at
@@ -293,9 +293,9 @@ done
RPMTEST_CHECK([
runroot rpm -U --ignoreos /build/RPMS/noarch/conflicta-1.0-1.noarch.rpm
runroot rpm -U --ignoreos --excludepath=/usr/share /build/RPMS/noarch/conflictb-1.0-1.noarch.rpm
-runroot rpm -Vav --nogroup --nouser conflicta conflictb
+runroot rpm -Vv --nogroup --nouser conflicta conflictb
runroot rpm -e conflicta
-runroot rpm -Vav --nogroup --nouser conflictb
+runroot rpm -Vv --nogroup --nouser conflictb
runroot rpm -e conflictb
runroot rpm -Vp --nogroup --nouser /build/RPMS/noarch/conflictb-1.0-1.noarch.rpm
],
@@ -310,9 +310,9 @@ missing /usr/share/my.version
RPMTEST_CHECK([
runroot rpm -U --ignoreos --excludepath=/usr/share /build/RPMS/noarch/conflicta-1.0-1.noarch.rpm
runroot rpm -U --ignoreos /build/RPMS/noarch/conflictb-1.0-1.noarch.rpm
-runroot rpm -Vav --nogroup --nouser conflicta conflictb
+runroot rpm -Vv --nogroup --nouser conflicta conflictb
runroot rpm -e conflicta
-runroot rpm -Vav --nogroup --nouser conflictb
+runroot rpm -Vv --nogroup --nouser conflictb
runroot rpm -e conflictb
runroot rpm -Vp --nogroup --nouser /build/RPMS/noarch/conflictb-1.0-1.noarch.rpm
],
@@ -327,9 +327,9 @@ missing /usr/share/my.version
RPMTEST_CHECK([
runroot rpm -U --ignoreos /build/RPMS/noarch/conflicta-1.0-1.noarch.rpm
runroot rpm -U --ignoreos --force /build/RPMS/noarch/conflictb-1.0-1.noarch.rpm
-runroot rpm -Vav --nogroup --nouser conflicta conflictb
+runroot rpm -Vv --nogroup --nouser conflicta conflictb
runroot rpm -e conflicta
-runroot rpm -Vav --nogroup --nouser conflictb
+runroot rpm -Vv --nogroup --nouser conflictb
runroot rpm -e conflictb
runroot rpm -Vp --nogroup --nouser /build/RPMS/noarch/conflictb-1.0-1.noarch.rpm
],
@@ -344,9 +344,9 @@ missing /usr/share/my.version
RPMTEST_CHECK([
runroot rpm -U --ignoreos /build/RPMS/noarch/conflicta-1.0-1.noarch.rpm
runroot rpm -U --ignoreos --force /build/RPMS/noarch/conflictb-1.0-1.noarch.rpm
-runroot rpm -Vav --nogroup --nouser conflicta conflictb
+runroot rpm -Vv --nogroup --nouser conflicta conflictb
runroot rpm -e conflictb
-runroot rpm -Vav --nogroup --nouser conflicta
+runroot rpm -Vv --nogroup --nouser conflicta
runroot rpm -e conflicta
],
[0],
diff --git a/tests/rpmverify.at b/tests/rpmverify.at
index 3a87b085f..32427021d 100644
--- a/tests/rpmverify.at
+++ b/tests/rpmverify.at
@@ -304,13 +304,13 @@ touch -t 201703171717 ${tf}
runroot rpm -U \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-2.0-1.noarch.rpm
-runroot rpm -Va --nouser --nogroup replacetest
+runroot rpm -V --nouser --nogroup replacetest
cat "${tf}"
runroot rpm -U \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-3.0-1.noarch.rpm
-runroot rpm -Va --nouser --nogroup replacetest
+runroot rpm -V --nouser --nogroup replacetest
cat "${tf}"
echo "xx" > "${tf}"
@@ -319,7 +319,7 @@ cat "${tf}"
runroot rpm -U \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-4.0-1.noarch.rpm
-runroot rpm -Va --nouser --nogroup replacetest
+runroot rpm -V --nouser --nogroup replacetest
cat "${tf}"
touch -t 201703171717 ${tf}
@@ -327,7 +327,7 @@ touch -t 201703171717 ${tf}
runroot rpm -U --oldpackage \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-3.0-1.noarch.rpm
-runroot rpm -Va --nouser --nogroup replacetest
+runroot rpm -V --nouser --nogroup replacetest
cat "${tf}"
],
[0],
@@ -352,7 +352,7 @@ touch -t 201703171717 ${tf}
runroot rpm -Uvv --fsmdebug \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-2.0-1.noarch.rpm > output.txt 2>&1
-runroot rpm -Va --nouser --nogroup replacetest
+runroot rpm -V --nouser --nogroup replacetest
grep -c "touch" output.txt
cat "${tf}"
@@ -360,7 +360,7 @@ cat "${tf}"
runroot rpm -Uvv --fsmdebug \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-3.0-1.noarch.rpm > output.txt 2>&1
-runroot rpm -Va --nouser --nogroup replacetest
+runroot rpm -V --nouser --nogroup replacetest
grep -c "touch" output.txt
cat "${tf}"
echo "xx" > "${tf}"
@@ -369,7 +369,7 @@ cat "${tf}"
runroot rpm -Uvv --fsmdebug \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-4.0-1.noarch.rpm > output.txt 2>&1
-runroot rpm -Va --nouser --nogroup replacetest
+runroot rpm -V --nouser --nogroup replacetest
grep -c "touch" output.txt
cat "${tf}"
@@ -378,7 +378,7 @@ touch -t 201703171717 ${tf}
runroot rpm -U -Uvv --fsmdebug --oldpackage \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-3.0-1.noarch.rpm > output.txt 2>&1
-runroot rpm -Va --nouser --nogroup replacetest
+runroot rpm -V --nouser --nogroup replacetest
grep -c "touch" output.txt
cat "${tf}"
],
@@ -449,13 +449,13 @@ readlink "${tf}"
runroot rpm -U \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-2.0-1.noarch.rpm
-runroot rpm -Va --nouser --nogroup replacetest
+runroot rpm -V --nouser --nogroup replacetest
readlink "${tf}"
runroot rpm -U \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-3.0-1.noarch.rpm
-runroot rpm -Va --nouser --nogroup replacetest
+runroot rpm -V --nouser --nogroup replacetest
readlink "${tf}"
ln -sf "xx" "${tf}"
@@ -464,13 +464,13 @@ readlink "${tf}"
runroot rpm -U \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-4.0-1.noarch.rpm
-runroot rpm -Va --nouser --nogroup replacetest
+runroot rpm -V --nouser --nogroup replacetest
readlink "${tf}"
runroot rpm -U --oldpackage \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-3.0-1.noarch.rpm
-runroot rpm -Va --nouser --nogroup replacetest
+runroot rpm -V --nouser --nogroup replacetest
readlink "${tf}"
],
[0],
@@ -494,7 +494,7 @@ readlink "${tf}"
runroot rpm -Uvv --fsmdebug \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-2.0-1.noarch.rpm > output.txt 2>&1
-runroot rpm -Va --nouser --nogroup replacetest
+runroot rpm -V --nouser --nogroup replacetest
grep -c "touch" output.txt
readlink "${tf}"
@@ -502,7 +502,7 @@ readlink "${tf}"
runroot rpm -Uvv --fsmdebug \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-3.0-1.noarch.rpm > output.txt 2>&1
-runroot rpm -Va --nouser --nogroup replacetest
+runroot rpm -V --nouser --nogroup replacetest
grep -c "touch" output.txt
readlink "${tf}"
ln -sf "xx" "${tf}"
@@ -511,14 +511,14 @@ readlink "${tf}"
runroot rpm -Uvv --fsmdebug \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-4.0-1.noarch.rpm > output.txt 2>&1
-runroot rpm -Va --nouser --nogroup replacetest
+runroot rpm -V --nouser --nogroup replacetest
grep -c "touch" output.txt
readlink "${tf}"
runroot rpm -U -Uvv --fsmdebug --oldpackage \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-3.0-1.noarch.rpm > output.txt 2>&1
-runroot rpm -Va --nouser --nogroup replacetest
+runroot rpm -V --nouser --nogroup replacetest
grep -c "touch" output.txt
readlink "${tf}"
],
@@ -554,17 +554,17 @@ for v in "1.0" "2.0"; do
done
runroot rpm -U /build/RPMS/noarch/replacetest-1.0-1.noarch.rpm
-runroot rpm -Va --nouser --nogroup replacetest
+runroot rpm -V --nouser --nogroup replacetest
runroot rpm -U \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-2.0-1.noarch.rpm
-runroot rpm -Va --nouser --nogroup replacetest
+runroot rpm -V --nouser --nogroup replacetest
chmod 777 "${tf}"
runroot rpm -U \
--oldpackage \
--define "_minimize_writes 1" \
/build/RPMS/noarch/replacetest-1.0-1.noarch.rpm
-runroot rpm -Va --nouser --nogroup replacetest
+runroot rpm -V --nouser --nogroup replacetest
],
[0],
[],
--
2.33.0

View File

@ -0,0 +1,81 @@
From 05fbeb97a92608a9f66faa3f8d1c0fb67b0db62c Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
Date: Wed, 7 Aug 2024 12:42:36 +0300
Subject: [PATCH] Fix crash on Lua file trigger exiting with return'ed data
(#3029)
Conflict:modify the test code because b9b3f3515164 and 7f59c7dd2f4
is not merged.
Reference:https://github.com/rpm-software-management/rpm/commit/05fbeb97a92608a9f66faa3f8d1c0fb67b0db62c
Reset the Lua stack on return from rpmluaRunScript() to discard any
unhandled returned data from the scriptlet. This may happen if there's
eg "return 0" from a non-macro scriptlet.
We could check for a numeric return value here and treat it as an exit
code, but then what to do with other kinds of returned data?
Our documentation states errors in Lua scriptlets should be signaled with
Lua error() function, it seems better to stick with that and avoid
introducing ambiguities and incompatibilities.
Update the existing file trigger tests to cover this case.
Fixes: #3029
---
rpmio/rpmlua.c | 2 ++
tests/data/SPECS/filetriggers.spec | 11 +++++++++++
tests/rpmscript.at | 3 +++
3 files changed, 16 insertions(+)
diff --git a/rpmio/rpmlua.c b/rpmio/rpmlua.c
index ecb21eb82..858be7739 100644
--- a/rpmio/rpmlua.c
+++ b/rpmio/rpmlua.c
@@ -303,6 +303,8 @@ int rpmluaRunScript(rpmlua lua, const char *script, const char *name,
exit:
free(buf);
+ /* discard any unhandled return data from the script */
+ lua_settop(L, otop);
return ret;
}
diff --git a/tests/data/SPECS/filetriggers.spec b/tests/data/SPECS/filetriggers.spec
index 3e2ee0034..e8d3bc7cd 100644
--- a/tests/data/SPECS/filetriggers.spec
+++ b/tests/data/SPECS/filetriggers.spec
@@ -52,6 +52,17 @@ end
print("")
io.flush()
+%filetriggerun -p <lua> -- /usr/bin
+print("filetriggerun(/usr/bin*)<lua>: "..arg[2].." "..arg[3])
+a = rpm.next_file()
+while a do
+ print(a)
+ a = rpm.next_file()
+end
+print("")
+io.flush()
+return 0
+
%filetriggerin -- /foo
echo "filetriggerin(/foo*):"
cat
diff --git a/tests/rpmscript.at b/tests/rpmscript.at
index 8fc729a56..d47705008 100644
--- a/tests/rpmscript.at
+++ b/tests/rpmscript.at
@@ -461,6 +461,9 @@ filetriggerpostun(/foo*):
filetriggerun(/usr/bin*): 0
/usr/bin/hello
+filetriggerun(/usr/bin*)<lua>: 0
+/usr/bin/hello
+
filetriggerpostun(/usr/bin*): 0
/usr/bin/hello
--
2.33.0

View File

@ -0,0 +1,66 @@
From 308ac60677732e9979b9ce11e5a3085906da1901 Mon Sep 17 00:00:00 2001
From: Michal Domonkos <mdomonko@redhat.com>
Date: Fri, 26 Jul 2024 10:44:04 +0200
Subject: [PATCH] Fix root relocation regression
Conflict:Do not modify the test code because the current test code is
different from that of the upstream community. If we directly
modify the test code, the test wull fail. Guaranteed by local
use cases.
Reference:https://github.com/rpm-software-management/rpm/commit/308ac60677732e9979b9ce11e5a3085906da1901
When relocating the root directory, make sure we insert the new path's
dirname to dirNames[] even if the root itself is owned by the package.
This appears to have been the intention from the first version (largely
untouched since) of this code as we allow the root to pass through the
first checks (by setting len to 0 in that case) as well as the second
for loop where we do the relocations.
This allows fsm to properly create and remove the relocated directory
since we're now using fd-based calls (#1919) and the parent directory
needs to be opened first.
No need to do string comparison here, the empty basename signals that
we're processing the root directory, so just use that.
Building a relocatable package that owns the root directory seems to be
a handy way to create user-installable packages (see RHEL-28967) and it
happened to work before with the path-based calls so this technically
was a regression. Add a test that emulates this use case.
Fixes: #3173
---
lib/relocation.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/relocation.c b/lib/relocation.c
index d31cf4779..0202b5c46 100644
--- a/lib/relocation.c
+++ b/lib/relocation.c
@@ -181,8 +181,9 @@ void rpmRelocateFileList(rpmRelocation *relocations, int numRelocations,
rpmFileTypes ft;
int fnlen;
+ size_t baselen = strlen(baseNames[i]);
size_t len = maxlen +
- strlen(dirNames[dirIndexes[i]]) + strlen(baseNames[i]) + 1;
+ strlen(dirNames[dirIndexes[i]]) + baselen + 1;
if (len >= fileAlloced) {
fileAlloced = len * 2;
fn = xrealloc(fn, fileAlloced);
@@ -244,8 +245,9 @@ assert(fn != NULL); /* XXX can't happen */
continue;
}
- /* Relocation on full paths only, please. */
- if (fnlen != len) continue;
+ /* Relocation on '/' and full paths only, please. */
+ if (baselen && fnlen != len)
+ continue;
rpmlog(RPMLOG_DEBUG, "relocating %s to %s\n",
fn, relocations[j].newPath);
--
2.33.0

View File

@ -0,0 +1,114 @@
From 31c14ba6610568c2d634647fed1fb57221178da9 Mon Sep 17 00:00:00 2001
From: Michal Domonkos <mdomonko@redhat.com>
Date: Fri, 26 Jul 2024 10:43:50 +0200
Subject: [PATCH] Make sure dirs are not relocated twice
Conflict:adapt context
Reference:https://github.com/rpm-software-management/rpm/commit/31c14ba6610568c2d634647fed1fb57221178da9
When processing relocations, new dirnames are added to dirNames[] first
and then the rest is relocated. However, we go through the entire array
in the latter step, meaning that we may accidentally relocate an already
relocated path.
Most relocations are fine as they involve two separate directory trees,
and we already skip over directories that don't match the old prefix.
However, that breaks apart if we're relocating to a nested subdirectory
(e.g. /opt -> /opt/new/dir).
Fix this by simply stopping at the original dirCount as the new entries
are always added to the end of dirNames[].
Such relocations are perhaps not very common (or even unsupported) but
relocating the root directory itself may be useful (see the next commit
for details) and that is subject to the same issue.
Note that we currently don't handle root relocations properly to start
with but that will be addressed in the next commit, this prepares the
ground.
---
lib/relocation.c | 6 +++---
tests/rpmi.at | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/lib/relocation.c b/lib/relocation.c
index 1eab60211..d31cf4779 100644
--- a/lib/relocation.c
+++ b/lib/relocation.c
@@ -124,7 +124,7 @@ void rpmRelocateFileList(rpmRelocation *relocations, int numRelocations,
char ** baseNames;
char ** dirNames;
uint32_t * dirIndexes;
- rpm_count_t fileCount, dirCount;
+ rpm_count_t fileCount, dirCount, dirCountOrig;
int nrelocated = 0;
int fileAlloced = 0;
char * fn = NULL;
@@ -163,7 +163,7 @@ void rpmRelocateFileList(rpmRelocation *relocations, int numRelocations,
baseNames = bnames.data;
dirIndexes = dindexes.data;
fileCount = rpmtdCount(&bnames);
- dirCount = rpmtdCount(&dnames);
+ dirCount = dirCountOrig = rpmtdCount(&dnames);
/* XXX TODO: use rpmtdDup() instead */
dirNames = dnames.data = duparray(dnames.data, dirCount);
dnames.flags |= RPMTD_PTR_ALLOCED;
@@ -297,7 +297,7 @@ assert(fn != NULL); /* XXX can't happen */
}
/* Finish off by relocating directories. */
- for (i = dirCount - 1; i >= 0; i--) {
+ for (i = dirCountOrig - 1; i >= 0; i--) {
for (j = numRelocations - 1; j >= 0; j--) {
if (relocations[j].oldPath == NULL) /* XXX can't happen */
diff --git a/tests/rpmi.at b/tests/rpmi.at
index 7d1a0a871..372be0a8b 100644
--- a/tests/rpmi.at
+++ b/tests/rpmi.at
@@ -1135,6 +1135,42 @@ runroot rpm -U --relocate /opt/bin=/bin \
],
[])
RPMTEST_CLEANUP
+
+AT_SETUP([rpm -i relocatable package 2])
+AT_KEYWORDS([install relocate])
+RPMDB_INIT
+
+runroot rpmbuild --quiet -bb /data/SPECS/reloc.spec
+runroot rpmbuild --quiet -bb /data/SPECS/fakeshell.spec
+
+runroot rpm -U /build/RPMS/noarch/fakeshell-1.0-1.noarch.rpm
+
+RPMTEST_CHECK([
+runroot rpm -U \
+ --relocate /opt/bin=/opt/bin/foo/bar \
+ --relocate /opt/etc=/opt/etc/foo/bar \
+ --relocate /opt/lib=/opt/lib/foo/bar \
+ /build/RPMS/noarch/reloc-1.0-1.noarch.rpm
+runroot rpm -ql reloc
+],
+[0],
+[1: /opt/bin/foo/bar
+2: /opt/etc/foo/bar
+3: /opt/lib/foo/bar
+0: /opt/bin/foo/bar
+1: /opt/etc/foo/bar
+2: /opt/lib/foo/bar
+/opt
+/opt/bin/foo/bar
+/opt/bin/foo/bar/typo
+/opt/etc/foo/bar
+/opt/etc/foo/bar/conf
+/opt/lib/foo/bar
+/opt/lib/foo/bar/notlib
+],
+[])
+RPMTEST_CLEANUP
+
AT_SETUP([rpm -i with/without --excludedocs])
AT_KEYWORDS([install excludedocs])
RPMTEST_CHECK([
--
2.33.0

View File

@ -1,6 +1,6 @@
Name: rpm Name: rpm
Version: 4.18.2 Version: 4.18.2
Release: 13 Release: 14
Summary: RPM Package Manager Summary: RPM Package Manager
License: GPLv2+ License: GPLv2+
URL: http://www.rpm.org/ URL: http://www.rpm.org/
@ -41,6 +41,10 @@ Patch6019: backport-Use-unsigned-integers-more-consistently-in-the-handl.patch
Patch6020: backport-Use-proper-type-for-copyTagsFromMainDebug.patch Patch6020: backport-Use-proper-type-for-copyTagsFromMainDebug.patch
Patch6021: backport-Reset-recursion-depth-for-error-message.patch Patch6021: backport-Reset-recursion-depth-for-error-message.patch
Patch6022: backport-Fix-division-by-zero-in-elfdeps-RhBug-2299414.patch Patch6022: backport-Fix-division-by-zero-in-elfdeps-RhBug-2299414.patch
Patch6023: backport-Make-sure-dirs-are-not-relocated-twice.patch
Patch6024: backport-Fix-root-relocation-regression.patch
Patch6025: backport-Fix-crash-on-Lua-file-trigger-exiting-with-return-ed.patch
Patch6026: backport-Fix-V-option-usage-in-our-tests.patch
Patch9000: Add-digest-list-plugin.patch Patch9000: Add-digest-list-plugin.patch
Patch9001: Add-IMA-digest-list-support.patch Patch9001: Add-IMA-digest-list-support.patch
@ -339,6 +343,9 @@ make clean
%exclude %{_mandir}/man8/rpmspec.8.gz %exclude %{_mandir}/man8/rpmspec.8.gz
%changelog %changelog
* Wed Sep 4 2024 gengqihu<gengqihu2@h-partners.com> - 4.18.2-14
- Backport some patches from upstream
* Tue Sep 3 2024 gengqihu<gengqihu2@h-partners.com> - 4.18.2-13 * Tue Sep 3 2024 gengqihu<gengqihu2@h-partners.com> - 4.18.2-13
- Backport some patches from upstream - Backport some patches from upstream