[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: My first RPM
- From: Tim Mooney <mooney dogbert cc ndsu NoDak edu>
- To: RPM Package Manager <rpm-list redhat com>
- Subject: Re: My first RPM
- Date: Tue, 12 Sep 2006 16:51:45 -0500 (CDT)
In regard to: My first RPM, Dave Morrow said (at 4:00pm on Sep 12, 2006):
Basically, I am wondering if someone can assist me. I want the RPM I am
creating to create a user if it does not already exist. Can someone
assist me with this? (Assuming it can be done )
RPM supports scripts that fire at multiple different times during the
installation and removal process, and those scripts can use any
interpreter you want, so you can accomplish pretty much anything your
heart desires. With great power comes great responsibility, though. ;-)
We do this very thing in one of our RPMs. We need the user (and a custom
group) to exist before any files contained in the RPM are dropped onto
the system, so we use a %pre script.
We define the login name, numeric id, group name, and other attributes of
the account at the top of the spec file via %defines, so that it can be
easily customized by editing that portion of the file, without having to
hunt through the scripts.
We also have a %postun script that removes the user and group if the
RPMs are completely uninstalled. Be very careful if you do this, though,
or you'll run into the problem that another person was reporting just a
couple days ago -- a previous version of the RPM accidentally removes the
account even on upgrade (for RPM, an upgrade is a new install followed
by an old removal, which means the %postun script for version X.Y.Z of
the package runs *after* the %pre/%post for version X.Y.Z+1). This is
documented in Maximum RPM, and can be avoided by having your scripts all
check what's passed to them as $1, and then only acting if the number
(which will be 0 or 1) is appropriate for the action you're going to
take.
Tim
--
Tim Mooney mooney dogbert cc ndsu NoDak edu
Information Technology Services (701) 231-1076 (Voice)
Room 242-J6, IACC Building (701) 231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]