Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-10-2005, 11:49 PM   #1
Registered: Feb 2004
Distribution: FC4,RHEL4
Posts: 223

Rep: Reputation: 30
RPM spec file install rule how its evaluated?

There's a spec file that used to create rpm package. there i found following install rule
mkdir -p $RPM_BUILD_ROOT%{_bindir}
I know what is _bindir but unable to find RPM_BUILD_ROOT variable also why -p used with mkdir here?
Old 03-11-2005, 02:01 AM   #2
Registered: Aug 2003
Location: Melbourne Australia
Distribution: Fedora Core 4
Posts: 184

Rep: Reputation: 30
BuildRoot: - Your friend

Have a look in the spec file for a line beginning with "BuildRoot:". The path on the right hand side of the colon ( is what the variable "$RPM_BUILD_ROOT" gets assigned with. For example, if the spec file has the line "BuildRoot:%{_tmppath}/%{name}-%{version}-root" then every time you see the variable "$RPM_BUILD_ROOT" it is replaced with "%{_tmppath}/%{name}-%{version}-root". This tag is usually located in the preamble part of the spec file. (the first group of "tags", name:value, usually up to the first blank line & before any "%" style tags of which the "%description" tag is usually first)
And just in case you don't already know, this variable is for telling rpmbuild what to use as the root dir of where to temporarily install the compiled app. In other words, if you were building it yourself, without rpmbuild, & you issued the "make install" command as root, the same files that would have been copied to your system will be copied using the "BuildRoot:" location as the prefix to every file that gets installed, just as if you used the "--prefix=" argument to "make install". This is not actually necessary because rpmbuild gets it's list of files to include in the rpm you are building from the "%files" list in the spec file. If the "BuildRoot:" tag is not used though, when rpmbuild gets to the "%install" part of the build & tries to install the files to your filesystem, it will return errors because it can not write to the specified directories, which, unless your are running rpmbuild as root, (which I hope your not) will kill rpmbuild. The "BuildRoot:" tag also comes in handy when you want to check what files get installed before you build the rpm. Personally, I like to use "BuildRoot: %{_topdir}/installroot" & start off by issuing "rpmbuild -bi" so that I can easily check what files get installed by viewing the contents of ~/redhat/installroot.
Another thing to note is that the "BuildRoot:" tag can not be added to your ~/.rpmmacros file, it must be added to every spec file individually.
A good site to teach you how to use rpmbuild is Maximum RPM which can be found here ->

As for the -p switch to mkdir, the first thing you should do is read the man page for mkdir with the command "man mkdir". All it does is make any parent directories that don't already exist. For example, if you execute "mkdir ~/temp_dir/test_dir", mkdir will return saying "mkdir: cannot create directory `./temp_dir/test_dir': No such file or directory", but if you include the "-p " switch, mkdir will make all dir's required to make the dir that you actually want, just like it would if you did "mkdir ~/temp_dir " then "mkdir ~/temp_dir/test_dir".

These were both very easy questions that you should have been able to find an answer to yourself, as I did. There is an absolute plethora of sites out there devoted to ALL matters pertaining to Linux, & almost all command line tools have a man page which is usually the best place to start.

Hope this helped!
Old 03-11-2005, 02:03 AM   #3
Registered: Aug 2003
Location: Melbourne Australia
Distribution: Fedora Core 4
Posts: 184

Rep: Reputation: 30

Sorry, that smiley face at the top should be a : surrounded by brackets


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
RPM Spec file creation, %files section question davidas Linux - Software 1 09-13-2007 02:26 AM
questions on writing own rpm .spec file adrianmak Linux - Software 0 08-18-2005 06:03 AM
%file attribute for RPM SPEC files Brian of Gep Linux - Software 3 06-18-2004 04:51 AM
%file attribute for RPM SPEC files Brian of Gep Fedora 0 06-15-2004 07:12 PM
RPM Spec file creation: %file section question davidas Linux - Newbie 0 03-16-2004 10:36 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:10 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration