LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   RPM spec file install rule how its evaluated? (https://www.linuxquestions.org/questions/programming-9/rpm-spec-file-install-rule-how-its-evaluated-300255/)

cranium2004 03-10-2005 11:49 PM

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

fuzzyash 03-11-2005 02:01 AM

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!

fuzzyash 03-11-2005 02:03 AM

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


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