ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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; }
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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.