LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


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

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


hello,
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?
regards,
cranium
 
Old 03-11-2005, 02:01 AM   #2
fuzzyash
Member
 
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 -> http://www.rpm.org/max-rpm-snapshot/

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
fuzzyash
Member
 
Registered: Aug 2003
Location: Melbourne Australia
Distribution: Fedora Core 4
Posts: 184

Rep: Reputation: 30
Ooops

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


Reply



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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