Re: My first RPM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxxxxxxx
Information Technology Services         (701) 231-1076 (Voice)
Room 242-J6, IACC Building              (701) 231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164

_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/rpm-list

[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux