[TriLUG] RPM: spec file questions

Robert Dale rob at nrek.net
Fri Dec 20 10:23:56 EST 2002


On Thu, 19 Dec 2002, H Brett Bolen wrote:

> I'm building a binary rpm -- but it installs to a user
> account.  This is for a navy project, all the user does
> is turns on the computer ( I don't even think there is a
> login), and the files executed from /home/apbtuser.
> 
> I was thinking it might be better to build a src rpm instead
> even though it installs binary files, but currently I'm building
> a binary rpm.

You can build both at the same time using the -ba option.

> I've used rpm2cpio but it didn't give the spec file.

If you have the .src.rpm file, you can install it (rpm -i)
and the spec file will end up in /usr/src/redhat/SPECS/<package>.spec

> Regarding the relative path question, I'm wondering if
> I can build the rpm file from a different tree than
> I'm working on.  For instance this might be the file
> section of the spec file.
> 
>     %files
>     /home/apbtuser/apbt/bin/blah
>     /home/apbtuser/apbt/rtf/blah.xml
>     /home/apbtuser/apbt/dat/blah.db
> 
> Since I install these to that location ( /home/apbtuser/apbt), I
> have to move my dev tree before I can test the rpm build.  Is there
> a way I can do something like this
> 
>     %files
>     ./apbt/bin/blah
> 
> or
> 
>     %file
>     $PATH/apbt/bin/blah

I'm not sure if you're asking how to build relocatable RPMs or how to
change the build root - I think build root.

If you're always going to install to /home/apbtuser/apbt, then I think
you are trying to change the build root.  You can do this two ways:
1) use BuildRoot: in the spec file
2) use rpm --buildroot=<path>

Then you can use $RPM_BUILD_ROOT within the spec file to refer to that
location.

In %files, you still refer to the files with the absolute path as if they
were installed (or, to put it the more correct way, the path relative to
the $RPM_BUILD_ROOT).

Have a look at 
http://www.rpm.org/max-rpm/s1-rpm-anywhere-different-build-area.html too.
Although, they do it a little differently.

If you're trying to build relocatable RPMs, where you may want to install
to /home/fred or even /usr, then you want to look at Prefix: and %prefix
in the spec file.  Then you can change the install location with
rpm --prefix=/some/other/place foo.rpm

HTH

-- 
Robert Dale






More information about the TriLUG mailing list