1

I am writing my first spec file and one thing I do not understand is how to make it dynamic. I am using other spec files as reference and noticed that many have name / version loaded dynamically. I am wondering how to do this? Here is an example:

http://svn.apache.org/repos/asf/hbase/branches/0.94/src/packages/rpm/spec/hbase.spec

Mainly I am wondering what these sections mean:

%define _source      @package.name@
%define _final_name  @final.name@ 
%define _prefix      @package.prefix@
%define _bin_dir     %{_prefix}/bin 
%define _conf_dir    @package.conf.dir@
%define _include_dir %{_prefix}/include
....

Also I'm wondering what exactly {_prefix} actually is?

Sorry for the newbie questions. I'm having an unusual amount of trouble finding info on this.

catagon87
  • 548
  • 5
  • 21

1 Answers1

0

%{_prefix} (and lots of other macros) are defined in /usr/lib/rpm/macros. These are read by rpmbuild and substituted when parsing the spec file. %{_prefix} specifically denotes the installation prefix which is used when installing things into the root filesystem. This usually is /usr. Macros in /usr/lib/rpm/macros* define paths and more according to the file system layout and packaging conventions of the distribution one is building the package on. For instance, a distro might for some reason want to have all binaries installed in /foo/bin, in which case it would ship an macro file with the %{_bindir} macro set accordingly.

All keys between @ (such as @package.name@) usually denote placeholders for autoconf variables, these are substituted when running autoconf, see [1]. These are often used to automatically generate an appropriate file (in this case, spec file) from a template (which includes the said @ delimited placeholders) when configuring a source package.

As far as passing other variables is concerned, here are some options [2]. These may be used when the user wishes to be able to dynamically control certain aspects of the package.

[1] http://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Setting-Output-Variables.html

[2] How to pass user defined parameters to rpmbuild to fill variables

Community
  • 1
  • 1
smani
  • 1,953
  • 17
  • 13