Base directory of the package

Hello, I have an RPM package for which I need to know the base directory /opt/appdir. But if the package is relocated, then it will be different. I need to get the value dynamically.

I tried to query the RPM with INSTPREFIXES but couldn't get the value. The only way I see is to do 'rpm -ql RPM Name' and grep for the script that I know
inside the package.
The package contains a script under /opt/appdir/ABCDInstaller/bin/ABCDInstaller.sh

from which I need to get the path '/opt/appdir'.

Can you help how I can get the path. Also, is there a better way to get the base directory of the package.

Thanks,
C H

RPM doesn't really have a concept of "base directory" I think, since neither does UNIX. Files get put in various places based on their function. Whatever this is short-circuits that by dumping everything in /opt/ where it can do whatever it pleases.

You could use --list to list the files in the package, perhaps.

Or the rpm2targz utility may be useful, since you can just get straight filenames out of a tarball with tar -ztf filename.tar.gz and do what you want with the paths from there.

The RPM package I am talking about is created in such a way that it is installed by default under /opt. It is relocatable to any other path using --relocate option. I need to get that value dynamically.

For that, part of my solution is to query for a script in the package and get the base directory.

From the below line,
/opt/appdir/ABCDInstaller/bin/ABCDInstaller.sh

I know the RPM package will install the directory ABCDInstaller. So I want to get the value before that which in this case is /opt/appdir.

Thanks,
Ravi