1 |
< |
### RPM cms overview 4.6.2 |
1 |
> |
### RPM cms overview 5.2.1c |
2 |
|
|
3 |
+ |
# This is a RPM spec file for building the Overview. This is a very |
4 |
+ |
# minimal SCRAM build area with highly reduced set of dependencies. |
5 |
+ |
# Building Overview does not in fact require SCRAM at all, but this |
6 |
+ |
# arrangment makes it easier for a developer with CMSSW work area. |
7 |
+ |
# See DQM GUI spec file for more commentary on what goes on here. |
8 |
|
%define cvsserver cvs://:pserver:anonymous@cmscvs.cern.ch:2401/cvs_server/repositories/CMSSW?passwd=AA_:yZZ3e |
9 |
+ |
%define scram $SCRAMV1_ROOT/bin/scram --arch %cmsplatf |
10 |
+ |
%define cmssw CMSSW_3_6_1 |
11 |
+ |
%define vcfg V03-29-09 |
12 |
|
%define initenv export ZZPATH=$PATH ZZLD_LIBRARY_PATH=$LD_LIBRARY_PATH ZZPYTHONPATH=$PYTHONPATH; %initenv_all |
13 |
|
|
14 |
< |
Source0: %{cvsserver}&strategy=checkout&module=CMSSW/VisMonitoring/DQMServer&export=VisMonitoring/DQMServer&tag=-rR04-06-02&output=/DQMServer.tar.gz |
15 |
< |
Requires: cherrypy py2-cheetah yui py2-pysqlite py2-cx-oracle py2-pil py2-matplotlib |
16 |
< |
Provides: /usr/bin/python |
14 |
> |
Source0: %{cvsserver}&strategy=checkout&module=config&export=config&tag=-r%{vcfg}&output=/config.tar.gz |
15 |
> |
Source1: %{cvsserver}&strategy=checkout&module=CMSSW/VisMonitoring/DQMServer&export=VisMonitoring/DQMServer&tag=-rR05-01-08&output=/DQMServer.tar.gz |
16 |
> |
Requires: cherrypy py2-cheetah yui py2-cx-oracle py2-pil py2-matplotlib overview-conf SCRAMV1 |
17 |
|
|
18 |
+ |
# Set up minimal SCRAM project build area with our sources. |
19 |
|
%prep |
20 |
< |
%setup -c -T -n src -a 0 |
21 |
< |
tar -jcvf ../distsrc.tar.bz2 . |
22 |
< |
|
20 |
> |
export SCRAM_ARCH=%cmsplatf |
21 |
> |
rm -fr %_builddir/{config,src,THE_BUILD} |
22 |
> |
%setup -T -b 0 -n config |
23 |
> |
%setup -c -T -a 1 -n src |
24 |
> |
|
25 |
> |
cd %_builddir |
26 |
> |
rm -fr src/Vis*/*/{src,bin,interface,plugins,test} |
27 |
> |
tar -jcvf distsrc.tar.bz2 -C src . |
28 |
> |
|
29 |
> |
config/updateConfig.pl -p CMSSW -v THE_BUILD -s $SCRAMV1_VERSION -t ${OVERVIEW_CONF_ROOT} |
30 |
> |
%scram project -d $PWD -b config/bootsrc.xml </dev/null |
31 |
> |
|
32 |
> |
# Build the code as a scram project area, then relocate it to more |
33 |
> |
# normal directories (%i/{bin,lib,python}). Save the scram runtime |
34 |
> |
# environment plus extra externals for later use, but manipulate |
35 |
> |
# the scram environment to point to the installation directories. |
36 |
> |
# Avoid generating excess environment. |
37 |
|
%build |
38 |
< |
for f in */*/scripts/visDQM*; do |
39 |
< |
mv $f $(echo $f | sed s/visDQM/ov/g) |
40 |
< |
done |
41 |
< |
|
42 |
< |
%install |
43 |
< |
# Relocate code to normal %i/{lib,bin,python} directories. Save the |
44 |
< |
# runtime environment needed for later use, but avoid excess values. |
45 |
< |
mkdir -p %i/etc/profile.d %i/{x,}bin %i/{x,}lib %i/{x,}python %i/data |
46 |
< |
cp -p %_builddir/distsrc.tar.bz2 %i/data |
47 |
< |
export PYTHONPATH=%i/python${PYTHONPATH+":$PYTHONPATH"}; |
48 |
< |
|
49 |
< |
cd %_builddir/src |
50 |
< |
for d in */*; do |
51 |
< |
if [ -d $d/python ]; then |
52 |
< |
cp -p $d/python/*.{py,js,css,gif,png,tmpl} %i/python |
53 |
< |
rm -f %i/python/GuiDQM.py |
31 |
< |
fi |
32 |
< |
|
33 |
< |
for f in $d/scripts/*; do |
34 |
< |
if [ -f $f ]; then cp -p $f %i/bin; fi |
35 |
< |
done |
36 |
< |
done |
37 |
< |
|
38 |
< |
for mod in %i/python/*.py; do |
39 |
< |
python -c "import $(basename $mod | sed 's/\.py$//')" |
40 |
< |
done |
41 |
< |
|
42 |
< |
# Now generate server start-up environment. Eliminate non-existent and |
43 |
< |
# duplicate path components and convert back to format that only adds to |
44 |
< |
# user's one, not one that uses RPM-builder's environment. Finally munge |
45 |
< |
# in patch directories. |
38 |
> |
export SCRAM_ARCH=%cmsplatf |
39 |
> |
cd %_builddir/THE_BUILD/src |
40 |
> |
export BUILD_LOG=yes |
41 |
> |
export SCRAM_NOPLUGINREFRESH=yes |
42 |
> |
export SCRAM_NOLOADCHECK=true |
43 |
> |
export SCRAM_NOSYMCHECK=true |
44 |
> |
(%scram build -v -f %makeprocesses </dev/null) || { %scram build outputlog </dev/null && false; } |
45 |
> |
|
46 |
> |
# Now clean up environment. First eliminate non-existent directories |
47 |
> |
# from the paths. Then capture the SCRAM run-time environment, and |
48 |
> |
# eliminate duplicate path components (from cmsbuild vs. scram), and |
49 |
> |
# convert it back to a format that is additive to the user environment |
50 |
> |
# (you want the init script to modify your $PATH, not to change it to |
51 |
> |
# mine, right!?). Finally munge SCRAM directories to finall install |
52 |
> |
# area directories. |
53 |
> |
mkdir -p %i/etc/profile.d |
54 |
|
for p in PATH LD_LIBRARY_PATH PYTHONPATH; do |
55 |
|
for z in "" ZZ; do |
56 |
|
eval export $z$p=$(perl -e 'print join(":", grep($_ && -d $_ && scalar(@{[<$_/*>]}) > 0, split(/:/,$ENV{'$z$p'})))') |
57 |
|
done |
58 |
|
done |
59 |
< |
perl -w -i -e \ |
60 |
< |
'open(SH, "> %i/etc/profile.d/env.sh") || die; |
61 |
< |
open(CSH, "> %i/etc/profile.d/env.csh") || die; |
62 |
< |
$ENV{PATH} = "%i/xbin:%i/bin:$ENV{PATH}"; |
63 |
< |
$ENV{LD_LIBRARY_PATH} = "%i/xlib:%i/lib:$ENV{LD_LIBRARY_PATH}"; |
64 |
< |
$ENV{PYTHONPATH} = "%i/xpython:%i/python:$ENV{PYTHONPATH}"; |
59 |
> |
removeenv='LOCALRT|CMSSW_(RELEASE_)*(BASE|VERSION|(FWLITE|SEARCH)_[A-Z_]*)|(COIN|IGUANA|SEAL)_[A-Z_]*' |
60 |
> |
scram runtime -sh | grep -v SCRAMRT | egrep -v "^export ($removeenv)=" > %i/etc/profile.d/env.sh |
61 |
> |
scram runtime -csh | grep -v SCRAMRT | egrep -v "^setenv ($removeenv) " > %i/etc/profile.d/env.csh |
62 |
> |
perl -w -i -p -e \ |
63 |
> |
'BEGIN { |
64 |
> |
%%linked = map { s|/+[^/]+$||; ($_ => 1) } |
65 |
> |
grep(defined $_, map { readlink $_ } |
66 |
> |
<%_builddir/THE_BUILD/external/%cmsplatf/lib/*>); |
67 |
> |
} |
68 |
> |
foreach $dir (keys %%linked) { s<:$dir([ :;"]|$)><$1>g; } |
69 |
|
foreach $p ("PATH", "LD_LIBRARY_PATH", "PYTHONPATH") { |
70 |
< |
%%seen = (); |
59 |
< |
$ENV{"ZZ$p"} = join(":", grep($_ && -d $_ && scalar(@{[<$_/*>]}) > 0, split(/:/,$ENV{"ZZ$p"}))); |
60 |
< |
$ENV{"$p"} = join(":", grep($_ && -d $_ && scalar(@{[<$_/*>]}) > 0, split(/:/,$ENV{"$p"}))); |
61 |
< |
$ENV{$p} =~ s<([ :=])$ENV{"ZZ$p"}([ :;"]|$)><$1\${$p}$2>g if $ENV{"ZZ$p"}; |
62 |
< |
$ENV{$p} = join(":", map { ($seen{$_} ? () : do { $seen{$_} = 1; ($_) }) } split(/:/, $ENV{$p})); |
63 |
< |
print SH "export $p=$ENV{$p};\n"; |
64 |
< |
print CSH "setenv $p $ENV{$p};\n"; |
70 |
> |
s<([ :=])$ENV{"ZZ$p"}([ :;"]|$)><$1\${$p}$2>g if $ENV{"ZZ$p"}; |
71 |
|
} |
72 |
< |
print SH "export YUI_ROOT=$ENV{YUI_ROOT};\n"; |
73 |
< |
print CSH "setenv YUI_ROOT $ENV{YUI_ROOT};\n"; |
74 |
< |
close(SH); close(CSH);' |
75 |
< |
|
76 |
< |
# Script to record what sources went into this package so user can |
77 |
< |
# check them out conveniently. |
78 |
< |
sed 's/^ //' > %i/bin/ovDistSource << \END_OF_SCRIPT |
79 |
< |
#!/bin/sh |
80 |
< |
doit= shopt=-ex cvs=${CVSROOT:-":pserver:anonymous@cmscvs.cern.ch:/cvs/CMSSW"} |
81 |
< |
while [ $# -gt 0 ]; do |
82 |
< |
case $1 in |
83 |
< |
-n ) doit=echo shopt=-e; shift ;; |
84 |
< |
* ) echo "$0: unrecognised parameter: $1" 1>&2; exit 1 ;; |
85 |
< |
esac |
86 |
< |
done |
87 |
< |
set $shopt |
88 |
< |
$doit tar -jxf %i/data/distsrc.tar.bz2 |
89 |
< |
tar -jtf %i/data/distsrc.tar.bz2 '*/CVS/Root' | |
90 |
< |
xargs $doit sed -i -e "s|.*|$cvs|" |
91 |
< |
END_OF_SCRIPT |
92 |
< |
|
93 |
< |
# Script to patch the server from the local developer area. The user's |
94 |
< |
# stuff goes into xbin/xlib/xpython directories, which are in front of |
95 |
< |
# the server's own bin/lib/python directories. So anything in x* will |
96 |
< |
# be picked up in preference to the server-distributed files. |
97 |
< |
sed 's/^ //' > %i/bin/ovDistPatch << \END_OF_SCRIPT |
98 |
< |
#!/bin/sh |
99 |
< |
|
100 |
< |
if [ X"$CMSSW_BASE" = X ]; then |
101 |
< |
echo "scram runtime not set, will use one from $PWD" 1>&2 |
102 |
< |
eval `scram runtime -sh` |
103 |
< |
fi |
104 |
< |
|
105 |
< |
if [ X"$CMSSW_BASE" = X ] || [ X"$SCRAM_ARCH" = X ] || \ |
106 |
< |
[ ! -f "$CMSSW_BASE/src/VisMonitoring/DQMServer/python/GuiCore.py" ]; then |
107 |
< |
echo "error: could not locate local scram developer area, exiting" 1>&2 |
108 |
< |
exit 1; |
109 |
< |
fi |
110 |
< |
|
111 |
< |
set -e |
112 |
< |
rm -fr %i/x{lib,bin,python}/{*,.??*} |
113 |
< |
|
114 |
< |
echo "copying $CMSSW_BASE/lib/$SCRAM_ARCH into %i/xlib" |
109 |
< |
(cd $CMSSW_BASE/lib/$SCRAM_ARCH && tar -cf - .) | (cd %i/xlib && tar -xf -) |
110 |
< |
|
111 |
< |
echo "copying $CMSSW_BASE/bin/$SCRAM_ARCH into %i/xbin" |
112 |
< |
(cd $CMSSW_BASE/bin/$SCRAM_ARCH && tar -cf - .) | (cd %i/xbin && tar -xf -) |
113 |
< |
|
114 |
< |
echo "copying $CMSSW_BASE/src/VisMonitoring/DQMServer/python into %i/xpython" |
115 |
< |
(cd $CMSSW_BASE/src/VisMonitoring/DQMServer/python && tar -cf - *.*) | (cd %i/xpython && tar -xf -) |
116 |
< |
|
117 |
< |
echo "renaming utility scripts" |
118 |
< |
for f in %i/xbin/visDQM*; do |
119 |
< |
mv $f $(echo $f | sed s/visDQM/ov/g) |
120 |
< |
done |
121 |
< |
exit 0 |
122 |
< |
END_OF_SCRIPT |
123 |
< |
|
124 |
< |
# Script to unpatch the server area. Simply clears out xbin/xlib/xpython |
125 |
< |
# so the server will then pick up the files distributed with the RPM. |
126 |
< |
sed 's/^ //' > %i/bin/ovDistUnpatch << \END_OF_SCRIPT |
127 |
< |
#!/bin/sh |
128 |
< |
echo "removing local overrides from %i" |
129 |
< |
rm -fr %i/x{lib,bin,python}/{*,.??*} |
130 |
< |
exit 0 |
131 |
< |
END_OF_SCRIPT |
132 |
< |
|
133 |
< |
# CRON script to purge sessions abandoned by users. |
134 |
< |
sed 's/^ //' > %i/etc/purge-old-sessions << \END_OF_SCRIPT |
135 |
< |
#!/bin/sh |
136 |
< |
. %instroot/cmsset_default.sh |
137 |
< |
. %i/etc/profile.d/env.sh |
138 |
< |
for opt; do |
139 |
< |
[ -d "$opt/gui/www/sessions" ] || continue |
140 |
< |
ovPurgeSessions $opt/gui/www/sessions |
141 |
< |
done |
142 |
< |
END_OF_SCRIPT |
143 |
< |
|
144 |
< |
# Utility script to update CRONTAB entries to this server version. |
145 |
< |
# Accounts for changes in the server configurations. For details |
146 |
< |
# of use see DQMGuiProduction twiki page. |
147 |
< |
sed 's/^ //' > %i/etc/update-crontab << \END_OF_SCRIPT |
148 |
< |
#!/bin/sh |
149 |
< |
purge= defpurge=$(dirname %instroot) |
150 |
< |
while [ $# -gt 0 ]; do |
151 |
< |
case $1 in |
152 |
< |
--purge ) |
153 |
< |
purge="$purge $2" |
154 |
< |
shift; shift ;; |
155 |
< |
* ) |
156 |
< |
echo "$(basename $0): unrecognised option $1" 1>&2 |
157 |
< |
exit 1 ;; |
158 |
< |
esac |
159 |
< |
done |
160 |
< |
|
161 |
< |
set -x |
162 |
< |
(crontab -l | fgrep -v /overview/; |
163 |
< |
sed -e "s|#PURGE|${purge:-$defpurge}|g" <%i/etc/crontab) | |
164 |
< |
crontab - |
165 |
< |
END_OF_SCRIPT |
166 |
< |
|
167 |
< |
# CRONTAB entries for this server. This will be modified by the |
168 |
< |
# update-crontab script and merged to other crontab rules. |
169 |
< |
sed 's/^ //' > %i/etc/crontab << \END_OF_SCRIPT |
170 |
< |
5 */2 * * * %i/etc/purge-old-sessions #PURGE |
171 |
< |
END_OF_SCRIPT |
72 |
> |
s<:'"$SCRAMV1_ROOT"'/[a-z]+:><:>g; |
73 |
> |
s<:%instroot/common:><:>g; |
74 |
> |
s<%_builddir/THE_BUILD/bin/%cmsplatf><%i/bin>g; |
75 |
> |
s<%_builddir/THE_BUILD/(lib|module)/%cmsplatf><%i/lib>g; |
76 |
> |
s<%_builddir/THE_BUILD/external/%cmsplatf/lib><%i/external>g; |
77 |
> |
s<%_builddir/THE_BUILD/python><%i/python>g; |
78 |
> |
s<%_builddir/THE_BUILD><%i>g;' \ |
79 |
> |
%i/etc/profile.d/env.sh %i/etc/profile.d/env.csh |
80 |
> |
|
81 |
> |
(echo "export PATH=%i/xbin:\$PATH;" |
82 |
> |
echo "export PYTHONPATH=%i/xlib:%i/xpython:\$PYTHONPATH;" |
83 |
> |
echo "export LD_LIBRARY_PATH=%i/xlib:\$LD_LIBRARY_PATH;" |
84 |
> |
echo "export YUI_ROOT='$YUI_ROOT';" |
85 |
> |
echo "export OVERVIEW_ROOT='%i';" |
86 |
> |
echo "export OVERVIEW_CMSSW_VERSION='%{cmssw}';") >> %i/etc/profile.d/env.sh |
87 |
> |
|
88 |
> |
(echo "setenv PATH %i/xbin:\$PATH;" |
89 |
> |
echo "setenv PYTHONPATH %i/xlib:%i/xpython:\$PYTHONPATH;" |
90 |
> |
echo "setenv LD_LIBRARY_PATH %i/xlib:\$LD_LIBRARY_PATH;" |
91 |
> |
echo "setenv YUI_ROOT '$YUI_ROOT';" |
92 |
> |
echo "setenv OVERVIEW_ROOT '%i';" |
93 |
> |
echo "setenv OVERVIEW_CMSSW_VERSION '%{cmssw}';") >> %i/etc/profile.d/env.csh |
94 |
> |
|
95 |
> |
# Install the project files. Copies from SCRAM area to final install |
96 |
> |
# area. Creates scripts to patch and unpatch the server area from a |
97 |
> |
# local SCRAM developer area. Creates scripts for server management. |
98 |
> |
# Usage at https://twiki.cern.ch/twiki/bin/view/CMS/DQMTest and |
99 |
> |
# https://twiki.cern.ch/twiki//bin/view/CMS/DQMGuiProduction. |
100 |
> |
%install |
101 |
> |
export SCRAM_ARCH=%cmsplatf |
102 |
> |
mkdir -p %i/etc/profile.d %i/etc/scramconfig %i/external %i/{,x}bin %i/{,x}lib %i/{,x}python %i/data |
103 |
> |
cp -p %_builddir/distsrc.tar.bz2 %i/data |
104 |
> |
cp -p %_builddir/THE_BUILD/bin/%cmsplatf/* %i/bin |
105 |
> |
cp -p %_builddir/THE_BUILD/src/VisMonitoring/DQMServer/python/*.* %i/python |
106 |
> |
tar -C %_builddir/THE_BUILD/external/%cmsplatf/lib -cf - . | tar -C %i/external -xvvf - |
107 |
> |
cp -p %_builddir/THE_BUILD/config/toolbox/%cmsplatf/tools/selected/*.xml %i/etc/scramconfig |
108 |
> |
rm -f %i/python/GuiDQM.py |
109 |
> |
|
110 |
> |
# Rename executable scripts. |
111 |
> |
perl -p -i -e 's/DQMGUI\_ROOT/OVERVIEW_ROOT/g' %i/bin/visDQM* |
112 |
> |
for f in %i/bin/visDQM*; do |
113 |
> |
mv $f $(echo $f | sed s/visDQM/ov/g) |
114 |
> |
done |
115 |
|
|
116 |
< |
chmod a+x %i/bin/ovDist* |
117 |
< |
chmod a+x %i/etc/*-* |
116 |
> |
(set -e; eval `scram runtime -sh`; |
117 |
> |
export PYTHONPATH=%i/python${PYTHONPATH+":$PYTHONPATH"}; |
118 |
> |
for mod in %i/python/*.py; do |
119 |
> |
python -c "import $(basename $mod | sed 's/\.py$//')" |
120 |
> |
done) |
121 |
|
|
122 |
|
# Post installation rules. Relocate the various scripts. |
123 |
|
# Relocate SCRAM-generated external link "database". |
124 |
|
%post |
179 |
– |
%{relocateConfig}bin/ovDist* |
180 |
– |
%{relocateConfig}etc/*-* |
181 |
– |
%{relocateConfig}etc/crontab |
125 |
|
%{relocateConfig}etc/profile.d/env.sh |
126 |
|
%{relocateConfig}etc/profile.d/env.csh |
127 |
+ |
%{relocateConfig}etc/scramconfig/*.xml |
128 |
+ |
perl -w -e ' |
129 |
+ |
($oldroot, $newroot, @files) = @ARGV; |
130 |
+ |
foreach $f (@files) { |
131 |
+ |
next if !defined($old = readlink $f); |
132 |
+ |
($new = $old) =~ s|\Q$oldroot\E|$newroot|; |
133 |
+ |
if ($new ne $old) { unlink($f); symlink($new, $f); } |
134 |
+ |
}' %instroot $RPM_INSTALL_PREFIX $RPM_INSTALL_PREFIX/%pkgrel/external/* |