-
Notifications
You must be signed in to change notification settings - Fork 176
/
scram-project-build.file
executable file
·367 lines (305 loc) · 11.9 KB
/
scram-project-build.file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
### FILE scram-project-build
# FIXME: support building all platforms together like scram does?
# FIXME: automatic sub-packages for "doc" etc?
%define mic %(case %cmsplatf in (*_mic_*) echo true;; (*) echo false;; esac)
%define cmssw_libs biglib/%{cmsplatf} lib/%{cmsplatf}
%define islinux %(case %{cmsos} in (slc*|fc*) echo 1 ;; (*) echo 0 ;; esac)
%define isslc6 %(case %{cmsos} in (slc6_*) echo 1 ;; (*) echo 0 ;; esac)
Requires: SCRAMV1
BuildRequires: gcc
# For non-linux archs disable subpackageDebug otherwise add dwz.file build dependencies.
%if "%{?subpackageDebug:set}" == "set"
%if %islinux
BuildRequires: dwz file
%else
%undefine subpackageDebug
%endif # islinux
%endif # subpackageDebug
%if %isslc6
%if "%{?pkgname}" != "coral"
Requires: patchelf
Requires: glibc
Requires: file
%endif # coral
%endif # isslc6
%define initenv %initenv_direct
%define scramcmd $SCRAMV1_ROOT/bin/scram --arch %cmsplatf
%define srctree src
#config stuff moved to github!
%define cvsconfig config
%define configtar config.tar.gz
%define configrepo git://github.com/cms-sw/cmssw-config.git?protocol=https
%if "%{?buildtarget:set}" != "set"
%define buildtarget release-build
%endif
%if "%{?cvstag:set}" != "set"
%define cvstag %realversion
%endif
%if "%{?scram_compiler:set}" != "set"
%if "%mic" == "true"
%define scram_compiler icc
%else
%define scram_compiler gcc
%endif
%endif
%define bootstrapfile config/bootsrc.xml
%if "%{?subpackageDebug:set}" == "set"
# note: do not change the order of the -fdebug-prefix-map options, they seem to be use in reverse order
%define extraOptions USER_CXXFLAGS='-fdebug-prefix-map=%{cmsroot}=%{installroot} -fdebug-prefix-map=%{instroot}=%{installroot} -g %{?usercxxflags}'
%else
%if "%{?usercxxflags:set}" == "set"
%define extraOptions USER_CXXFLAGS='%{usercxxflags}'
%else
%define extraOptions %{nil}
%endif
%endif
%if "%{?configtag:set}" != "set"
%define configtag V05-05-07
%endif
%if "%{?cvssrc:set}" != "set"
%define cvssrc %(echo %n | sed -e "s|-patch||"| tr 'a-z' 'A-Z')
%endif
%if "%{?buildarch:set}" != "set"
%define buildarch :
%endif
%if "%{?cmsroot:set}" != "set"
%define cmsroot %instroot
%endif
%if "%{?ucprojtype:set}" != "set"
%define ucprojtype %(echo %n | sed -e "s|-patch||" | tr 'a-z' 'A-Z')
%endif
%define lcprojtype %(echo %ucprojtype | tr 'A-Z' 'a-z')
%if "%{?toolconf:set}" != "set"
%define toolconf %(echo %n | sed "s|-|_|g" | tr 'a-z' 'A-Z')_TOOL_CONF_ROOT
%endif
#define source0 %{configrepo}&obj=master/%{configtag}&module=%{cvsconfig}&export=config&output=/%configtar
%define source0 https://github.com/cms-sw/cmssw-config/archive/%{configtag}.tar.gz
Source0: %source0
Source1: %source1
# IMPORTANT: notice that the only reason
# why we specify sources like this is that
# we need the associated %%setup macro in the %%prep
# section.
# In case you need to have a generic file copied
# from CMSDIST, simply put whatever "SourceX: file" you
# need in the spec which is importing this fragment.
# DO NOT add any special hook which does not have a
# corresponding %%setup macro.
%if "%{?additionalSrc0:set}" == "set"
Source2: %{additionalSrc0}&output=/src1.tar.gz
%endif
%if "%{?additionalSrc1:set}" == "set"
Source3: %{additionalSrc1}&output=/src2.tar.gz
%endif
%prep
rm -rf config
rm -rf %{srctree}
rm -rf poison
%setup -T -b 0 -n cmssw-config-%(echo %{configtag} | sed 's/^.//')
# The following is a temporary hack until we move to 4.8.1
cd ..; mv cmssw-config-%(echo %{configtag} | sed 's/^.//') config
%setup -D -T -b 1 -n %{srctree}
%if "%{?additionalSrc0:set}" == "set"
%setup -D -T -a 2 -n %{srctree}
%endif
%if "%{?additionalSrc1:set}" == "set"
%setup -D -T -a 3 -n %{srctree}
%endif
%{?PatchReleaseAdditionalPackages:%PatchReleaseAdditionalPackages}
cd %_builddir
echo %{configtag} > %_builddir/config/config_tag
%_builddir/config/updateConfig.pl -p %{ucprojtype} -v %v -s $SCRAMV1_VERSION -t ${%{toolconf}} -a %cmsplatf --keys SCRAM_COMPILER=%{scram_compiler} \
%if "%{?gitcommit:set}" == "set"
--keys PROJECT_GIT_HASH=%{gitcommit}
%else
--keys PROJECT_GIT_HASH=%{realversion}
%endif
%{?PartialBootstrapPatch:%PartialBootstrapPatch}
%{?patchsrc:%patchsrc}
%{?patchsrc2:%patchsrc2}
%{?patchsrc3:%patchsrc3}
%{?patchsrc4:%patchsrc4}
%{?patchsrc5:%patchsrc5}
%{?patchsrc6:%patchsrc6}
%{?patchsrc7:%patchsrc7}
%{?patchsrc8:%patchsrc8}
%{?patchsrc9:%patchsrc9}
rm -rf %i
mkdir -p $(dirname %i)
%{?buildarch:%buildarch}
%scramcmd project -d $(dirname %i) -b %{bootstrapfile}
%build
# Remove cmt stuff that brings unwanted dependencies:
rm -rf `find %{i}/%{srctree} -type d -name cmt`
grep -r -l -e "^#!.*perl.*" %{i}/%{srctree} | xargs perl -p -i -e "s|^#!.*perl(.*)|#!/usr/bin/env perl\$1|"
%scramcmd arch
cd %i/%{srctree}
%if "%{?extra_tools:set}" == "set"
for t in %{extra_tools}; do %scramcmd setup $t; done
%endif
%{?buildarch:%buildarch}
export BUILD_LOG=yes
export SCRAM_NOPLUGINREFRESH=yes
# We clean everything before doing anything else.
%scramcmd b clean
if [ $(uname) = Darwin ]; then
# %scramcmd doesn't know the rpath variable on darwin...
%scramcmd b echo_null # ensure lib, bin exist
eval `%scramcmd runtime -sh`
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
fi
%if "%{?nolibchecks:set}" == "set"
export SCRAM_NOLOADCHECK=true
export SCRAM_NOSYMCHECK=true
%endif
%{?preBuildCommand:%preBuildCommand}
%scramcmd b -r echo_CXX </dev/null
%{?PatchReleasePythonSymlinks:%PatchReleasePythonSymlinks}
%if "%{?prebuildtarget:set}" == "set"
%scramcmd b --verbose -f %{prebuildtarget} </dev/null
%endif
%scramcmd b --verbose -f %{compileOptions} %{extraOptions} %{makeprocesses} %{buildtarget} </dev/null || { touch ../build-errors && %scramcmd b -f outputlog && [ "%{?ignore_compile_errors:set}" == "set" ]; }
%if "%{?additionalBuildTarget0:set}" == "set"
%scramcmd b --verbose -f %{additionalBuildTarget0} < /dev/null
%endif
%if "%{?postbuildtarget:set}" == "set"
%scramcmd b --verbose -f %{postbuildtarget} </dev/null
%endif
# Move the debug logs into the builddir, so that they do not get packaged.
LOG_WEB_DIR=%cmsroot/WEB/build-logs/%{cmsplatf}/%{v}
rm -rf ${LOG_WEB_DIR}
mkdir -p ${LOG_WEB_DIR}/logs/src
if [ -d %{i}/tmp/%{cmsplatf}/cache/log/src ]; then
pushd %{i}/tmp/%{cmsplatf}/cache/log/src
tar czf ${LOG_WEB_DIR}/logs/src/src-logs.tgz ./
popd
fi
%if "%{?saveDeps:set}" == "set"
mkdir -p %i/etc/dependencies
perl %i/config/SCRAM/findDependencies.pl -rel %i -arch %cmsplatf -scramroot $SCRAMV1_ROOT
%{?PatchReleaseDependencyInfo:%PatchReleaseDependencyInfo}
gzip -f %i/etc/dependencies/*.out
%endif
(eval `%scramcmd run -sh` ; echo $PYTHONPATH | sed -e "s/:/','/g" | awk '{print "#!/usr/bin/env python \n\ncmsswPythonPaths=['"'"'"$1"'"'"']"}' > %i/python/cmsswPaths.py) || true
eval `%scramcmd run -sh`
for cmd in edmPluginRefresh ; do
cmdpath=`which $cmd 2> /dev/null || echo ""`
if [ "X$cmdpath" != X ] ; then
for lib in %{cmssw_libs} ; do
if [ -d %i/$lib ] ; then
rm -f %i/$lib/.edmplugincache
$cmd %i/$lib || true
fi
done
fi
done
%install
# FIXME: not having it set seems to cause a bunch of
# issues on macosx, because various tools actually use it and are unable
# to autodetect. Temporary until we get proper support.
SCRAM_ARCH=%cmsplatf ; export SCRAM_ARCH
cd %i
%{?buildarch:%buildarch}
%scramcmd install -f
(SCRAM_TOOL_HOME=$SCRAMV1_ROOT/%{srctree}; export SCRAM_TOOL_HOME; rm -rf external/%cmsplatf; ./config/SCRAM/linkexternal.pl --arch %cmsplatf) || true
%{?PartialReleasePackageList:%PartialReleasePackageList}
%{?PatchReleaseSourceSymlinks:%PatchReleaseSourceSymlinks}
%if "%{?runGlimpse:set}" == "set"
%scramcmd b --verbose -f gindices </dev/null
%endif
%{?RelocatePatchReleaseSymlinks:%RelocatePatchReleaseSymlinks}
tar czf %{srctree}.tar.gz %{srctree}
rm -fR %{srctree} tmp
# Handle debug symbols. We always have a debug subpackage for debug symbols so
# no point in complicating the standard builds with this.
%if "%{?subpackageDebug:set}" == "set"
touch %i/.SCRAM/%cmsplatf/subpackage-debug
if [ "%{n}" == "coral" ]; then
ELF_DIRS="%i/%cmsplatf/lib %i/%cmsplatf/tests/bin"
DROP_SYMBOLS_DIRS=""
else
ELF_DIRS="%i/lib/%cmsplatf %i/biglib/%cmsplatf %i/bin/%cmsplatf %i/test/%cmsplatf"
DROP_SYMBOLS_DIRS="%i/objs/%cmsplatf"
fi
# optimise the debug symbols, compress them, and split them into separate file
for DIR in $ELF_DIRS $DROP_SYMBOLS_DIRS; do
pushd $DIR
mkdir -p .debug
# ELF binaries
ELF_BINS=$(file * | grep ELF | cut -d':' -f1)
if [ ! -z "$ELF_BINS" ]; then
if [ $(echo $ELF_BINS | wc -w) -gt 1 ] ; then
dwz -m .debug/common-symbols.debug -M common-symbols.debug $ELF_BINS || true
fi
echo "$ELF_BINS" | xargs -t -n1 -P%{compiling_processes} -I% sh -c 'objcopy --compress-debug-sections --only-keep-debug % .debug/%.debug; objcopy --strip-debug --add-gnu-debuglink=.debug/%.debug %'
fi
popd
done
for DIR in $DROP_SYMBOLS_DIRS; do
rm -rf $DIR/.debug
done
# split the debug symbols out of the main binaries, into separate files
rm -f %_builddir/files.debug %_builddir/files
touch %_builddir/files.debug %_builddir/files
for DIR in $ELF_DIRS; do
DIR=`echo $DIR | sed 's|^%i/|%{installroot}/%{pkgrel}/|'`
echo "%exclude $DIR/.debug" >> %_builddir/files
echo "$DIR/.debug" >> %_builddir/files.debug
done
%endif
######################################################
#Do the symlink relocation as a last step in install
for L in `find external/%cmsplatf -type l`; do
lnk=`readlink -n $L 2>&1`
case $lnk in
%{cmsroot}/%{cmsplatf}/*)
rl=`echo $L | sed -e 's|[^/]*/|../|g;' | xargs dirname`
al=`echo $lnk | sed -e "s|^%{cmsroot}/%{cmsplatf}/|../../../$rl/|"`
rm -f $L
ln -sf $al $L
;;
esac
done
find external/%cmsplatf -type l | xargs ls -l
%{?PatchReleaseSymlinkRelocate:%PatchReleaseSymlinkRelocate}
%post
export SCRAM_ARCH=%cmsplatf
cd $RPM_INSTALL_PREFIX/%pkgrel
if [ -e %{srctree}.tar.gz ] ; then
tar xzf %{srctree}.tar.gz
rm -fR %{srctree}.tar.gz
fi
scramver=`cat config/scram_version`
SCRAMV1_ROOT=$RPM_INSTALL_PREFIX/%cmsplatf/lcg/SCRAMV1/$scramver
if [ -d python ]; then %{relocateCmsFiles} $(find python -maxdepth 1 -type f); fi
(SCRAM_TOOL_HOME=$SCRAMV1_ROOT/src; export SCRAM_TOOL_HOME; ./config/SCRAM/projectAreaRename.pl %{instroot} $CMS_INSTALL_PREFIX %cmsplatf )
(SCRAM_TOOL_HOME=$SCRAMV1_ROOT/src; export SCRAM_TOOL_HOME; ./config/SCRAM/projectAreaRename.pl %{cmsroot} $CMS_INSTALL_PREFIX %cmsplatf )
%{?buildarch:%buildarch}
for lib in %{cmssw_libs} ; do
if [ -f $lib/.edmplugincache ] ; then
find $lib -name "*.edmplugin" -type f -exec touch {} \;
touch $lib/.edmplugincache
fi
done
%{?PatchReleaseFilesRelocate:%PatchReleaseFilesRelocate}
%{?PartialReleaseFilesRelocate:%PartialReleaseFilesRelocate}
[ -f $RPM_INSTALL_PREFIX/etc/scramrc/%{pkgname}.map ] || (mkdir -p $RPM_INSTALL_PREFIX/etc/scramrc && echo '%{ucprojtype}=$SCRAM_ARCH/%{pkgcategory}/%{pkgname}/%{ucprojtype}_*' > $RPM_INSTALL_PREFIX/etc/scramrc/%{pkgname}.map)
%if "%{?pkgname}" != "coral"
case %cmsplatf in
slc6_amd64_*)
FILE_PKG=$(echo "%{directpkgreqs}" | tr ' ' '\n' | grep 'external/file/')
FILE_PATH=$RPM_INSTALL_PREFIX/%cmsplatf/$FILE_PKG
PATCHELF_PKG=$(echo "%{directpkgreqs}" | tr ' ' '\n' | grep 'external/patchelf/')
PATCHELF_PATH=$RPM_INSTALL_PREFIX/%cmsplatf/$PATCHELF_PKG
CMSSW_BIN_PATH="$RPM_INSTALL_PREFIX/%pkgrel/bin/%cmsplatf $RPM_INSTALL_PREFIX/%pkgrel/test/%cmsplatf"
CMSSW_ELF_BIN=$(find $CMSSW_BIN_PATH -type f -exec $FILE_PATH/bin/file {} \; | grep ELF | cut -d':' -f1)
GLIBC_PKG=$(echo "%{directpkgreqs}" | tr ' ' '\n' | grep 'external/glibc/')
GLIBC_PATH=$CMS_INSTALL_PREFIX/%cmsplatf/$GLIBC_PKG
echo "$CMSSW_ELF_BIN" | xargs -t -n 1 -I% -P $(getconf _NPROCESSORS_ONLN) sh -c "strings % 2>&1 | grep '%{cmsplatf}/external/glibc' 2>&1 >/dev/null && $PATCHELF_PATH/bin/patchelf --set-interpreter $GLIBC_PATH/lib64/ld.so % || true"
esac
%endif # coral
%if "%{?runGlimpse:set}" == "set"
%{relocateConfig}.glimpse_full/.glimpse_filenames
%endif
%postun
rm -fR $RPM_INSTALL_PREFIX/%pkgrel