RPM Build ?? My rpm does nothing :(

Stuart stuart at sjsears.com
Thu Mar 24 20:35:37 UTC 2005


On Thursday 24 March 2005 17:54, Michael Gale wrote:
> Hello,
>
> I just ran rpm -qpl nrpe-2.0-1.src.rpm and it says that it does not
> contain files.
This is because it doesn't.
your %files section in your .spec file does not list any files at all.
This is the list that rpm uses to decide which files to package...
but apart from this there are a few more serious points to consider.
1. You are building your rpm as root.
this is a Very Bad Thing, particularly in your case, as you have made a
couple 
of quite serious errors in your spec file that with a more complex
package 
could cause major system damage.
you should build as a non-privileged user.
this means that you
a) create a ~/.rpmmacros file which contains a line like
%_topdir /home/stuart/REDHAT
b) you then create the directory mentioned above and a few
subdirectories:
mkdir -p /home/stuart/REDHAT/{RPMS,SRPMS,BUILD,SOURCES,SPECS}
you then put the spec/source files into these directories and work
there. This 
limits the damage you can do to your system with a badly written .spec
file
2. you misunderstand (slightly) how the rpm build process works.
This may be because you have made some simple assumptions about it.
There is 
very good guide to doing this on http://freshrpms.net somewhere.
Perhaps 
someone else can supply the complete URL for you.
I'll show you the part of your spec file that makes me think this:
# -- extract from spec file
>%prep
>%setup
>./setup-nrpe.sh
why not the ./configure options that are (presumably) included in the
setup 
script? RPM is designed to do these things for you.
incidentally, what precisely does ./setup-nrpe.sh do?

>%build
>make RPM_OPT_FLAGS="$RPM_OPT_FLAGS"
fine

>%install
>rm -rf $RPM_BUILD_ROOT
also ok, but usually done in a %clean section

>install -s -m 755 src/nrpe /home/nrpe/nrpe 
>chown nrpe:nrpe /home/nrpe/nrpe
>install -m 644 nrpe.cfg-rpminstall /home/nrpe/nrpe.cfg
>install -s -m 755 nrpe.init-script /etc/rc.d/init.d/nrpe
these are the main issues - you are copying files *directly*
into /home 
and /etc (etc) with these commands.
what you *should* be doing is something like this:
mkdir -p $RPM_BUILD_ROOT/home/nrpe/nrpe
install -s -m 755 src/nrpe $RPM_BUILD_ROOT/home/nrpe/nrpe
etc etc.
This is because an rpmbuild does a chrooted install into its buildroot
and 
expects to find files to package under there.
doing it the way that you have copies files straight into your live 
fileystem, probably overwriting any that were already there with the
same name
doing this as root is extremely hazardous to your system's health.

>ln -s /etc/rc.d/init.d/nrpe /etc/rc.d/rc3.d/nrpe
you should really create a chkconfig-compliant init script and add it as
part 
of a %post scripts in your rpm .spec file. You should also realise that
this 
script will never actually run as it is not called (something like)
S88nrpe.
you would also need to add the user nrpe in a %pre script, or their
home 
directory will not exist *unless* you create it before you install the
rpm 
package you are building. This means your rpm will only install on some 
systems and not on others...
>%clean
>rm -rf $RPM_BUILD_ROOT

>%files
>%defattr(-,root,root)
Assuming that you install into the $RPM_BUILD_ROOT as designed, this
should be 
a list of the files you want packaged with the 
RPM_BUILD_ROOT stripped from their paths, ie in your case
%files
%defattr(-,root,root)
/home/nrpe/nrpe
/home/nrpe/nrpe.cfg
/etc/rc.d/init.d/nrpe
bearing in mind that with you %defattr line you have changed the
ownership on 
all of these files to root:root!


> On Thu, 2005-03-24 at 10:48 -0700, Michael Gale wrote:
> > Hello,
> >
> > I am trying to build a package for nrpe-2.0, I was following the
> > instructions at http://www.rpm.org/RPM-HOWTO/build-it.html.
I would also recommend you look at the RPM articles written by Chip
Turner in 
past editions of the Red hat Magazine 
http://www.redhat.com/magazine/002dec04/ (and also issue 1 if you can
find 
it)
and http://www.rpm.org/max-rpm
which is rather out of date but there are links to updated CVS versions.

HTH

Stuart
--
Stuart Sears RHCE, RHCX, RTFM, ASAP
A businessman is a hybrid of a dancer and a calculator.
		-- Paul Valery





More information about the redhat-list mailing list