Bug 59319 - Using rpm from within %post install-script fails
Summary: Using rpm from within %post install-script fails
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: rpm   
(Show other bugs)
Version: 7.2
Hardware: All Linux
Target Milestone: ---
Assignee: Jeff Johnson
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2002-02-05 09:35 UTC by Fritz Elfert
Modified: 2008-05-01 15:38 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-02-05 09:37:17 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
specfile for creating an RPM which waits in %post until /tmp/rpmloop is removed (454 bytes, text/plain)
2002-02-05 09:37 UTC, Fritz Elfert
no flags Details

Description Fritz Elfert 2002-02-05 09:35:13 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.78 [de] (X11; U; Linux 2.4.9-21 i686; Nav)

Description of problem:
I'm currently building some packages which depend on a relocatable
third-party package (IBMJava2-SDK) and need to create some symlinks
depending on _where_ the user actually has installed IBMJava2-SDK.
Since installation of IBMJava2-SDK does not create any system-wide
config files, tried to retrieve the prefix using the following
line in my %post script

JDKPREFIX=`rpm -q --queryformat '%{INSTALLPREFIX}\n' IBMJava2-SDK`

however when executing, i get the following error:

error: cannot get shared lock on /var/lib/rpm/Packages
error: cannot open Packages index using db3 - Operation not permitted (1)

If i would do a write-operation on the database, i would understand
this error, but a query should open the rpm-db read-only?!

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Create a dummy RPM with the attached spec.
2. Install this RPM, it will hang in until you delete /tmp/rpmloop
3. On a second console, try some rpm queries, they will fail.

Additional info:

Comment 1 Fritz Elfert 2002-02-05 09:37:12 UTC
Created attachment 44517 [details]
specfile for creating an RPM which waits in %post until /tmp/rpmloop is removed

Comment 2 Jeff Johnson 2002-02-05 14:59:12 UTC
You can't invoke rpm from %post et al scriptlets
because (as you have seen) the rpmdb has an
exclusive lock.

The install prefix that you want is in an environment
variable. Build a test package with
	exit 1
build, install with relocation, and you'll see the environment
variable you want.

Comment 3 Fritz Elfert 2002-02-05 16:55:48 UTC
You misunderstood,

I want to retrieve the install-prefix of _ANOTHER_ (thirparty),
previously installed relocatable package from within the
%post script of _MY_ package, _NOT_ the prefix of my package (that would
be too easy ;-))

Comment 4 Jeff Johnson 2002-02-05 17:03:29 UTC
Then you can't do that from a %post scriptlet.

You might try using slocate to find a file from the other
package. Another alternative is to explicitly restrict
relocations to a known set, and check each member of
the set for installation.

There's also the quick hack of passing an environment
variable to the %post scriptlet from a query performed
before attempting an install. Not recommended, but I
believe that will work.

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