1 |
### FILE scram-project-build
|
2 |
# FIXME: support building all platforms together like scram does?
|
3 |
# FIXME: automatic sub-packages for "doc" etc?
|
4 |
|
5 |
Requires: SCRAMV1
|
6 |
|
7 |
%define initenv %initenv_direct
|
8 |
%define scramcmd $SCRAMV1_ROOT/bin/scram --arch %cmsplatf
|
9 |
%define cmsrepo cvs://:pserver:anonymous@cmscvs.cern.ch:2401/cvs_server/repositories/CMSSW?passwd=AA_:yZZ3e
|
10 |
%define srctree src
|
11 |
|
12 |
#config stuff
|
13 |
%define cvsconfig config
|
14 |
%define configtar config.tar.gz
|
15 |
%define configrepo %cmsrepo
|
16 |
%define buildtarget release-build
|
17 |
%define bootstrapfile config/bootsrc.xml
|
18 |
|
19 |
%if "%{?subpackageDebug:set}" == "set"
|
20 |
%define debugOptions USER_CXXFLAGS="-g"
|
21 |
%else
|
22 |
%define debugOptions %{nil}
|
23 |
%endif
|
24 |
|
25 |
%if "%{?configtag:set}" != "set"
|
26 |
%define configtag V04-00-09
|
27 |
%endif
|
28 |
|
29 |
%if "%{?useCmsTC:set}" != "set"
|
30 |
%if "%{?cvsrepo:set}" != "set"
|
31 |
%define cvsrepo %cmsrepo
|
32 |
%endif
|
33 |
%else
|
34 |
%define cvsrepo cmstc
|
35 |
%endif
|
36 |
|
37 |
%if "%{?cvssrc:set}" != "set"
|
38 |
%define cvssrc %(echo %n | sed -e "s|-patch||"| tr 'a-z' 'A-Z')
|
39 |
%endif
|
40 |
|
41 |
%if "%{?cvstag:set}" != "set"
|
42 |
%define cvstag %realversion
|
43 |
%endif
|
44 |
|
45 |
%if "%{?buildarch:set}" != "set"
|
46 |
%define buildarch :
|
47 |
%endif
|
48 |
|
49 |
%if "%{?cmsroot:set}" != "set"
|
50 |
%define cmsroot %instroot
|
51 |
%endif
|
52 |
|
53 |
%if "%{?ucprojtype:set}" != "set"
|
54 |
%define ucprojtype %(echo %n | sed -e "s|-patch||" | tr 'a-z' 'A-Z')
|
55 |
%endif
|
56 |
%define lcprojtype %(echo %ucprojtype | tr 'A-Z' 'a-z')
|
57 |
%define toolconf %(echo %n | sed "s|-|_|g" | tr 'a-z' 'A-Z')_TOOL_CONF_ROOT
|
58 |
|
59 |
%define source0 %{configrepo}&tag=-r%{configtag}&module=%{cvsconfig}&export=config&output=/%configtar
|
60 |
|
61 |
%if "%{?source1:set}" != "set"
|
62 |
%if "%{cvsrepo}" != "cmstc"
|
63 |
%define source1 %{cvsrepo}&tag=-r%{cvstag}&module=%{cvssrc}&export=%{srctree}&output=/src.tar.gz
|
64 |
%else
|
65 |
%define source1 %{cvsrepo}://?tag=%{cvstag}&module=%{cvssrc}&export=%{srctree}&output=/src.tar.gz
|
66 |
%endif
|
67 |
%endif
|
68 |
|
69 |
Source0: %source0
|
70 |
Source1: %source1
|
71 |
|
72 |
# IMPORTANT: notice that the only reason
|
73 |
# why we specify sources like this is that
|
74 |
# we need the associated %%setup macro in the %%prep
|
75 |
# section.
|
76 |
# In case you need to have a generic file copied
|
77 |
# from CMSDIST, simply put whatever "SourceX: file" you
|
78 |
# need in the spec which is importing this fragment.
|
79 |
# DO NOT add any special hook which does not have a
|
80 |
# corresponding %%setup macro.
|
81 |
%if "%{?additionalSrc0:set}" == "set"
|
82 |
Source2: %{additionalSrc0}&output=/src1.tar.gz
|
83 |
%endif
|
84 |
|
85 |
%if "%{?additionalSrc1:set}" == "set"
|
86 |
Source3: %{additionalSrc1}&output=/src2.tar.gz
|
87 |
%endif
|
88 |
Source4: findDependencies.pl
|
89 |
|
90 |
%prep
|
91 |
rm -rf config
|
92 |
rm -rf %{srctree}
|
93 |
|
94 |
%setup -T -b 0 -n config
|
95 |
%setup -D -T -b 1 -n %{srctree}
|
96 |
|
97 |
%if "%{?additionalSrc0:set}" == "set"
|
98 |
%setup -D -T -a 2 -n %{srctree}
|
99 |
%endif
|
100 |
|
101 |
%if "%{?additionalSrc1:set}" == "set"
|
102 |
%setup -D -T -a 3 -n %{srctree}
|
103 |
%endif
|
104 |
|
105 |
%{?PatchReleaseAdditionalPackages:%PatchReleaseAdditionalPackages}
|
106 |
|
107 |
cd %_builddir
|
108 |
%_builddir/config/updateConfig.pl -p %{ucprojtype} -v %v -s $SCRAMV1_VERSION -t ${%{toolconf}} -a %cmsplatf
|
109 |
|
110 |
%{?PartialBootstrapPatch:%PartialBootstrapPatch}
|
111 |
%{?patchsrc:%patchsrc}
|
112 |
%{?patchsrc2:%patchsrc2}
|
113 |
%{?patchsrc3:%patchsrc3}
|
114 |
%{?patchsrc4:%patchsrc4}
|
115 |
%{?patchsrc5:%patchsrc5}
|
116 |
%{?patchsrc6:%patchsrc6}
|
117 |
%{?patchsrc7:%patchsrc7}
|
118 |
%{?patchsrc8:%patchsrc8}
|
119 |
%{?patchsrc9:%patchsrc9}
|
120 |
|
121 |
rm -rf %i
|
122 |
mkdir -p $(dirname %i)
|
123 |
%{?buildarch:%buildarch}
|
124 |
%scramcmd project -d $(dirname %i) -b %{bootstrapfile}
|
125 |
|
126 |
%build
|
127 |
|
128 |
# Remove cmt stuff that brings unwanted dependencies:
|
129 |
rm -rf `find %{i}/%{srctree} -type d -name cmt`
|
130 |
grep -r -l -e "^#!.*perl.*" %{i}/%{srctree} | xargs perl -p -i -e "s|^#!.*perl(.*)|#!/usr/bin/env perl\$1|"
|
131 |
|
132 |
%scramcmd arch
|
133 |
cd %i/%{srctree}
|
134 |
%{?buildarch:%buildarch}
|
135 |
|
136 |
export BUILD_LOG=yes
|
137 |
export SCRAM_NOPLUGINREFRESH=yes
|
138 |
|
139 |
if [ $(uname) = Darwin ]; then
|
140 |
# %scramcmd doesn't know the rpath variable on darwin...
|
141 |
%scramcmd b echo_null # ensure lib, bin exist
|
142 |
eval `%scramcmd runtime -sh`
|
143 |
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
|
144 |
fi
|
145 |
|
146 |
%if "%{?nolibchecks:set}" == "set"
|
147 |
export SCRAM_NOLOADCHECK=true
|
148 |
export SCRAM_NOSYMCHECK=true
|
149 |
%endif
|
150 |
|
151 |
%{?preBuildCommand:%preBuildCommand}
|
152 |
|
153 |
%scramcmd b -r echo_CXX </dev/null
|
154 |
|
155 |
%{?PatchReleasePythonSymlinks:%PatchReleasePythonSymlinks}
|
156 |
|
157 |
%if "%{?runGlimpse:set}" == "set"
|
158 |
%scramcmd b --verbose -f gindices </dev/null
|
159 |
%endif
|
160 |
|
161 |
%if "%{?prebuildtarget:set}" == "set"
|
162 |
%scramcmd b --verbose -f %{prebuildtarget} </dev/null
|
163 |
%endif
|
164 |
|
165 |
# Notice that on make we continue and create a package even if the build
|
166 |
# failed. This is because we are still in a porting phase for the mac and we
|
167 |
# still have hundreds of errors. This behavior should be changed when the have
|
168 |
# a fully working mac release, aligned with the linux one.
|
169 |
%scramcmd b --verbose -f %{compileOptions} %{debugOptions} %{makeprocesses} %{buildtarget} </dev/null || { %scramcmd b -f outputlog && case %cmsos in osx*) true;; *) false;; esac; }
|
170 |
|
171 |
%if "%{?additionalBuildTarget0:set}" == "set"
|
172 |
%scramcmd b --verbose -f %{additionalBuildTarget0} < /dev/null
|
173 |
%endif
|
174 |
|
175 |
%if "%{?postbuildtarget:set}" == "set"
|
176 |
%scramcmd b --verbose -f %{postbuildtarget} </dev/null
|
177 |
%endif
|
178 |
|
179 |
# Move the debug logs into the builddir, so that they do not get packaged.
|
180 |
rm -rf %_builddir/logs; mv %i/tmp/%cmsplatf/cache/log %_builddir/logs
|
181 |
|
182 |
# split the debug symbols out of tha main binaries, into separate files
|
183 |
%if "%{?subpackageDebug:set}" == "set"
|
184 |
rm -f %_builddir/files.debug %_builddir/files
|
185 |
touch %_builddir/files.debug %_builddir/files
|
186 |
echo "%exclude %i/debug.tar.gz" >> %_builddir/files
|
187 |
BINDIR=$(%scramcmd tool info Self | grep "^PATH\|LD_LIBRARY_PATH=" | cut -d= -f2 | tr ":" "\n" | grep -v external)
|
188 |
for DIR in $BINDIR; do
|
189 |
mkdir -p $DIR/.debug
|
190 |
# FIXME - work around the 2GB limit in RPM 4.4.2
|
191 |
#echo "%dir $DIR/.debug" >> %_builddir/files.debug
|
192 |
echo "%exclude $DIR/.debug" >> %_builddir/files
|
193 |
echo "$DIR/.debug" | sed 's#%{pkginstroot}/##' >> %_builddir/files.debug
|
194 |
done
|
195 |
for FILE in $(find $BINDIR -type f | xargs file | grep "ELF" | cut -d: -f1); do
|
196 |
NAME=$(basename $FILE)
|
197 |
DIR=$(dirname $FILE)
|
198 |
DEBUG="$DIR/.debug/$NAME.debug"
|
199 |
eu-strip "$FILE" -f "$DEBUG"
|
200 |
# FIXME - work around the 2GB limit in RPM 4.4.2
|
201 |
#echo "$DEBUG" >> %_builddir/files.debug
|
202 |
#echo "%exclude $DEBUG" >> %_builddir/files
|
203 |
echo "$DEBUG" | sed 's#%{pkginstroot}/##' >> %_builddir/files.debug
|
204 |
done
|
205 |
%endif
|
206 |
|
207 |
%if "%{?saveDeps:set}" == "set"
|
208 |
mkdir -p %i/etc/dependencies
|
209 |
perl %{_sourcedir}/findDependencies.pl -rel %i -arch %cmsplatf -scramroot $SCRAMV1_ROOT
|
210 |
%{?PatchReleaseDependencyInfo:%PatchReleaseDependencyInfo}
|
211 |
gzip -f %i/etc/dependencies/*.out
|
212 |
%endif
|
213 |
|
214 |
(eval `%scramcmd run -sh` ; echo $PYTHONPATH | sed -e "s/:/','/g" | awk '{print "#!/usr/bin/env python \n\ncmsswPythonPaths=['"'"'"$1"'"'"']"}' > %i/python/cmsswPaths.py) || true
|
215 |
|
216 |
rm -f %i/lib/%cmsplatf/.edmplugincache
|
217 |
eval `%scramcmd run -sh`
|
218 |
for cmd in edmPluginRefresh ; do
|
219 |
cmdpath=`which $cmd 2> /dev/null || echo ""`
|
220 |
if [ "X$cmdpath" != X ] ; then
|
221 |
$cmd || true
|
222 |
fi
|
223 |
done
|
224 |
|
225 |
%install
|
226 |
# FIXME: not having it set seems to cause a bunch of
|
227 |
# issues on macosx, because various tools actually use it and are unable
|
228 |
# to autodetect. Temporary until we get proper support.
|
229 |
SCRAM_ARCH=%cmsplatf ; export SCRAM_ARCH
|
230 |
cd %i
|
231 |
%{?buildarch:%buildarch}
|
232 |
|
233 |
%scramcmd install -f
|
234 |
(SCRAM_TOOL_HOME=$SCRAMV1_ROOT/%{srctree}; export SCRAM_TOOL_HOME; rm -rf external/%cmsplatf; ./config/SCRAM/linkexternal.pl --arch %cmsplatf) || true
|
235 |
|
236 |
%{?PartialReleasePackageList:%PartialReleasePackageList}
|
237 |
%{?PatchReleaseSourceSymlinks:%PatchReleaseSourceSymlinks}
|
238 |
%{?PatchReleaseGlimpse:%PatchReleaseGlimpse}
|
239 |
|
240 |
tar czf %{srctree}.tar.gz %{srctree}
|
241 |
rm -fR %{srctree} tmp
|
242 |
|
243 |
# FIXME - work around the 2GB limit in RPM 4.4.2
|
244 |
%if "%{?subpackageDebug:set}" == "set"
|
245 |
tar czf debug.tar.gz --files-from %_builddir/files.debug --no-recursion --remove-files
|
246 |
%endif
|
247 |
|
248 |
######################################################
|
249 |
#Do the symlink relocation as a last step in %install
|
250 |
for L in `find external/%cmsplatf -type l`; do
|
251 |
lnk=`readlink -n $L 2>&1`
|
252 |
case $lnk in
|
253 |
%{cmsroot}/%{cmsplatf}/*)
|
254 |
rl=`echo $L | sed -e 's|[^/]*/|../|g;' | xargs dirname`
|
255 |
al=`echo $lnk | sed -e "s|^%{cmsroot}/%{cmsplatf}/|../../../$rl/|"`
|
256 |
rm -f $L
|
257 |
ln -sf $al $L
|
258 |
;;
|
259 |
esac
|
260 |
done
|
261 |
find external/%cmsplatf -type l | xargs ls -l
|
262 |
|
263 |
%post
|
264 |
export SCRAM_ARCH=%cmsplatf
|
265 |
cd $RPM_INSTALL_PREFIX/%pkgrel
|
266 |
if [ -e %{srctree}.tar.gz ] ; then
|
267 |
tar xzf %{srctree}.tar.gz
|
268 |
rm -fR %{srctree}.tar.gz
|
269 |
fi
|
270 |
scramver=`cat config/scram_version`
|
271 |
SCRAMV1_ROOT=$RPM_INSTALL_PREFIX/%cmsplatf/lcg/SCRAMV1/$scramver
|
272 |
if [ -d python ]; then %{relocateCmsFiles} $(find python -maxdepth 1 -type f); fi
|
273 |
(SCRAM_TOOL_HOME=$SCRAMV1_ROOT/src; export SCRAM_TOOL_HOME; ./config/SCRAM/projectAreaRename.pl %{instroot} $CMS_INSTALL_PREFIX %cmsplatf )
|
274 |
(SCRAM_TOOL_HOME=$SCRAMV1_ROOT/src; export SCRAM_TOOL_HOME; ./config/SCRAM/projectAreaRename.pl %{cmsroot} $CMS_INSTALL_PREFIX %cmsplatf )
|
275 |
%{?buildarch:%buildarch}
|
276 |
if [ -f lib/${SCRAM_ARCH}/.edmplugincache ] ; then
|
277 |
find lib/${SCRAM_ARCH} -name "*.edmplugin" -type f -exec touch {} \;
|
278 |
touch lib/${SCRAM_ARCH}/.edmplugincache
|
279 |
fi
|
280 |
%scramcmd install -f -d $CMS_INSTALL_PREFIX/%pkgrel
|
281 |
|
282 |
%{?PatchReleaseFilesRelocate:%PatchReleaseFilesRelocate}
|
283 |
%{?PartialReleaseFilesRelocate:%PartialReleaseFilesRelocate}
|
284 |
[ -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)
|
285 |
|
286 |
%postun
|
287 |
if [ -e $RPM_INSTALL_PREFIX/%pkgrel ] ; then
|
288 |
rm -fR $RPM_INSTALL_PREFIX/%pkgrel/%{srctree} $RPM_INSTALL_PREFIX/%pkgrel/.SCRAM
|
289 |
fi
|