-
Notifications
You must be signed in to change notification settings - Fork 183
/
cmsswdata.file
63 lines (55 loc) · 2.59 KB
/
cmsswdata.file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
%prep
%build
%install
mkdir -p %i/etc/scram.d
cat << \EOF_TOOLFILE >%i/etc/scram.d/cmsswdata.xml
<tool name="cmsswdata" version="%v" revision="1">
<client>
<environment name="CMSSWDATA_BASE" default="%{cmsroot}/%{cmsplatf}/%{pkgcategory}"/>
<environment name="CMSSW_DATA_PATH" default="$CMSSWDATA_BASE"/>
EOF_TOOLFILE
cat << \EOF_TOOLFILE > %i/searchpath.xml
</client>
<runtime name="CMSSW_DATA_PATH" value="$CMSSWDATA_BASE" type="path"/>
EOF_TOOLFILE
for toolbase in `echo %pkgreqs | tr ' ' '\n' | grep 'cms/data-'` ; do
toolver=`basename $toolbase`
pack=`echo $toolbase | cut -d/ -f2 | sed 's|data-||;s|-|/|'`
echo " <flags CMSSW_DATA_PACKAGE=\"$pack=$toolver\"/>" >> %i/etc/scram.d/cmsswdata.xml
echo " <runtime name=\"CMSSW_SEARCH_PATH\" default=\"%{cmsroot}/%{cmsplatf}/$toolbase\" type=\"path\"/>" >> %i/searchpath.xml
done
cat %i/searchpath.xml >> %i/etc/scram.d/cmsswdata.xml
echo " </tool>" >> %i/etc/scram.d/cmsswdata.xml
rm -f %i/searchpath.xml
chmod a+r %i/etc/scram.d/cmsswdata.xml
%post
%{relocateConfig}etc/scram.d/*.xml
echo "%{BaseTool}_ROOT='$CMS_INSTALL_PREFIX/%{pkgrel}'" > $RPM_INSTALL_PREFIX/%{pkgrel}/etc/profile.d/init.sh
echo "set %{BaseTool}_ROOT='$CMS_INSTALL_PREFIX/%{pkgrel}'" > $RPM_INSTALL_PREFIX/%{pkgrel}/etc/profile.d/init.csh
echo "%{BaseTool}_PKGREQUIRED='%pkgreqs'" >> $RPM_INSTALL_PREFIX/%{pkgrel}/etc/profile.d/init.sh
echo "set %{BaseTool}_PKGREQUIRED='%pkgreqs'" >> $RPM_INSTALL_PREFIX/%{pkgrel}/etc/profile.d/init.csh
for DATA_PATH in %directpkgreqs; do
PKG_DIR=$(echo $DATA_PATH | cut -d/ -f2)
[ $(echo $PKG_DIR | grep '^data-' | wc -l) -eq 1 ] || continue
PKG_DIR=$(echo $PKG_DIR | sed 's|^data-||;s|-|/|')
SOURCE=$RPM_INSTALL_PREFIX/%{cmsplatf}/$DATA_PATH
%if "%{?cmsswdata_version_link:set}" == "set"
DES_PATH=$DATA_PATH
%else
DES_PATH=$(echo $DATA_PATH | cut -d/ -f1,2)/$(echo $DATA_PATH | cut -d/ -f3 | tr '-' '\n' | grep '^V[0-9][0-9]$\|^[0-9][0-9]$' | tr '\n' '-' | sed 's|-$||')
%endif
PKG_DATA=$(echo $PKG_DIR | cut -d/ -f1)
if [ ! -e $RPM_INSTALL_PREFIX/share/$DES_PATH/$PKG_DIR ] ; then
rm -rf $RPM_INSTALL_PREFIX/share/$DES_PATH
mkdir -p $RPM_INSTALL_PREFIX/share/$DES_PATH
if [ -L $SOURCE/$PKG_DATA ] ; then
ln -fs ../../../../%{cmsplatf}/$DATA_PATH/$PKG_DATA $RPM_INSTALL_PREFIX/share/$DES_PATH/$PKG_DATA
else
echo "Moving $DATA_PATH in share"
rsync -aq --no-t --size-only $SOURCE/$PKG_DATA/ $RPM_INSTALL_PREFIX/share/$DES_PATH/$PKG_DATA/
fi
fi
if [ ! -L $SOURCE/$PKG_DATA ] ; then
rm -rf $SOURCE/$PKG_DATA && ln -fs ../../../../share/$DES_PATH/$PKG_DATA $SOURCE/$PKG_DATA
fi
done