ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CMSDIST/cms-env.spec
Revision: 1.49
Committed: Wed Nov 7 19:55:33 2007 UTC (17 years, 5 months ago) by ratnik
Branch: MAIN
CVS Tags: CMSSW_1_7_0_pre10_ONLINE
Changes since 1.48: +15 -4 lines
Log Message:
Fixes in preinstall script:
 - no longer relies on top level bin directory being created manually
or by other rpm (apt)
 - uses safer logic when creating backups

File Contents

# User Rev Content
1 dlange 1.44 ### RPM cms cms-env 1.0
2 eulisse 1.1 Source: cmsos
3     %prep
4     %build
5     echo $SCRAM_ROOT
6     %install
7     %define scramroot %(echo $SCRAM_ROOT)
8     %define scramv1root %(echo $SCRAMV1_ROOT)
9    
10     mkdir -p %instroot/bin
11     install -m 755 %_sourcedir/cmsos %instroot/bin/cmsos
12 eulisse 1.5 mkdir -p %{instroot}/%{cmsplatf}/etc/profile.d
13    
14 eulisse 1.28 ### Detects the SCRAM_ARCH to be used.
15     cat << \EOF_CMSARCH_SH >%instroot/bin/cmsarch
16     #!/bin/sh
17     osarch=`%instroot/bin/cmsos`
18     compilerv=gcc323
19     # We need to assume 1 compiler per platform.
20     # There is no other way around this.
21 eulisse 1.31 if [ ! "$SCRAM_ARCH" ]
22 eulisse 1.29 then
23     case $osarch in
24     slc3_ia32) compilerv=gcc323;;
25     slc3_amd64) compilerv=gcc344;;
26     slc4_ia32) compilerv=gcc345;;
27 elmer 1.46 slc4_amd64) compilerv=gcc345; osarch=slc4_ia32;;
28 eulisse 1.33 osx104_ia32) compilerv=gcc401;;
29 elmer 1.40 osx104_ppc32) compilerv=gcc400;;
30 eulisse 1.29 esac
31     echo ${osarch}_${compilerv}
32     else
33     echo $SCRAM_ARCH
34     fi
35    
36 eulisse 1.28 EOF_CMSARCH_SH
37     chmod 755 %instroot/bin/cmsarch
38    
39 eulisse 1.9 ### BASH code
40    
41 eulisse 1.1 cat << \EOF_CMSSET_DEFAULT_SH > %instroot/cmsset_default.sh
42     export PATH=%instroot/bin:$PATH
43 eulisse 1.2
44 eulisse 1.22 if [ ! $SCRAM_ARCH ]
45 eulisse 1.19 then
46 eulisse 1.28 SCRAM_ARCH=`%instroot/bin/cmsarch`
47 eulisse 1.19 export SCRAM_ARCH
48 eulisse 1.15 fi
49    
50 eulisse 1.16 here=%{instroot}
51    
52 eulisse 1.10 if [ "$VO_CMS_SW_DIR" != "" ]
53     then
54 eulisse 1.9 here=$VO_CMS_SW_DIR
55     else
56 eulisse 1.12 if [ "$OSG_APP" != "" ]
57     then
58     here=$OSG_APP/cmssoft/cms
59     fi
60 eulisse 1.10 fi
61 eulisse 1.9
62 eulisse 1.14 if [ ! -d $here/${SCRAM_ARCH}/etc/profile.d ]
63 eulisse 1.13 then
64 elmer 1.38 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 eulisse 1.13 fi
68 eulisse 1.9
69 eulisse 1.27 for pkg in `/bin/ls $here/${SCRAM_ARCH}/etc/profile.d/ | grep 'S.*[.]sh'`
70 eulisse 1.5 do
71     source $here/${SCRAM_ARCH}/etc/profile.d/$pkg
72     done
73 eulisse 1.21
74 eulisse 1.22 if [ ! $CMS_PATH ]
75 eulisse 1.21 then
76     export CMS_PATH=$here
77     fi
78 metson 1.32
79 elmer 1.46 # aliases
80 elmer 1.48 alias cmsenv='eval `scramv1 runtime -sh`'
81 elmer 1.47 alias cmsrel='scramv1 project CMSSW'
82 elmer 1.46
83 metson 1.32 if [ -f $CMS_PATH/SITECONF/local/JobConfig/cmsset_local.sh ]; then
84     . $CMS_PATH/SITECONF/local/JobConfig/cmsset_local.sh
85     fi
86 eulisse 1.1 EOF_CMSSET_DEFAULT_SH
87    
88 eulisse 1.9
89     ### CSH code
90    
91 eulisse 1.1 cat << \EOF_CMSSET_DEFAULT_CSH > %instroot/cmsset_default.csh
92 eulisse 1.7
93 eulisse 1.4 if (${?PATH}) then
94     setenv PATH %instroot/bin:$PATH
95     else
96     setenv PATH %instroot/bin
97     endif
98    
99 eulisse 1.19 if ( ! ${?SCRAM_ARCH}) then
100 eulisse 1.28 setenv SCRAM_ARCH `sh -c %instroot/bin/cmsarch`
101 eulisse 1.25 endif
102 eulisse 1.15
103 eulisse 1.22 set here=%instroot
104 eulisse 1.16
105 eulisse 1.7 if ( ${?VO_CMS_SW_DIR} ) then
106 eulisse 1.23 set here=$VO_CMS_SW_DIR
107 eulisse 1.7 else
108 eulisse 1.12 # OSG
109     if ( ${?OSG_APP} ) then
110 eulisse 1.23 set here=$OSG_APP/cmssoft/cms
111 eulisse 1.12 endif
112     # OSG
113 eulisse 1.7 endif
114    
115     if ( ! -e $here/cmsset_default.csh ) then
116     echo "Please cd into the directory where cmsset_default.csh is."
117     endif
118 eulisse 1.5
119 eulisse 1.27 foreach pkg ( `/bin/ls ${here}/${SCRAM_ARCH}/etc/profile.d/ | grep 'S.*[.]csh'` )
120 eulisse 1.5 source ${here}/${SCRAM_ARCH}/etc/profile.d/$pkg
121     end
122 eulisse 1.21 if ( ! ${?CMS_PATH} ) then
123     setenv CMS_PATH $here
124     endif
125 metson 1.32
126 elmer 1.46 # aliases
127 elmer 1.48 alias cmsenv 'eval `scramv1 runtime -csh`'
128 elmer 1.47 alias cmsrel 'scramv1 project CMSSW'
129 elmer 1.46
130 ratnik 1.49 if ( -e $CMS_PATH/SITECONF/local/JobConfig/cmsset_local.csh ) then
131 metson 1.32 source $CMS_PATH/SITECONF/local/JobConfig/cmsset_local.csh
132     endif
133 eulisse 1.22 unset here
134 eulisse 1.1 EOF_CMSSET_DEFAULT_CSH
135 eulisse 1.28 touch %instroot/%cmsplatf/etc/profile.d/dummy
136 eulisse 1.8 %pre
137 ratnik 1.49 if [ -f $RPM_INSTALL_PREFIX/cmsset_default.sh ]
138     then
139     cp $RPM_INSTALL_PREFIX/cmsset_default.sh $RPM_INSTALL_PREFIX/cmsset_default.sh.old`date +%Y%m%d`
140     fi
141     if [ -f $RPM_INSTALL_PREFIX/cmsset_default.csh ]
142     then
143     cp $RPM_INSTALL_PREFIX/cmsset_default.csh $RPM_INSTALL_PREFIX/cmsset_default.csh.old`date +%Y%m%d`
144     fi
145     if [ -d $RPM_INSTALL_PREFIX/bin ]
146     then
147     cp -r $RPM_INSTALL_PREFIX/bin $RPM_INSTALL_PREFIX/bin.old`date +%Y%m%d`
148     else
149     mkdir -p $RPM_INSTALL_PREFIX/bin
150     fi
151 eulisse 1.1 %post
152     echo $RPM_INSTALL_PREFIX
153 eulisse 1.3 perl -p -i -e "s|%{instroot}|$RPM_INSTALL_PREFIX|g" $RPM_INSTALL_PREFIX/cmsset_default.sh
154     perl -p -i -e "s|%{instroot}|$RPM_INSTALL_PREFIX|g" $RPM_INSTALL_PREFIX/cmsset_default.csh
155     perl -p -i -e "s|%{instroot}|$RPM_INSTALL_PREFIX|g" $RPM_INSTALL_PREFIX/bin/cmsos
156 eulisse 1.28 perl -p -i -e "s|%{instroot}|$RPM_INSTALL_PREFIX|g" $RPM_INSTALL_PREFIX/bin/cmsarch
157 eulisse 1.3 %files
158     %i
159     %instroot/cmsset_default.sh
160     %instroot/cmsset_default.csh
161     %instroot/bin/cmsos
162 eulisse 1.28 %instroot/bin/cmsarch
163 eulisse 1.5 %instroot/%cmsplatf/etc/profile.d
164 eulisse 1.6 %exclude %instroot/%cmsplatf/etc/profile.d/*