root / tmp / org.txm.setups / shared / mac / INSTALL @ 1736
Historique | Voir | Annoter | Télécharger (3,84 ko)
1 |
#!/bin/sh |
---|---|
2 |
|
3 |
VERSION="-TXMVERSION" |
4 |
|
5 |
vercomp () { |
6 |
echo "test $1 $2" |
7 |
if [[ $1 == $2 ]] |
8 |
then |
9 |
return 0 |
10 |
fi |
11 |
local IFS=. |
12 |
local i ver1=($1) ver2=($2) |
13 |
# fill empty fields in ver1 with zeros |
14 |
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)) |
15 |
do |
16 |
ver1[i]=0 |
17 |
done |
18 |
for ((i=0; i<${#ver1[@]}; i++)) |
19 |
do |
20 |
if [[ -z ${ver2[i]} ]] |
21 |
then |
22 |
ver2[i]=0 |
23 |
fi |
24 |
if ((10#${ver1[i]} > 10#${ver2[i]})) |
25 |
then |
26 |
return 0 |
27 |
fi |
28 |
if ((10#${ver1[i]} < 10#${ver2[i]})) |
29 |
then |
30 |
return 1 |
31 |
fi |
32 |
done |
33 |
return 0 |
34 |
} |
35 |
|
36 |
# messages en and fr |
37 |
SAY_STARTINSTALL_EN="starting post installation" |
38 |
SAY_INSTALLR_EN="installing R and R dependancies" |
39 |
SAY_CREATESTAMP_EN="creating STAMP" |
40 |
SAY_SETFILERIGHTS_EN="setting file rights" |
41 |
SAY_DONE_EN="Done" |
42 |
|
43 |
SAY_STARTINSTALL_FR="Début de la post-installation de TXM" |
44 |
SAY_INSTALLR_FR="Installation de R et ses dépendances" |
45 |
SAY_CREATESTAMP_FR="Création du fichier STAMP" |
46 |
SAY_SETFILERIGHTS_FR="Réglage des droits de fichiers" |
47 |
SAY_DONE_FR="Installation terminée" |
48 |
|
49 |
if [ $LANG = "fr_FR.UTF-8" ];then |
50 |
SAY_STARTINSTALL=$SAY_STARTINSTALL_FR |
51 |
SAY_INSTALLR=$SAY_INSTALLR_FR |
52 |
SAY_CREATESTAMP=$SAY_CREATESTAMP_FR |
53 |
SAY_SETFILERIGHTS=$SAY_SETFILERIGHTS_FR |
54 |
SAY_DONE=$SAY_DONE_FR |
55 |
else |
56 |
SAY_STARTINSTALL=$SAY_STARTINSTALL_EN |
57 |
SAY_INSTALLR=$SAY_INSTALLR_EN |
58 |
SAY_CREATESTAMP=$SAY_CREATESTAMP_EN |
59 |
SAY_SETFILERIGHTS=$SAY_SETFILERIGHTS_EN |
60 |
SAY_DONE=$SAY_DONE_EN |
61 |
fi |
62 |
|
63 |
OSVERSION=`sw_vers -productVersion` |
64 |
echo "MAC OS X Version is : $OSVERSION" |
65 |
vercomp $OSVERSION "10.7" |
66 |
if [ $? != 0 ];then |
67 |
java -version |
68 |
if [ $? != 0 ];then |
69 |
echo "** TXM postinstall: failed to install: java is missing." |
70 |
exit 1 |
71 |
fi |
72 |
fi |
73 |
|
74 |
say $SAY_STARTINSTALL |
75 |
echo "** TXM postinstall: start post installation" |
76 |
TXMINSTALLDIR="/Applications/TXM${VERSION}.app" |
77 |
|
78 |
# remove "try(library(textometrieR))" from .Rprofile if any |
79 |
if [ -f "$HOME/.Rprofile" ]; then |
80 |
echo "Removing 'try(library(textometrieR))' from old .Rprofile" |
81 |
sed "s/try(library(textometrieR))//g" "$HOME/.Rprofile" > "$HOME/.Rprofile2" && |
82 |
mv -f "$HOME/.Rprofile2" "$HOME/.Rprofile" |
83 |
if [ $? != 0 ];then |
84 |
echo "** TXM postinstall: failed to fix old '.Rprofile' file." |
85 |
exit 1 |
86 |
fi |
87 |
fi |
88 |
|
89 |
say $SAY_INSTALLR |
90 |
if [ ! -d "/usr/local/lib/tcl8" ]; then |
91 |
installer -pkg "$TXMINSTALLDIR/Contents/TXM/R/tcltk-8.5.5-x11.pkg" -allowUntrusted -target / |
92 |
if [ $? != 0 ]; then |
93 |
echo "** TXM install: installation of tcltk failed. Aborting." |
94 |
exit 1 |
95 |
fi |
96 |
else |
97 |
echo "Skipping tcl8 installation" |
98 |
fi |
99 |
|
100 |
if [ ! -d "/usr/local/share/texinfo" ]; then |
101 |
installer -pkg "$TXMINSTALLDIR/Contents/TXM/R/texinfo-6.1-0.pkg" -allowUntrusted -target / |
102 |
if [ $? != 0 ]; then |
103 |
echo "** TXM install: installation of texinfo failed. Aborting." |
104 |
exit 1 |
105 |
fi |
106 |
else |
107 |
echo "Skipping 'texinfo' installation" |
108 |
fi |
109 |
|
110 |
if [ ! -d "/opt/X11/bin" ]; then |
111 |
installer -pkg "$TXMINSTALLDIR/Contents/TXM/R/XQuartz.pkg" -allowUntrusted -target / |
112 |
if [ $? != 0 ]; then |
113 |
echo "** TXM install: installation of XQuartz failed. Aborting." |
114 |
exit 1 |
115 |
fi |
116 |
else |
117 |
echo "Skipping XQuartz installation" |
118 |
fi |
119 |
|
120 |
say $SAY_CREATESTAMP |
121 |
echo "** TXM postinstall: create STAMP file" |
122 |
# Create STAMP |
123 |
touch "$TXMINSTALLDIR/STAMP" |
124 |
|
125 |
if [ $? != 0 ];then |
126 |
echo "** TXM postinstall: failed to create STAMP file." |
127 |
exit 1 |
128 |
fi |
129 |
|
130 |
say $SAY_SETFILERIGHTS |
131 |
echo "** TXM postinstall: set rights" |
132 |
# Set executable files |
133 |
chmod +x "$TXMINSTALLDIR"/Contents/TXM/plugins/CQP.macosx*/res/macosx/* |
134 |
|
135 |
chmod -R +r "$TXMINSTALLDIR" |
136 |
chmod +rx "$TXMINSTALLDIR/Contents/MacOS/TXM" |
137 |
chmod -R +rx /opt/local/lib |
138 |
|
139 |
echo "sudo chown -R $USER $TXMINSTALLDIR" |
140 |
sudo chown -R "$USER" "$TXMINSTALLDIR" |
141 |
|
142 |
if [ $? != 0 ];then |
143 |
echo "** TXM postinstall: failed to set permissions." |
144 |
exit 1 |
145 |
fi |
146 |
|
147 |
#check created directories |
148 |
if [ ! -d "/opt/local/lib" ]; then |
149 |
echo "** TXM postinstall: failed to create /opt/local/lib directory. User has not enough rights?" |
150 |
exit 1 |
151 |
fi |
152 |
|
153 |
say $SAY_DONE |
154 |
echo "** TXM postinstall: Done" |