Discussion:
%files section of SPEC file
Joshua M. Miller
2007-07-23 17:02:14 UTC
Permalink
Good morning,

I am new to RPM creation and I am attempting to build my first "ground
up" package. I'm using RH 4.5 as a build platform and have the
following question:

I have the following variables relevant to this discussion:

%define buildroot /usr/src/redhat

When populating the %files section, how do I specify that a file should
be taken from the build root of:

%{buildroot}/etc/

...and placed in the final destination of:

/etc

I keep getting the entire %{buildroot} created on the destination host.

TIA,
--
Joshua M. Miller - RHCE,VCP
Joshua M. Miller
2007-07-23 17:04:34 UTC
Permalink
One minor inconsequential correction below to the %{buildroot} variable.

Thanks,
--
Joshua M. Miller - RHCE,VCP
Post by Joshua M. Miller
Good morning,
I am new to RPM creation and I am attempting to build my first "ground
up" package. I'm using RH 4.5 as a build platform and have the
%define pkg_name <package>
%define buildroot /usr/src/redhat/BUILD/%{pkg_name}
When populating the %files section, how do I specify that a file should
%{buildroot}/etc/
/etc
I keep getting the entire %{buildroot} created on the destination host.
TIA,
Matthew Miller
2007-07-23 17:21:51 UTC
Permalink
Post by Joshua M. Miller
%define buildroot /usr/src/redhat
Err, don't do that. It doesn't do what you think it does. The buildroot is
the temporary directory where the files to be installed are placed. Then the
rpm archive is built from that layout.
Post by Joshua M. Miller
When populating the %files section, how do I specify that a file should
%{buildroot}/etc/
/etc
Putting them into the buildroot is what the %install section is for. In the
%files section, list them relative to the final destination.
--
Matthew Miller ***@mattdm.org <http://mattdm.org/>
Boston University Linux ------> <http://linux.bu.edu/>
Joshua M. Miller
2007-07-23 17:31:06 UTC
Permalink
Thanks for the help, Mathew.

If I understand what you're saying correctly, does this mean I can build
an RPM and specify the files in the %files section relative to their
final destination, without actually having them in the final destination
on the build host, but keeping them in the buildroot?

TIA,
--
Joshua M. Miller - RHCE,VCP
Post by Matthew Miller
Post by Joshua M. Miller
%define buildroot /usr/src/redhat
Err, don't do that. It doesn't do what you think it does. The buildroot is
the temporary directory where the files to be installed are placed. Then the
rpm archive is built from that layout.
Post by Joshua M. Miller
When populating the %files section, how do I specify that a file should
%{buildroot}/etc/
/etc
Putting them into the buildroot is what the %install section is for. In the
%files section, list them relative to the final destination.
Bob Proulx
2007-07-23 17:49:33 UTC
Permalink
Post by Joshua M. Miller
If I understand what you're saying correctly, does this mean I can build
an RPM and specify the files in the %files section relative to their
final destination,
Yes.
Post by Joshua M. Miller
without actually having them in the final destination on the build
host, but keeping them in the buildroot?
Yes.

'%install' them into the build root area. "buildroot" is really
an image location staging area. It is the root of the area where the
package is built.

Bob
Matthew Miller
2007-07-23 17:46:56 UTC
Permalink
Post by Joshua M. Miller
If I understand what you're saying correctly, does this mean I can build
an RPM and specify the files in the %files section relative to their
final destination, without actually having them in the final destination
on the build host, but keeping them in the buildroot?
Yes. That's exactly what buildroot is for. Put this line or something
similar in your spec file:

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

(Eventually, this will be standardized properly as predefined and you won't
have to include this line, but for now, it's important to have.)

and then install your package's files underneath %{buildroot}. If you're
lucky, "make install DESTDIR=%{buildroot}" will work for the program
you're packaging. If that doesn't work, try "%makeinstall".
--
Matthew Miller ***@mattdm.org <http://mattdm.org/>
Boston University Linux ------> <http://linux.bu.edu/>
Jos Vos
2007-07-23 18:16:13 UTC
Permalink
Post by Matthew Miller
Yes. That's exactly what buildroot is for. Put this line or something
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Yes, and don't "%define buildroot", as was in your sample code, which
I've never seen used and I don't know what side effects it has, and
don't use some buildroot path below /usr/src/redhat or so, that's the
wrong usage, it should be a tmp path.
--
-- Jos Vos <***@xos.nl>
-- X/OS Experts in Open Systems BV | Phone: +31 20 6938364
-- Amsterdam, The Netherlands | Fax: +31 20 6948204
Tony Earnshaw
2007-07-23 19:05:57 UTC
Permalink
Post by Jos Vos
Post by Matthew Miller
Yes. That's exactly what buildroot is for. Put this line or something
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Yes, and don't "%define buildroot", as was in your sample code, which
I've never seen used and I don't know what side effects it has, and
don't use some buildroot path below /usr/src/redhat or so, that's the
wrong usage, it should be a tmp path.
Apart from which, there's some sodding good documentation out there,
including maximum.rpm (http://www.rpm.org/max-rpm/), Fedora
(http://docs.fedoraproject.org/drafts/rpm-guide-en/index.html) and
Gurulabs (www.gurulabs.com/GURULABS-RPM-LAB/GURULABS-RPM-GUIDE-v1.0.PDF)
for those with any nouse at all. Not only did I find all those for
myself, but I absolutely hate asking others for help with tying my own
bootlaces when I can do it myself (learned as a kiddie before kindergarten).

I use swish-e to index a hotchpotch of maximum and Fedora so's I can
look up on words. When I'm feeling particularly stupid, I call up
acrobat reader and Gurulabs to read, once again, what's on page 20.

Notwithstanding, I've had some hand-holding from Bob the cyclist and
pilot and Jeff on this list, for which I'll ever be grateful.

Any body seeking (obviously as root) to build in /usr/src should be
chastised and the errors of his ways plainly pointed out.

--Tonni
--
Tony Earnshaw
Email: tonni at hetnet dot nl
Joshua M. Miller
2007-07-23 19:07:07 UTC
Permalink
Thanks for the help, Mathew.

I was packaging a set of files that I had not built, I was merely using
RPM for the convenience factor of distributing them so I had to define
my buildroot in this case. I have been able to build and deploy the RPM
defining the BuildRoot as you describe.

Thanks a lot,
--
Joshua M. Miller - RHCE,VCP
Post by Matthew Miller
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
(Eventually, this will be standardized properly as predefined and you won't
have to include this line, but for now, it's important to have.)
Loading...