ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CMSDIST/cms-common.spec
Revision: 1.1
Committed: Tue Jan 1 11:03:59 2008 UTC (17 years, 4 months ago) by muzaffar
Branch: MAIN
CVS Tags: pe20080123a-ports-412, pe20080123a-ports, pe20080120a-ports-412, pe20080120a-ports, pe20080119a-ports-412, pe20080119a-ports, pe20080118g-ports-412, pe20080118g-ports, pe20080118f-ports-412, pe20080118f-ports, nr_pe20080118e-ports-onl, pe20080118e-ports-412, pe20080118e-ports, pe20080118d-ports-412, pe20080118d-ports, pe20080118c-ports, pe20080118b-ports, pe20080118a-ports, pe20080111b-ports, pe20080111a-ports, pe20080110b-ports, pe20080110a-ports, pe20080109a-ports, sm20080101a-newscram
Log Message:
added cms-common

File Contents

# User Rev Content
1 muzaffar 1.1 ### RPM cms cms-common 1.0
2     Source: cmsos
3     %prep
4     %build
5     echo $SCRAM_ROOT
6     %install
7    
8     mkdir -p %instroot/common %instroot/bin %{instroot}/%{cmsplatf}/etc/profile.d
9    
10     # Do not create these common files if already exist
11     # This is to avoid different arch creating these files
12     if [ ! -f %instroot/common/.cms-common ]; then
13     install -m 755 %_sourcedir/cmsos %instroot/common/cmsos
14     ### Detects the SCRAM_ARCH to be used.
15     cat << \EOF_CMSARCH_SH >%instroot/common/cmsarch
16     #!/bin/sh
17     osarch=`%instroot/common/cmsos`
18     compilerv=gcc323
19     # We need to assume 1 compiler per platform.
20     # There is no other way around this.
21     if [ ! "$SCRAM_ARCH" ]
22     then
23     case $osarch in
24     slc3_ia32) compilerv=gcc323;;
25     slc3_amd64) compilerv=gcc344;;
26     slc4_ia32) compilerv=gcc345;;
27     slc4_amd64) compilerv=gcc345; osarch=slc4_ia32;;
28     osx104_ia32) compilerv=gcc401;;
29     osx104_ppc32) compilerv=gcc400;;
30     esac
31     echo ${osarch}_${compilerv}
32     else
33     echo $SCRAM_ARCH
34     fi
35    
36     EOF_CMSARCH_SH
37     chmod 755 %instroot/common/cmsarch
38    
39     ### BASH code
40    
41     cat << \EOF_CMSSET_DEFAULT_SH > %instroot/cmsset_default.sh
42     export PATH=%instroot/common:%instroot/bin:$PATH
43    
44     if [ ! $SCRAM_ARCH ]
45     then
46     SCRAM_ARCH=`%instroot/common/cmsarch`
47     export SCRAM_ARCH
48     fi
49    
50     here=%{instroot}
51    
52     if [ "$VO_CMS_SW_DIR" != "" ]
53     then
54     here=$VO_CMS_SW_DIR
55     else
56     if [ "$OSG_APP" != "" ]
57     then
58     here=$OSG_APP/cmssoft/cms
59     fi
60     fi
61    
62     if [ ! -d $here/${SCRAM_ARCH}/etc/profile.d ]
63     then
64     echo "Your shell is not able to find where cmsset_default.sh is located."
65     echo "Either you have not set VO_CMS_SW_DIR or OSG_APP correctly"
66     echo "or SCRAM_ARCH is not set to a valid architecture."
67     fi
68    
69     for pkg in `/bin/ls $here/${SCRAM_ARCH}/etc/profile.d/ | grep 'S.*[.]sh'`
70     do
71     source $here/${SCRAM_ARCH}/etc/profile.d/$pkg
72     done
73    
74     if [ ! $CMS_PATH ]
75     then
76     export CMS_PATH=$here
77     fi
78    
79     # aliases
80     alias cmsenv='eval `scram runtime -sh`'
81     alias cmsrel='scram project CMSSW'
82    
83     if [ -f $CMS_PATH/SITECONF/local/JobConfig/cmsset_local.sh ]; then
84     . $CMS_PATH/SITECONF/local/JobConfig/cmsset_local.sh
85     fi
86    
87     if [ ! $CVSROOT ]
88     then
89     CVSROOT=:kserver:cmscvs.cern.ch:/cvs_server/repositories/CMSSW
90     export CVSROOT
91     fi
92    
93     EOF_CMSSET_DEFAULT_SH
94    
95    
96     ### CSH code
97    
98     cat << \EOF_CMSSET_DEFAULT_CSH > %instroot/cmsset_default.csh
99    
100     if (${?PATH}) then
101     setenv PATH %instroot/common:%instroot/bin:$PATH
102     else
103     setenv PATH %instroot/common:%instroot/bin
104     endif
105    
106     if ( ! ${?SCRAM_ARCH}) then
107     setenv SCRAM_ARCH `sh -c %instroot/common/cmsarch`
108     endif
109    
110     set here=%instroot
111    
112     if ( ${?VO_CMS_SW_DIR} ) then
113     set here=$VO_CMS_SW_DIR
114     else
115     # OSG
116     if ( ${?OSG_APP} ) then
117     set here=$OSG_APP/cmssoft/cms
118     endif
119     # OSG
120     endif
121    
122     if ( ! -e $here/cmsset_default.csh ) then
123     echo "Please cd into the directory where cmsset_default.csh is."
124     endif
125    
126     foreach pkg ( `/bin/ls ${here}/${SCRAM_ARCH}/etc/profile.d/ | grep 'S.*[.]csh'` )
127     source ${here}/${SCRAM_ARCH}/etc/profile.d/$pkg
128     end
129     if ( ! ${?CMS_PATH} ) then
130     setenv CMS_PATH $here
131     endif
132    
133     # aliases
134     alias cmsenv 'eval `scram runtime -csh`'
135     alias cmsrel 'scram project CMSSW'
136    
137     if( -e $CMS_PATH/SITECONF/local/JobConfig/cmsset_local.csh ) then
138     source $CMS_PATH/SITECONF/local/JobConfig/cmsset_local.csh
139     endif
140    
141     if ( ! ${?CVSROOT}) then
142     setenv CVSROOT :kserver:cmscvs.cern.ch:/cvs_server/repositories/CMSSW
143     endif
144    
145     unset here
146     EOF_CMSSET_DEFAULT_CSH
147    
148     cat << \EOF_COMMON_SCRAM > %instroot/common/scram
149     #!/bin/sh
150     CMSARCH=`cmsarch`
151     srbase=
152     if [ "X$SCRAM_VERSION" = "X" ] ; then
153     sver=`cat %{instroot}/$CMSARCH/etc/default-scramv1-version`
154     dir=`/bin/pwd`
155     while [ ! -d ${dir}/.SCRAM -a "$dir" != "/" ] ; do
156     dir=`dirname $dir`
157     done
158     if [ -f ${dir}/config/scram_version ] ; then
159     ver=`cat ${dir}/config/scram_version`
160     case $ver in
161     V0_* ) srbase=lcg/SCRAM/${ver};;
162     * ) srbase=lcg/SCRAMV1/${ver};;
163     esac
164     if [ -f %{instroot}/$CMSARCH/${srbase}/etc/profile.d/init.sh ] ; then
165     sver=$ver
166     fi
167     fi
168     else
169     sver=$SCRAM_VERSION
170     fi
171     scmd=scram
172     case $sver in
173     V0_* ) srbase=lcg/SCRAM/${sver}; scmd=scramv0;;
174     V1_0* ) srbase=lcg/SCRAMV1/${sver}; scmd=scramv1;;
175     * ) srbase=lcg/SCRAMV1/${sver};;
176     esac
177     source %{instroot}/$CMSARCH/${srbase}/etc/profile.d/init.sh
178     # In the case we are on ia32 we prepend the linux32 command to the actual
179     # scram command so that, no matter where the ia32 architecture is running
180     # (i686 or x84_64) scram detects it as ia32.
181     CMSPLAT=`echo $CMSARCH | cut -d_ -f 2`
182     if [ "$CMSPLAT" = "ia32" ]
183     then
184     USE_LINUX32=linux32
185     else
186     USE_LINUX32=
187     fi
188     $USE_LINUX32 %{instroot}/$CMSARCH/${srbase}/bin/${scmd} $@
189     EOF_COMMON_SCRAM
190    
191     chmod +x %{instroot}/common/scram
192     ln -sf scram %{instroot}/common/scramv1
193     ln -sf scram %{instroot}/common/scramv0
194     touch %instroot/common/.cms-common
195     fi
196    
197     touch %instroot/%cmsplatf/etc/profile.d/dummy
198     ln -s ../common/cmsarch %instroot/bin/cmsarch
199     ln -s ../common/cmsarch %instroot/bin/cmsos
200    
201     %post
202     echo $RPM_INSTALL_PREFIX
203     perl -p -i -e "s|%{instroot}|$RPM_INSTALL_PREFIX|g" $RPM_INSTALL_PREFIX/cmsset_default.sh
204     perl -p -i -e "s|%{instroot}|$RPM_INSTALL_PREFIX|g" $RPM_INSTALL_PREFIX/cmsset_default.csh
205     perl -p -i -e "s|%{instroot}|$RPM_INSTALL_PREFIX|g" $RPM_INSTALL_PREFIX/common/cmsos
206     perl -p -i -e "s|%{instroot}|$RPM_INSTALL_PREFIX|g" $RPM_INSTALL_PREFIX/common/cmsarch
207     perl -p -i -e "s|%{instroot}|$RPM_INSTALL_PREFIX|g" $RPM_INSTALL_PREFIX/common/scram
208    
209     %files
210     %i
211     %instroot/cmsset_default.sh
212     %instroot/cmsset_default.csh
213     %instroot/common/cmsos
214     %instroot/common/cmsarch
215     %instroot/common/scram
216     %instroot/common/scramv1
217     %instroot/common/scramv0
218     %instroot/%cmsplatf/etc/profile.d
219     %exclude %instroot/%cmsplatf/etc/profile.d/*