Bug 2055033 - rpm migration scriptlet should be converted to lua?
Summary: rpm migration scriptlet should be converted to lua?
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm
Version: 37
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Neal Gompa
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 2018913 2164378
TreeView+ depends on / blocked
 
Reported: 2022-02-16 09:07 UTC by Zbigniew Jędrzejewski-Szmek
Modified: 2023-01-25 12:01 UTC (History)
7 users (show)

Fixed In Version: rpm-4.17.0-9.fc36 rpm-4.17.0-9.fc37
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2164378 (view as bug list)
Environment:
Last Closed: 2023-01-25 11:57:47 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Zbigniew Jędrzejewski-Szmek 2022-02-16 09:07:23 UTC
Description of problem:
dnf install --installroot=… reports error in scriptlets:

  Running scriptlet: rpm-4.17.0-8.fc36.x86_64                                                                      202/334 
/var/tmp/rpm-tmp.9pzeVc: line 3: mkdir: command not found
/var/tmp/rpm-tmp.9pzeVc: line 4: sort: command not found

  Installing       : rpm-4.17.0-8.fc36.x86_64                                                                      202/334 

If it can't be rewritten in lua, then please at least redirect all
errors to /dev/null.

Version-Release number of selected component (if applicable):
rpm-4.17.0-8.fc36.x86_64

How reproducible:
deterministic

Steps to Reproduce:
1. sudo dnf install --releasever=rawhide --repo=fedora --installroot=/var/tmp/f36-test3 rpm --nogpgcheck --setopt install_weak_deps=False

(With this reproducer I get just "find: command not found".)

Comment 1 Neal Gompa 2022-02-16 12:30:13 UTC
How in the world is this happening? This scriptlet only runs if "/var/lib/rpm" as a directory exists. What is creating that directory before rpm migrates it?

Comment 2 Neal Gompa 2022-02-16 12:31:48 UTC
And after I write this, I know why...

*sighs*

The joys of installroot... It's easy enough to fix by adding some Requires(pre) statements.

Comment 3 Neal Gompa 2022-02-16 12:43:51 UTC
PR submitted: https://src.fedoraproject.org/rpms/rpm/pull-request/23

Once merged, the rawhide branch can be fast-forwarded onto the f36 branch to fix this.

Comment 4 Neal Gompa 2022-02-17 12:29:55 UTC
PR merged and updated packages built in F36 and Rawhide now.

Comment 5 Ben Cotton 2022-08-09 13:42:01 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 37 development cycle.
Changing version to 37.

Comment 6 Pavel Raiskup 2023-01-25 10:17:33 UTC
On F38 (Rawhide):

$ /usr/bin/dnf5 --installroot /var/lib/mock/fedora-rawhide-x86_64-bootstrap/root/ --releasever 38 install rpm
...
Running transaction
[1/2] Verify package files                                                                                                                                                                          100% | 133.0   B/s | 167.0   B |  00m01s
>>> Running pre-transaction scriptlet: filesystem-0:3.18-2.fc37.x86_64
>>> Stop pre-transaction scriptlet: filesystem-0:3.18-2.fc37.x86_64
[2/3] Prepare transaction                                                                                                                                                                           100% |   1.1 KiB/s | 167.0   B |  00m00s
>>> Running pre-install scriptlet: rpm-0:4.18.0-9.fc38.x86_64
>>> Stop pre-install scriptlet: rpm-0:4.18.0-9.fc38.x86_64
>>> Error in pre-install scriptlet: rpm-0:4.18.0-9.fc38.x86_64 return code 2
...
Transaction failed: Rpm transaction failed.

Comment 7 Pavel Raiskup 2023-01-25 10:18:49 UTC
PR: https://src.fedoraproject.org/rpms/rpm/pull-request/34

Comment 8 Panu Matilainen 2023-01-25 11:06:24 UTC
Ehm, this is an old bug long since fixed. Please open a new bug because it's not the same at all now. Note that adding a bash dependency to a regular scriptlet will achieve precisely nothing because /bin/sh is already an interpreter-dependency on it. (but then, I see no indication that missing bash is the cause in the latest message either)

Comment 9 Pavel Raiskup 2023-01-25 11:46:39 UTC
As shown, filesystem.rpm'đ %pretrans is executed first, and right after
that then rpm.rpm's %pre.  This is a fresh --installroot transaction,
therefore I'm curious how do you guarantee that bash is installed first
in the transaction.

Comment 10 Panu Matilainen 2023-01-25 11:56:00 UTC
It wasn't entirely clear from that snippet, but yeah I can reproduce. That's not going to be fixed by adding dependencies to rpm because it already has everything it needs. Rpm getting installed first in this scenario is entirely backwards, it's supposed to be installed *last* or almost so based on dependencies. If you compare the behavior with older dnf, that's exactly what happens. 

What you're seeing smells like a dnf5 bug. Please open a new bug on this and cc me on it.

Comment 11 Panu Matilainen 2023-01-25 11:57:47 UTC
In the meanwhile, the original issue has been fixed long since but the bug never got closed.

Comment 12 Panu Matilainen 2023-01-25 11:59:01 UTC
Oh and no, it does not need converting to Lua. Rpm has no %pretrans script (which is the thing *requiring* Lua) and is not a part of the early "bootstrap" set of packages (glibc,setup,filesystem etc) so there's nothing to gain from converting the script.


Note You need to log in before you can comment on or make changes to this bug.