[Fedora-packaging] what a buildroot is

Björn Persson bjorn at xn--rombobjrn-67a.se
Sun Apr 15 21:59:47 UTC 2012


Kamal Ahmed wrote:
> Name: foo ... BuildRoot: /tmp/%{name} %prep ... %build ... %install install
> -m755 $RPM_BUILD_ROOT/obj/ggsnc/ggsnc %{_bindir}/ %files /usr/bin/ggsnc

I think I see the misunderstanding. Perhaps it will help you if I point out 
that "buildroot" is a very badly chosen word. It should have been called 
"installroot". The buildroot is not where the build takes place, it's a 
staging directory that you install into. That "chroot" or "root simulated 
environment" you're asking for, that's what the buildroot is.

In other words, you shouldn't try to copy files *from* the buildroot, you 
should copy them *to* the buildroot.

Use these spec file fragments:

# Define a temporary installation root.
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

%install
# Make an empty installation root.
rm -rf %{buildroot}
mkdir -p %{buildroot}
# Make directories in the installation root.
mkdir -p %{buildroot}%{_bindir}
# Copy files to the installation root.
cp obj/ggsnc/ggsnc %{buildroot}%{_bindir}

%files
%{_bindir}/ggsnc

Be sure to note carefully where I have used "%{buildroot}" in the code above, 
and where I have not used it.

(It doesn't matter much whether you use "%{buildroot}" (an RPM macro) or 
"$RPM_BUILD_ROOT" (a shell variable). I prefer the RPM macro because I think 
it makes the spec file more readable.)


By the way, please don't reply to another message unless the message you're 
writing is actually a reply to that message. This thread is shown as replies 
to a question from Mihamina Rakotomandimby that it actually has nothing to do 
with.

Björn Persson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.fedoraproject.org/pipermail/packaging/attachments/20120415/276d0315/attachment.sig>


More information about the packaging mailing list