1 |
### FILE rpm-preamble
|
2 |
|
3 |
#When build with non-empty buildroot rpm runs some post scripts
|
4 |
#to strip the binary. Following two definition avoid running those
|
5 |
#scripts. These scripts were not doing anything in past as we always
|
6 |
#built with empty buildroot.
|
7 |
%define __os_install_post %{nil}
|
8 |
%define __spec_install_post %{nil}
|
9 |
|
10 |
# Preliminarily define where things go. These are the places we
|
11 |
# know even without knowing the architecture yet. In particular
|
12 |
# we need %_specdir to find "cmsos" to determine the architecture.
|
13 |
# Note that we define the values all here, but some of them are
|
14 |
# not actually usable until we've managed to defined %cmsplatf.
|
15 |
#
|
16 |
# "instroot" is the root of the private RPM package tree, it gets
|
17 |
# both the RPM database as well as all the packages into it. It
|
18 |
# also has all the RPM standard dirs in it: SPECS, SOURCES, BUILD,
|
19 |
# RPMS, SRPMS. However we fudge those significantly to make sure
|
20 |
# there is no chance data from packages or different platforms can
|
21 |
# ever mix.
|
22 |
#
|
23 |
# Under the "instroot" there are other subtrees: external, lcg, cms.
|
24 |
# External software is installed under the first, while LHC software
|
25 |
# releases go under the others. Which tree is used is determined by
|
26 |
# install.sh from the group the spec belongs to.
|
27 |
#
|
28 |
# The default installation root is "/cms". This can be changed,
|
29 |
# e.g. from RPM command line, but currently only up to producing
|
30 |
# binary RPMs. The binaries are not relocatable (yet?).
|
31 |
%if "%{?instroot:set}" != "set"
|
32 |
%define instroot /cms
|
33 |
%endif
|
34 |
|
35 |
%if "%{?cmsroot:set}" != "set"
|
36 |
%define cmsroot %instroot
|
37 |
%endif
|
38 |
|
39 |
%if "%{?tempprefix:set}" != "set"
|
40 |
%define tempprefix tmp
|
41 |
%endif
|
42 |
|
43 |
%if "%{?allpkgreqs:set}" != "set"
|
44 |
%define allpkgreqs %{pkgreqs}
|
45 |
%endif
|
46 |
|
47 |
%if "%{?builddirectpkgreqs:set}" != "set"
|
48 |
%define builddirectpkgreqs %{nil}
|
49 |
%endif
|
50 |
|
51 |
# We define cmsbuildApiVersion to be 0 in the case we are not using
|
52 |
# a recent enough version of cmsBuild/install.sh, which does not
|
53 |
# set cmsbuildApiVersion.
|
54 |
%if "%{?cmsbuildApiVersion:set}" != "set"
|
55 |
%define cmsbuildApiVersion 0
|
56 |
%endif
|
57 |
|
58 |
%define pkgdir %{pkgcategory}/%{n}/%{v}
|
59 |
|
60 |
# Architecture comes first by default. Run with "--define 'archfirst no'"
|
61 |
# to change this.
|
62 |
%if "%{?archfirst:set}" != "set"
|
63 |
%define archfirst yes
|
64 |
%endif
|
65 |
|
66 |
%if "%archfirst" == "yes"
|
67 |
%define pkgrel %{cmsplatf}/%{pkgdir}
|
68 |
%else
|
69 |
%define pkgrel %{pkgdir}/%{cmsplatf}
|
70 |
%endif
|
71 |
|
72 |
%define pkginstroot %{instroot}/%{pkgrel}
|
73 |
|
74 |
#define _rpmdbdir %{cmsroot}/RPMDB
|
75 |
%define _sourcedir %{cmsroot}/SOURCES/%{pkgdir}
|
76 |
%define _builddir %{cmsroot}/BUILD/%{cmsplatf}/%{pkgdir}
|
77 |
%define _specdir %{cmsroot}/SPECS/%{pkgdir}
|
78 |
# The new cmsBuild script puts packages in a directory structure that
|
79 |
# includes the package checksum. This way it is possible to decide
|
80 |
# what spec was used to build a given package.
|
81 |
%if "%cmsbuildApiVersion" == "0"
|
82 |
%define _rpmdir %{cmsroot}/RPMS
|
83 |
%define _srcrpmdir %{cmsroot}/SRPMS
|
84 |
%else
|
85 |
%define _rpmdir %{cmsroot}/RPMS/cache/%{specchecksum}
|
86 |
%define _srcrpmdir %{cmsroot}/SRPMS/cache/%{specchecksum}
|
87 |
%endif
|
88 |
%define _tmppath %{cmsroot}/%{tempprefix}
|
89 |
%define _topdir %{cmsroot}
|
90 |
|
91 |
%define _rpmfilename %{cmsplatf}/%%{name}-%%{version}-%%{release}.%{cmsplatf}.rpm
|
92 |
%define _srpmfilename %%{name}-%%{version}-%%{release}.src.rpm
|
93 |
|
94 |
|
95 |
|
96 |
# Force use of system gcc on darwin. Set/unset as necessary -- but
|
97 |
# then make sure the right compiler gets picked up in the environment
|
98 |
# by setting $PATH and $LD_LIBRARY_PATH correctly.
|
99 |
%ifos darwin
|
100 |
%define is_darwin true
|
101 |
%endif
|
102 |
|
103 |
%if "%{?is_darwin:set}-%gccver" == "set-4.2.1"
|
104 |
%define use_system_gcc true
|
105 |
%endif
|
106 |
|
107 |
# Old version of install.sh/cmsBuild.sh did not set the cmscompiler variable,
|
108 |
# while cmsBuild does, in order to support compilers different other than
|
109 |
# gcc. For this reason we add a check to avoid setting cmscompiler in
|
110 |
# the case we are using the new cmsBuild script.
|
111 |
%if "%{?cmscompiler:set}" != "set"
|
112 |
%define cmscompiler gcc
|
113 |
%endif
|
114 |
|
115 |
#set cmscompilerv only if not already set by cmsBuild
|
116 |
%if "%{?cmscompilerv:set}" != "set"
|
117 |
# Guess compiler version. "gccver" is defined by install.sh when
|
118 |
# producing the spec file from the version of the gcc spec.
|
119 |
%if "%cmscompiler" == "gcc"
|
120 |
%if "%{?use_system_gcc:set}" == "set"
|
121 |
%{expand:%%define cmscompilerv %(gcc --version | head -1 | cut -d' ' -f3 | cut -d. -f1,2,3 | tr -d .)}
|
122 |
%else
|
123 |
%{expand:%%define cmscompilerv %(echo %gccver | cut -d. -f1,2,3 | tr -d .)}
|
124 |
%endif
|
125 |
%endif
|
126 |
|
127 |
%if "%cmscompiler" != "gcc"
|
128 |
%{expand:%%define cmscompilerv %(echo %compilerRealVersion | cut -d. -f1,2 | tr -d .)}
|
129 |
%endif
|
130 |
%endif
|
131 |
|
132 |
# Define compiler platform version strings. We use an external
|
133 |
# script to determine platform name as RPM doesn't support multi-
|
134 |
# line macros in spec files, only in "rpmmacros" files.
|
135 |
%define debugsuffix %{?debug_build:_dbg}
|
136 |
%define cmscomp %{cmscompiler}%{cmscompilerv}
|
137 |
|
138 |
#set cmsos only if cmsBuild does not set it
|
139 |
%if "%{?cmsos:set}" != "set"
|
140 |
# Old versions of cmsBuild/install.sh used to keep cmsos script in
|
141 |
# _specdir rather than in _sourcedir. This makes sure that
|
142 |
# rpm-preamble works for boths.
|
143 |
%if "%{cmsbuildApiVersion}" == "0"
|
144 |
%{expand:%%define cmsos %(sh %_specdir/cmsos)}
|
145 |
%else
|
146 |
%{expand:%%define cmsos %(sh %_sourcedir/cmsos)}
|
147 |
%endif
|
148 |
%endif
|
149 |
|
150 |
%define cmsplatf %{cmsos}_%{cmscomp}%{debugsuffix}
|
151 |
|
152 |
# Define the variable name for dynamic linker search path.
|
153 |
%ifos darwin
|
154 |
%define dynamic_path_var DYLD_FALLBACK_LIBRARY_PATH
|
155 |
%else
|
156 |
%define dynamic_path_var LD_LIBRARY_PATH
|
157 |
%endif
|
158 |
|
159 |
# We are now done with locations. Move to other things.
|
160 |
|
161 |
# Disable for Fedora
|
162 |
%define __check_files %{nil}
|
163 |
%define debug_package %{nil}
|
164 |
|
165 |
# define ARCH %{cmsplatf}?
|
166 |
# No BuildRoot
|
167 |
# No %buildsubdir
|
168 |
# No Distribution:
|
169 |
# No DistURL:
|
170 |
# No %_excludedocs
|
171 |
# No Packager:
|
172 |
# No Provides:
|
173 |
# FIXME need %make -> gmake/make as appropriate?
|
174 |
|
175 |
# This little magic incantation figures out "Requires" from this
|
176 |
# spec itself. This allows us to handle (see below) those and
|
177 |
# only those packages the build on this platform actually needs.
|
178 |
# We protect against recursive expansion of "pkgreqs", otherwise
|
179 |
# this is pretty obvious -- it works because of strict control
|
180 |
# over directories so we always know where our spec file is.
|
181 |
|
182 |
%if "%{?use_ccache:set}" == "set"
|
183 |
%define ccache_define --define "use_ccache true"
|
184 |
%else
|
185 |
%define ccache_define %{nil}
|
186 |
%endif
|
187 |
|
188 |
%if "%{?use_distcc:set}" == "set"
|
189 |
%define distcc_define --define "use_distcc true"
|
190 |
%else
|
191 |
%define distcc_define %{nil}
|
192 |
%endif
|
193 |
|
194 |
# Define a little helper scriptlet to source package inits from other
|
195 |
# packages. This allows cross-package environment setup to work while
|
196 |
# building. See above how we determine the list by parsing the spec
|
197 |
# itself.
|
198 |
%if "%archfirst" == "yes"
|
199 |
%define initenv_all for x in %{allpkgreqs} .; do i=%{cmsroot}/%{cmsplatf}/$x/etc/profile.d/init.sh; [ -f $i ] && . $i; done
|
200 |
%define initenv_direct for x in %{directpkgreqs} %{builddirectpkgreqs} .; do i=%{cmsroot}/%{cmsplatf}/$x/etc/profile.d/init.sh; [ -f $i ] && . $i; done
|
201 |
%else
|
202 |
%define initenv_all for x in %{allpkgreqs} .; do i=%{cmsroot}/$x/%{cmsplatf}/etc/profile.d/init.sh; [ -f $i ] && . $i; done
|
203 |
%define initenv_direct for x in %{directpkgreqs} %{builddirectpkgreqs} .; do i=%{cmsroot}/$x/%{cmsplatf}/etc/profile.d/init.sh; [ -f $i ] && . $i; done
|
204 |
%endif
|
205 |
%define initenv %initenv_all
|
206 |
|
207 |
%if "%{?compiling_processes:set}" == "set"
|
208 |
%define makeprocesses -j %compiling_processes
|
209 |
%else
|
210 |
%define makeprocesses %{nil}
|
211 |
%endif
|
212 |
|
213 |
%if "%{?ignore_compile_errors:set}" == "set"
|
214 |
%define compileOptions -k
|
215 |
%else
|
216 |
%define compileOptions %{nil}
|
217 |
%endif
|
218 |
|
219 |
# Define a macro for relocating configuration files in %%post section.
|
220 |
%define relocateCmsFiles perl -p -i -e "s|\\Q%{instroot}\\E|$CMS_INSTALL_PREFIX|g;s|\\Q%{cmsroot}\\E|$CMS_INSTALL_PREFIX|g"
|
221 |
%define relocateRpmFiles perl -p -i -e "s|\\Q%{instroot}\\E|$RPM_INSTALL_PREFIX|g;s|\\Q%{cmsroot}\\E|$RPM_INSTALL_PREFIX|g"
|
222 |
%define reRelocateRpmFiles perl -p -i -e "s|\\Q$CMS_INSTALL_PREFIX\\E|$RPM_INSTALL_PREFIX|g"
|
223 |
%define reRelocateRpmPkg perl -p -i -e "s|\\Q$CMS_INSTALL_PREFIX\\E|$RPM_INSTALL_PREFIX|g" $RPM_INSTALL_PREFIX/%{pkgrel}/
|
224 |
%define relocateRpmPkg perl -p -i -e "s|\\Q%{instroot}\\E|$RPM_INSTALL_PREFIX|g;s|\\Q%{cmsroot}\\E|$RPM_INSTALL_PREFIX|g" $RPM_INSTALL_PREFIX/%{pkgrel}/
|
225 |
%define relocateCmsPkg perl -p -i -e "s|\\Q%{instroot}\\E|$CMS_INSTALL_PREFIX|g;s|\\Q%{cmsroot}\\E|$CMS_INSTALL_PREFIX|g" $RPM_INSTALL_PREFIX/%{pkgrel}/
|
226 |
%define relocateConfig %relocateCmsPkg
|
227 |
|
228 |
# On macosx one needs to use the -x option, to avoid excessive stripping.
|
229 |
%ifos darwin
|
230 |
%define strip strip -x
|
231 |
%else
|
232 |
%define strip strip
|
233 |
%endif
|