ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CMSDIST/overview.spec
Revision: 1.2
Committed: Fri May 22 23:49:53 2009 UTC (15 years, 11 months ago) by lat
Branch: MAIN
Changes since 1.1: +7 -5 lines
Log Message:
Fixes to python module installation.

File Contents

# User Rev Content
1 lat 1.1 ### RPM cms overview 4.6.0
2    
3     %define cvsserver cvs://:pserver:anonymous@cmscvs.cern.ch:2401/cvs_server/repositories/CMSSW?passwd=AA_:yZZ3e
4     %define initenv export ZZPATH=$PATH ZZLD_LIBRARY_PATH=$LD_LIBRARY_PATH ZZPYTHONPATH=$PYTHONPATH; %initenv_all
5    
6 lat 1.2 Source0: %{cvsserver}&strategy=checkout&module=CMSSW/VisMonitoring/DQMServer&export=VisMonitoring/DQMServer&tag=-rR04-06-00&output=/DQMServer.tar.gz
7 lat 1.1 Requires: cherrypy py2-cheetah yui py2-pysqlite py2-cx-oracle py2-pil py2-matplotlib
8    
9     %prep
10     %setup -c -T -n src -a 0
11     tar -jcvf ../distsrc.tar.bz2 .
12    
13     %build
14     for f in */*/scripts/visDQM*; do
15     mv $f $(echo $f | sed s/visDQM/ov/g)
16     done
17    
18     %install
19     # Relocate code to normal %i/{lib,bin,python} directories. Save the
20     # runtime environment needed for later use, but avoid excess values.
21     mkdir -p %i/etc/profile.d %i/{x,}bin %i/{x,}lib %i/{x,}python %i/data
22     cp -p %_builddir/distsrc.tar.bz2 %i/data
23     export PYTHONPATH=%i/python${PYTHONPATH+":$PYTHONPATH"};
24    
25     cd %_builddir/src
26     for d in */*; do
27     if [ -d $d/python ]; then
28 lat 1.2 cp -p $d/python/*.{py,js,css,gif,png,tmpl} %i/python
29     rm -f %i/python/GuiDQM.py
30 lat 1.1 fi
31    
32     for f in $d/scripts/*; do
33     if [ -f $f ]; then cp -p $f %i/bin; fi
34     done
35     done
36    
37 lat 1.2 for mod in %i/python/*.py; do
38     python -c "import $(basename $mod | sed 's/\.py$//')"
39     done
40    
41 lat 1.1 # Now generate server start-up environment. Eliminate non-existent and
42     # duplicate path components and convert back to format that only adds to
43     # user's one, not one that uses RPM-builder's environment. Finally munge
44     # in patch directories.
45     for p in PATH LD_LIBRARY_PATH PYTHONPATH; do
46     for z in "" ZZ; do
47     eval export $z$p=$(perl -e 'print join(":", grep($_ && -d $_ && scalar(@{[<$_/*>]}) > 0, split(/:/,$ENV{'$z$p'})))')
48     done
49     done
50     perl -w -i -e \
51     'open(SH, "> %i/etc/profile.d/env.sh") || die;
52     open(CSH, "> %i/etc/profile.d/env.csh") || die;
53     $ENV{PATH} = "%i/xbin:%i/bin:$ENV{PATH}";
54     $ENV{LD_LIBRARY_PATH} = "%i/xlib:%i/lib:$ENV{LD_LIBRARY_PATH}";
55     $ENV{PYTHONPATH} = "%i/xpython:%i/python:$ENV{PYTHONPATH}";
56     foreach $p ("PATH", "LD_LIBRARY_PATH", "PYTHONPATH") {
57     %%seen = ();
58     $ENV{"ZZ$p"} = join(":", grep($_ && -d $_ && scalar(@{[<$_/*>]}) > 0, split(/:/,$ENV{"ZZ$p"})));
59     $ENV{"$p"} = join(":", grep($_ && -d $_ && scalar(@{[<$_/*>]}) > 0, split(/:/,$ENV{"$p"})));
60     $ENV{$p} =~ s<([ :=])$ENV{"ZZ$p"}([ :;"]|$)><$1\${$p}$2>g if $ENV{"ZZ$p"};
61     $ENV{$p} = join(":", map { ($seen{$_} ? () : do { $seen{$_} = 1; ($_) }) } split(/:/, $ENV{$p}));
62     print SH "export $p=$ENV{$p};\n";
63     print CSH "setenv $p $ENV{$p};\n";
64     }
65     print SH "export YUI_ROOT=$ENV{YUI_ROOT};\n";
66     print CSH "setenv YUI_ROOT $ENV{YUI_ROOT};\n";
67     close(SH); close(CSH);'
68    
69     # Script to record what sources went into this package so user can
70     # check them out conveniently.
71     sed 's/^ //' > %i/bin/ovDistSource << \END_OF_SCRIPT
72     #!/bin/sh
73     doit= shopt=-ex cvs=${CVSROOT:-":pserver:anonymous@cmscvs.cern.ch:/cvs/CMSSW"}
74     while [ $# -gt 0 ]; do
75     case $1 in
76     -n ) doit=echo shopt=-e; shift ;;
77     * ) echo "$0: unrecognised parameter: $1" 1>&2; exit 1 ;;
78     esac
79     done
80     set $shopt
81     $doit tar -jxf %i/data/distsrc.tar.bz2
82     tar -jtf %i/data/distsrc.tar.bz2 '*/CVS/Root' |
83     xargs $doit sed -i -e "s|.*|$cvs|"
84     END_OF_SCRIPT
85    
86     # Script to patch the server from the local developer area. The user's
87     # stuff goes into xbin/xlib/xpython directories, which are in front of
88     # the server's own bin/lib/python directories. So anything in x* will
89     # be picked up in preference to the server-distributed files.
90     sed 's/^ //' > %i/bin/ovDistPatch << \END_OF_SCRIPT
91     #!/bin/sh
92    
93     if [ X"$CMSSW_BASE" = X ]; then
94     echo "scram runtime not set, will use one from $PWD" 1>&2
95     eval `scram runtime -sh`
96     fi
97    
98     if [ X"$CMSSW_BASE" = X ] || [ X"$SCRAM_ARCH" = X ] || \
99     [ ! -f "$CMSSW_BASE/src/VisMonitoring/DQMServer/python/GuiCore.py" ]; then
100     echo "error: could not locate local scram developer area, exiting" 1>&2
101     exit 1;
102     fi
103    
104     set -e
105     rm -fr %i/x{lib,bin,python}/{*,.??*}
106    
107     echo "copying $CMSSW_BASE/lib/$SCRAM_ARCH into %i/xlib"
108     (cd $CMSSW_BASE/lib/$SCRAM_ARCH && tar -cf - .) | (cd %i/xlib && tar -xf -)
109    
110     echo "copying $CMSSW_BASE/bin/$SCRAM_ARCH into %i/xbin"
111     (cd $CMSSW_BASE/bin/$SCRAM_ARCH && tar -cf - .) | (cd %i/xbin && tar -xf -)
112    
113     echo "copying $CMSSW_BASE/src/VisMonitoring/DQMServer/python into %i/xpython"
114     (cd $CMSSW_BASE/src/VisMonitoring/DQMServer/python && tar -cf - *.*) | (cd %i/xpython && tar -xf -)
115    
116     echo "renaming utility scripts"
117     for f in %i/xbin/visDQM*; do
118     mv $f $(echo $f | sed s/visDQM/ov/g)
119     done
120     exit 0
121     END_OF_SCRIPT
122    
123     # Script to unpatch the server area. Simply clears out xbin/xlib/xpython
124     # so the server will then pick up the files distributed with the RPM.
125     sed 's/^ //' > %i/bin/ovDistUnpatch << \END_OF_SCRIPT
126     #!/bin/sh
127     echo "removing local overrides from %i"
128     rm -fr %i/x{lib,bin,python}/{*,.??*}
129     exit 0
130     END_OF_SCRIPT
131    
132     # CRON script to purge sessions abandoned by users.
133     sed 's/^ //' > %i/etc/purge-old-sessions << \END_OF_SCRIPT
134     #!/bin/sh
135     . %instroot/cmsset_default.sh
136     . %i/etc/profile.d/env.sh
137     for opt; do
138     [ -d "$opt/gui/www/sessions" ] || continue
139     ovPurgeSessions $opt/gui/www/sessions
140     done
141     END_OF_SCRIPT
142    
143     # Utility script to update CRONTAB entries to this server version.
144     # Accounts for changes in the server configurations. For details
145     # of use see DQMGuiProduction twiki page.
146     sed 's/^ //' > %i/etc/update-crontab << \END_OF_SCRIPT
147     #!/bin/sh
148     purge= defpurge=$(dirname %instroot)
149     while [ $# -gt 0 ]; do
150     case $1 in
151     --purge )
152     purge="$purge $2"
153     shift; shift ;;
154     * )
155     echo "$(basename $0): unrecognised option $1" 1>&2
156     exit 1 ;;
157     esac
158     done
159    
160     set -x
161     (crontab -l | fgrep -v /overview/;
162     sed -e "s|#PURGE|${purge:-$defpurge}|g" <%i/etc/crontab) |
163     crontab -
164     END_OF_SCRIPT
165    
166     # CRONTAB entries for this server. This will be modified by the
167     # update-crontab script and merged to other crontab rules.
168     sed 's/^ //' > %i/etc/crontab << \END_OF_SCRIPT
169     5 */2 * * * %i/etc/purge-old-sessions #PURGE
170     END_OF_SCRIPT
171    
172     chmod a+x %i/bin/ovDist*
173     chmod a+x %i/etc/*-*
174    
175     # Post installation rules. Relocate the various scripts.
176     # Relocate SCRAM-generated external link "database".
177     %post
178     %{relocateConfig}bin/ovDist*
179     %{relocateConfig}etc/*-*
180     %{relocateConfig}etc/crontab
181     %{relocateConfig}etc/profile.d/env.sh
182     %{relocateConfig}etc/profile.d/env.csh