LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   rpmbuild (https://www.linuxquestions.org/questions/programming-9/rpmbuild-618014/)

pvpnguyen 02-01-2008 03:07 PM

rpmbuild
 
Hello Masters, I am trying to build and rpm package which will display a message like "You have to be root in order to install this package..." if the user is not root. Is there a way to check for user privilege in the rpm spec file? You help is greatly appriciated. Thanks.

Brian1 02-01-2008 05:01 PM

I don't think there is. One can only install rpm as root since update of rpm database will be done during the install.

Brian

unSpawn 02-01-2008 07:25 PM

Like Brian1 said it won't pratical since you can only install packages as root account user, but that doesn't mean there is no way to accomplish this, just use a pre-install section in your .spec file:
Code:

%pre
set -e; [ `id -g` -ne 0 ] && { echo 'be root or be gone'; exit 1; }


pvpnguyen 02-04-2008 08:51 AM

Thank you very much, I will try that in the %pre section of the spec file.

pvpnguyen 02-08-2008 10:25 AM

Hello UnSpawn,

Somehow the rpm checks for /var/lib/rpm/__db.000 lock first before the %pre section. What I get if I install the rpm as no-root is: error: can't create trasnsaction lock on /var/lib/rpm/__db.000. For new users, they don't know what the problem is. That's why I need to display that message out the the user. Is there anyother way? Thanks so much

cetialphav 02-08-2008 10:17 PM

One option would be to create a shell script to your users instead of a raw rpm. The shell script could extract the rpm from the script itself and then run whatever commands you want. There are plenty of linux installers that do something like this. Take a look at http://megastep.org/makeself/. That may work for you.


All times are GMT -5. The time now is 05:31 AM.