1 |
|
### RPM cms cms-env 1.0 |
2 |
|
Source: cmsos |
3 |
– |
Requires: SCRAM SCRAMV1 |
3 |
|
%prep |
4 |
|
%build |
5 |
|
echo $SCRAM_ROOT |
9 |
|
|
10 |
|
mkdir -p %instroot/bin |
11 |
|
install -m 755 %_sourcedir/cmsos %instroot/bin/cmsos |
12 |
+ |
mkdir -p %{instroot}/%{cmsplatf}/etc/profile.d |
13 |
+ |
|
14 |
+ |
### BASH code |
15 |
+ |
|
16 |
|
cat << \EOF_CMSSET_DEFAULT_SH > %instroot/cmsset_default.sh |
17 |
|
export PATH=%instroot/bin:$PATH |
18 |
|
export LD_LIBRARY_PATH=%instroot/lib:$LD_LIBRARY_PATH |
19 |
|
export DYLD_FALLBACK_LIBRARY_PATH=%instroot/lib:$DYLD_FALLBACK_LIBRARY |
20 |
< |
SCRAM_ARCH=$(cmsos); export SCRAM_ARCH |
20 |
> |
SCRAM_ARCH=$(cmsos) |
21 |
|
|
22 |
|
# We need to assume 1 compiler per platform. |
23 |
|
# There is no other way around this. |
24 |
|
case $SCRAM_ARCH in |
25 |
|
slc3_ia32) compilerv=gcc323;; |
26 |
< |
slc3_amd64) compilerv=gcc345;; |
26 |
> |
slc3_amd64) compilerv=gcc344;; |
27 |
> |
slc4_ia32) compilerv=gcc345;; |
28 |
> |
slc4_amd64) compilerv=gcc345;; |
29 |
|
osx104_ia32) compilerv=gcc400;; |
30 |
|
osx104_pcc32) compilerv=gcc400;; |
31 |
|
esac |
32 |
|
SCRAM_ARCH=${SCRAM_ARCH}_$compilerv |
33 |
|
|
34 |
< |
source %instroot/$SCRAM_ARCH/lcg/SCRAM/V0_20_0/etc/profile.d/init.sh |
35 |
< |
source %instroot/$SCRAM_ARCH/lcg/SCRAMV1/V1_0_2/etc/profile.d/init.sh |
34 |
> |
if [ $# -gt 0 ] |
35 |
> |
then |
36 |
> |
SCRAM_ARCH=$1 |
37 |
> |
fi |
38 |
> |
|
39 |
> |
export SCRAM_ARCH |
40 |
> |
|
41 |
> |
here=%{instroot} |
42 |
> |
|
43 |
> |
if [ "$VO_CMS_SW_DIR" != "" ] |
44 |
> |
then |
45 |
> |
here=$VO_CMS_SW_DIR |
46 |
> |
else |
47 |
> |
if [ "$OSG_APP" != "" ] |
48 |
> |
then |
49 |
> |
here=$OSG_APP/cmssoft/cms |
50 |
> |
fi |
51 |
> |
fi |
52 |
> |
|
53 |
> |
if [ ! -d $here/${SCRAM_ARCH}/etc/profile.d ] |
54 |
> |
then |
55 |
> |
echo "Your shell is not able to find where cmsset_default.sh is. Either cd into the directory where it is or move to zsh" |
56 |
> |
exit 1 |
57 |
> |
fi |
58 |
> |
|
59 |
> |
for pkg in `/bin/ls $here/${SCRAM_ARCH}/etc/profile.d/ | grep -e'^S.*[.]sh'` |
60 |
> |
do |
61 |
> |
source $here/${SCRAM_ARCH}/etc/profile.d/$pkg |
62 |
> |
done |
63 |
> |
export CMS_PATH=$here |
64 |
|
EOF_CMSSET_DEFAULT_SH |
65 |
|
|
66 |
+ |
|
67 |
+ |
### CSH code |
68 |
+ |
|
69 |
|
cat << \EOF_CMSSET_DEFAULT_CSH > %instroot/cmsset_default.csh |
70 |
< |
setenv PATH %instroot/bin:$PATH |
71 |
< |
setenv LD_LIBRARY_PATH %instroot/lib:$LD_LIBRARY_PATH |
72 |
< |
setenv DYLD_FALLBACK_LIBRARY_PATH %instroot/lib:$DYLD_FALLBACK_LIBRARY |
73 |
< |
setenv SCRAM_ARCH `cmsos` |
74 |
< |
sentenv compilerv gcc323 |
75 |
< |
switch ( $SCRAM_ARCH ) |
70 |
> |
|
71 |
> |
if (${?PATH}) then |
72 |
> |
setenv PATH %instroot/bin:$PATH |
73 |
> |
else |
74 |
> |
setenv PATH %instroot/bin |
75 |
> |
endif |
76 |
> |
|
77 |
> |
if (${?LD_LIBRARY_PATH}) then |
78 |
> |
setenv LD_LIBRARY_PATH %instroot/lib:$LD_LIBRARY_PATH |
79 |
> |
else |
80 |
> |
setenv LD_LIBRARY_PATH %instroot/lib |
81 |
> |
endif |
82 |
> |
|
83 |
> |
if (${?DYLD_FALLBACK_LIBRARY_PATH}) then |
84 |
> |
setenv DYLD_FALLBACK_LIBRARY_PATH %instroot/lib:$DYLD_FALLBACK_LIBRARY_PATH |
85 |
> |
else |
86 |
> |
setenv DYLD_FALLBACK_LIBRARY_PATH %instroot/lib |
87 |
> |
endif |
88 |
> |
|
89 |
> |
setenv CMSOSCOMMAND `which cmsos` |
90 |
> |
setenv SCRAM_ARCH `sh -c $CMSOSCOMMAND` |
91 |
> |
setenv compilerv gcc323 |
92 |
> |
switch ( ${SCRAM_ARCH} ) |
93 |
|
case slc3_ia32: |
94 |
|
setenv compilerv gcc323 |
95 |
|
breaksw |
96 |
|
case slc3_amd64: |
97 |
+ |
setenv compilerv gcc344 |
98 |
+ |
breaksw |
99 |
+ |
case slc4_ia32: |
100 |
+ |
setenv compilerv gcc345 |
101 |
+ |
breaksw |
102 |
+ |
case slc4_amd64: |
103 |
|
setenv compilerv gcc345 |
104 |
|
breaksw |
105 |
|
case osx104_ia32: |
110 |
|
breaksw |
111 |
|
endsw |
112 |
|
|
113 |
< |
. %instroot/$SCRAM_ARCH/lcg/SCRAM/V0_20_0/etc/profile.d/init.csh |
114 |
< |
. %instroot/$SCRAM_ARCH/lcg/SCRAMV1/V1_0_2/etc/profile.d/init.csh |
113 |
> |
setenv SCRAM_ARCH ${SCRAM_ARCH}_${compilerv} |
114 |
> |
|
115 |
> |
if ( $# > 0 ) then |
116 |
> |
setenv SCRAM_ARCH $1 |
117 |
> |
endif |
118 |
> |
|
119 |
> |
setenv here %instroot |
120 |
> |
|
121 |
> |
if ( ${?VO_CMS_SW_DIR} ) then |
122 |
> |
setenv here $VO_CMS_SW_DIR |
123 |
> |
else |
124 |
> |
# OSG |
125 |
> |
if ( ${?OSG_APP} ) then |
126 |
> |
setenv here $OSG_APP/cmssoft/cms |
127 |
> |
endif |
128 |
> |
# OSG |
129 |
> |
endif |
130 |
> |
|
131 |
> |
if ( ! -e $here/cmsset_default.csh ) then |
132 |
> |
echo "Please cd into the directory where cmsset_default.csh is." |
133 |
> |
endif |
134 |
> |
|
135 |
> |
foreach pkg ( `/bin/ls ${here}/${SCRAM_ARCH}/etc/profile.d/ | grep -e'^S.*[.]csh'` ) |
136 |
> |
source ${here}/${SCRAM_ARCH}/etc/profile.d/$pkg |
137 |
> |
end |
138 |
> |
setenv CMS_PATH $here |
139 |
|
EOF_CMSSET_DEFAULT_CSH |
140 |
|
|
141 |
+ |
%pre |
142 |
+ |
[ -f $RPM_INSTALL_PREFIX/cmsset_default.sh ] && cp $RPM_INSTALL_PREFIX/cmsset_default.sh $RPM_INSTALL_PREFIX/cmsset_default.sh.old`date +%Y%m%d` |
143 |
+ |
[ -f $RPM_INSTALL_PREFIX/cmsset_default.csh ] && cp $RPM_INSTALL_PREFIX/cmsset_default.csh $RPM_INSTALL_PREFIX/cmsset_default.csh.old`date +%Y%m%d` |
144 |
+ |
[ -d $RPM_INSTALL_PREFIX/bin ] && cp -r $RPM_INSTALL_PREFIX/bin $RPM_INSTALL_PREFIX/bin.old`date +%Y%m%d` |
145 |
|
%post |
146 |
|
echo $RPM_INSTALL_PREFIX |
147 |
|
perl -p -i -e "s|%{instroot}|$RPM_INSTALL_PREFIX|g" $RPM_INSTALL_PREFIX/cmsset_default.sh |
152 |
|
%instroot/cmsset_default.sh |
153 |
|
%instroot/cmsset_default.csh |
154 |
|
%instroot/bin/cmsos |
155 |
+ |
%instroot/%cmsplatf/etc/profile.d |
156 |
+ |
%exclude %instroot/%cmsplatf/etc/profile.d/* |