diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2022-03-23 14:25:31 +0200 |
---|---|---|
committer | Michal Domonkos <mdomonko@redhat.com> | 2022-07-01 10:52:14 +0200 |
commit | 9e9745e25fc1899bb8da21b08e583b2bd8cce355 (patch) | |
tree | 2dc660d1ec7074a39ffabd28237d9f5a89b72f05 | |
parent | 73fe137c0fee957ee8e0872a547698404ff73b64 (diff) | |
download | rpm-9e9745e25fc1899bb8da21b08e583b2bd8cce355.tar.gz |
Fix excluded paths taking part in file disposition calculations
Commit f311fb65eea4791fa15a00412384b96fdccbbf1c added a step to reset
calculated states between rpmtsRun() calls to allow for %pretrans
hacks, but this causes actions set for --excludepath to get lost.
While those do get recalculated at the time of actual install and
correctly skipped, this causes them to be considered for file
disposition which they should not.
(cherry picked from commit 0bb3fa9025882cd11867ffa0f8ab0bf3e6314d70)
-rw-r--r-- | lib/rpmfs.c | 9 | ||||
-rw-r--r-- | tests/rpme.at | 17 |
2 files changed, 23 insertions, 3 deletions
diff --git a/lib/rpmfs.c b/lib/rpmfs.c index ed272a9f1..874fce130 100644 --- a/lib/rpmfs.c +++ b/lib/rpmfs.c @@ -17,8 +17,7 @@ rpmfs rpmfsNew(rpm_count_t fc, int initState) { rpmfs fs = xcalloc(1, sizeof(*fs)); fs->fc = fc; - fs->actions = xmalloc(fs->fc * sizeof(*fs->actions)); - rpmfsResetActions(fs); + fs->actions = xcalloc(fs->fc, sizeof(*fs->actions)); if (initState) { fs->states = xmalloc(sizeof(*fs->states) * fs->fc); memset(fs->states, RPMFILE_STATE_NORMAL, fs->fc); @@ -119,6 +118,10 @@ void rpmfsSetAction(rpmfs fs, unsigned int ix, rpmFileAction action) void rpmfsResetActions(rpmfs fs) { if (fs && fs->actions) { - memset(fs->actions, FA_UNKNOWN, fs->fc * sizeof(*fs->actions)); + for (int i = 0; i < fs->fc; i++) { + /* --excludepaths is processed early, avoid undoing that */ + if (fs->actions[i] != FA_SKIPNSTATE) + fs->actions[i] = FA_UNKNOWN; + } } } diff --git a/tests/rpme.at b/tests/rpme.at index 2d395e27c..f46d64a6b 100644 --- a/tests/rpme.at +++ b/tests/rpme.at @@ -226,6 +226,23 @@ for p in a b; do done AT_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 -e conflicta +runroot rpm -Vav --nogroup --nouser conflictb +runroot rpm -e conflictb +runroot rpm -Vp --nogroup --nouser /build/RPMS/noarch/conflictb-1.0-1.noarch.rpm +], +[1], +[......... /usr/share/my.version +......... /usr/share/my.version (not installed) +......... /usr/share/my.version (not installed) +missing /usr/share/my.version +], +[]) + +AT_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 |