forked from cms-sw/cmsdist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscram-project-build.file
executable file
·304 lines (250 loc) · 9.99 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
### FILE scram-project-build
# FIXME: support building all platforms together like scram does?
# FIXME: automatic sub-packages for "doc" etc?
Requires: SCRAMV1
%define initenv %initenv_direct
%define scramcmd $SCRAMV1_ROOT/bin/scram --arch %cmsplatf
%define cmsrepo cvs://:pserver:[email protected]:2401/local/reps/CMSSW?passwd=AA_:yZZ3e
%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 "%{?usercxxflags:set}" == "set"
%define extraOptions USER_CXXFLAGS='"%{usercxxflags}"'
%else
%define extraOptions %{nil}
%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
# note: the single quotes are needed to protect the double quotes, otherwise scram will pass separate arguments to make
%define extraOptions USER_CXXFLAGS='"-fdebug-prefix-map=%{cmsroot}=%{installroot} -fdebug-prefix-map=%{instroot}=%{installroot} -g"'
%endif
%if "%{?configtag:set}" != "set"
%define configtag V05-01-03-01
%endif
%if "%{?useCmsTC:set}" != "set"
%if "%{?cvsrepo:set}" != "set"
%define cvsrepo %cmsrepo
%endif
%else
%define cvsrepo cmstc
%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')
%define toolconf %(echo %n | sed "s|-|_|g" | tr 'a-z' 'A-Z')_TOOL_CONF_ROOT
#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
%if "%{?source1:set}" != "set"
%if "%{cvsrepo}" != "cmstc"
%define source1 %{cvsrepo}&tag=-r%{cvstag}&module=%{cvssrc}&export=%{srctree}&output=/src.tar.gz
%else
%define source1 %{cvsrepo}://?tag=%{cvstag}&module=%{cvssrc}&export=%{srctree}&output=/src.tar.gz
%endif
%endif
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
Source4: findDependencies.pl
%prep
rm -rf config
rm -rf %{srctree}
%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
%{?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}
%{?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 "%{?runGlimpse:set}" == "set"
%scramcmd b --verbose -f gindices </dev/null
%endif
%if "%{?prebuildtarget:set}" == "set"
%scramcmd b --verbose -f %{prebuildtarget} </dev/null
%endif
%scramcmd b --verbose -f %{compileOptions} %{extraOptions} %{makeprocesses} %{buildtarget} </dev/null || { %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
pushd %{i}/tmp/%{cmsplatf}/cache/log/src
tar czf ${LOG_WEB_DIR}/logs/src/src-logs.tgz ./
popd
# split the debug symbols out of tha main binaries, into separate files
%if "%{?subpackageDebug:set}" == "set"
rm -f %_builddir/files.debug %_builddir/files
touch %_builddir/files.debug %_builddir/files
echo "%exclude %{installroot}/%{pkgrel}/debug.tar.gz" >> %_builddir/files
BINDIR=$(%scramcmd tool info Self | grep "^PATH\|LD_LIBRARY_PATH=" | cut -d= -f2 | tr ":" "\n" | grep -v external)
for DIR in $BINDIR; do
mkdir -p $DIR/.debug
# FIXME - work around the 2GB limit in RPM 4.4.2
#echo "%dir $DIR/.debug" >> %_builddir/files.debug
DIR=`echo $DIR | sed 's|^%i/||'`
echo "%exclude %{installroot}/%{pkgrel}/$DIR/.debug" >> %_builddir/files
echo "$DIR/.debug" >> %_builddir/files.debug
done
for FILE in $(find $BINDIR -type f | xargs file | grep "ELF" | cut -d: -f1); do
NAME=$(basename $FILE)
DIR=$(dirname $FILE)
DEBUG="$DIR/.debug/$NAME.debug"
eu-strip "$FILE" -f "$DEBUG"
# FIXME - work around the 2GB limit in RPM 4.4.2
#echo "$DEBUG" >> %_builddir/files.debug
#echo "%exclude $DEBUG" >> %_builddir/files
echo "$DEBUG" | sed 's#%{pkginstroot}/##' >> %_builddir/files.debug
done
%endif
%if "%{?saveDeps:set}" == "set"
mkdir -p %i/etc/dependencies
perl %{_sourcedir}/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
rm -f %i/lib/%cmsplatf/.edmplugincache
eval `%scramcmd run -sh`
for cmd in edmPluginRefresh ; do
cmdpath=`which $cmd 2> /dev/null || echo ""`
if [ "X$cmdpath" != X ] ; then
$cmd || true
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}
%{?PatchReleaseGlimpse:%PatchReleaseGlimpse}
tar czf %{srctree}.tar.gz %{srctree}
rm -fR %{srctree} tmp
# FIXME - work around the 2GB limit in RPM 4.4.2
%if "%{?subpackageDebug:set}" == "set"
tar czf debug.tar.gz --files-from %_builddir/files.debug --no-recursion --remove-files
%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}
if [ -f lib/${SCRAM_ARCH}/.edmplugincache ] ; then
find lib/${SCRAM_ARCH} -name "*.edmplugin" -type f -exec touch {} \;
touch lib/${SCRAM_ARCH}/.edmplugincache
fi
%{?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)
%postun
rm -fR $RPM_INSTALL_PREFIX/%pkgrel