Difference between revisions of "User:Xavivars/ApertiumInstaller"
Jump to navigation
Jump to search
m (User:Xavivars/installer moved to User:Xavivars/ApertiumInstaller) |
|||
| Line 5: | Line 5: | ||
###################################################################################### |
###################################################################################### |
||
# |
# |
||
# APERTIUM |
# APERTIUM INSTALL |
||
# |
# |
||
###################################################################################### |
###################################################################################### |
||
| Line 11: | Line 11: | ||
{ |
{ |
||
cat - << EOF |
cat - << EOF |
||
S'ha produït un error mentre s' |
S'ha produït un error mentre s'instaŀlava el paquet $1. |
||
Comproveu els errors que s'han produït i contacteu amb l'administrador del vostre sistema. |
Comproveu els errors que s'han produït i contacteu amb l'administrador del vostre sistema. |
||
| Line 88: | Line 88: | ||
### |
### |
||
# comprovem si ja està |
# comprovem si ja està instaŀlat lttoolbox, i actuem |
||
# en consecuència |
# en consecuència |
||
# |
# |
||
echo " |
echo "Instaŀlant el paquet LTTOOLBOX..." |
||
if [ ! -e $PREFIX/bin/lt-proc ]; then |
if [ ! -e $PREFIX/bin/lt-proc ]; then |
||
# no existeix lttoolbox, per tant l' |
# no existeix lttoolbox, per tant l'instaŀlem |
||
LTTOOLBOXPACK=`ls *lttoolbox*` |
LTTOOLBOXPACK=`ls -l --time-style=long-iso *lttoolbox* | head -n 1 | sed -e "s/ */ /g" | cut -f 8 -d " "` |
||
LTTOOLBOXFOLDER=`tar tvzf $LTTOOLBOXPACK | head -n 1 | sed -e "s/ */ /g" | cut -f 6 -d " "` |
LTTOOLBOXFOLDER=`tar tvzf $LTTOOLBOXPACK | head -n 1 | sed -e "s/ */ /g" | cut -f 6 -d " "` |
||
| Line 113: | Line 113: | ||
$MKINST make install >> $LOGFILE 2>&1 |
$MKINST make install >> $LOGFILE 2>&1 |
||
rm -rf * |
rm -rf * |
||
rm -rf .* |
|||
cd .. |
cd .. |
||
rmdir $LTTOOLBOXFOLDER |
rmdir $LTTOOLBOXFOLDER |
||
| Line 121: | Line 122: | ||
echo "" >> ~/.bashrc |
echo "" >> ~/.bashrc |
||
echo "LTTOOLBOX |
echo "LTTOOLBOX instaŀlat correctament" |
||
fi |
fi |
||
fi |
fi |
||
else |
else |
||
echo "LTTOOLBOX ja està |
echo "LTTOOLBOX ja està instaŀlat" |
||
fi |
fi |
||
| Line 138: | Line 139: | ||
fi |
fi |
||
### |
### |
||
# comprovem si ja està |
# comprovem si ja està instaŀlat apertium, i actuem |
||
# en consecuència |
# en consecuència |
||
# |
# |
||
echo " |
echo "Instaŀlant el paquet APERTIUM..." |
||
if [ ! -e $PREFIX/bin/apertium-transfer ]; then |
if [ ! -e $PREFIX/bin/apertium-transfer ]; then |
||
# no existeix apertium, per tant l' |
# no existeix apertium, per tant l'instaŀlem |
||
APERTIUMPACK=`ls -l *apertium* | head -n 1 | sed -e "s/ */ /g" | cut -f 8 -d " "` |
APERTIUMPACK=`ls -l --time-style=long-iso *apertium* | head -n 1 | sed -e "s/ */ /g" | cut -f 8 -d " "` |
||
APERTIUMFOLDER=`tar tvzf $APERTIUMPACK | head -n 1 | sed -e "s/ */ /g" | cut -f 6 -d " "` |
APERTIUMFOLDER=`tar tvzf $APERTIUMPACK | head -n 1 | sed -e "s/ */ /g" | cut -f 6 -d " "` |
||
| Line 162: | Line 163: | ||
make >> $LOGFILE 2>&1 |
make >> $LOGFILE 2>&1 |
||
$MKINST make install >> $LOGFILE 2>&1 |
$MKINST make install >> $LOGFILE 2>&1 |
||
rm -rf * |
rm -rf * |
||
rm -rf .* |
|||
cd .. |
cd .. |
||
rmdir $APERTIUMFOLDER |
rmdir $APERTIUMFOLDER |
||
echo "APERTIUM |
echo "APERTIUM instaŀlat correctament" |
||
fi |
fi |
||
fi |
fi |
||
else |
else |
||
echo "APERTIUM ja està |
echo "APERTIUM ja està instaŀlat" |
||
fi |
fi |
||
| Line 192: | Line 194: | ||
### |
### |
||
# comprovem si està |
# comprovem si està instaŀlat el paquet d'idioma |
||
# |
# |
||
echo " |
echo "Instaŀlant el paquet d'idioma $APERTLANG..." |
||
if [ ! -e $PREFIX/share/apertium/apertium-$APERTLANG ]; then |
if [ ! -e $PREFIX/share/apertium/apertium-$APERTLANG ]; then |
||
# no existeix lttoolbox, per tant l' |
# no existeix lttoolbox, per tant l'instaŀlem |
||
LANGPACK=`ls -l *apertium*$APERTLANG* | head -n 1 | sed -e "s/ */ /g" | cut -f 8 -d " "` |
LANGPACK=`ls -l --time-style=long-iso *apertium*$APERTLANG* | head -n 1 | sed -e "s/ */ /g" | cut -f 8 -d " "` |
||
LANGFOLDER=`tar tvzf $LANGPACK | head -n 1 | sed -e "s/ */ /g" | cut -f 6 -d " "` |
LANGFOLDER=`tar tvzf $LANGPACK | head -n 1 | sed -e "s/ */ /g" | cut -f 6 -d " "` |
||
| Line 215: | Line 217: | ||
make >> $LOGFILE 2>&1 |
make >> $LOGFILE 2>&1 |
||
$MKINST make install >> $LOGFILE 2>&1 |
$MKINST make install >> $LOGFILE 2>&1 |
||
rm -rf * |
rm -rf * |
||
rm -rf .* |
|||
cd .. |
cd .. |
||
rmdir $LANGFOLDER |
rmdir $LANGFOLDER |
||
echo "APERTIUM-$APERTLANG |
echo "APERTIUM-$APERTLANG instaŀlat correctament" |
||
fi |
fi |
||
fi |
fi |
||
else |
else |
||
echo "APERTIUM-$APERTLANG ja està |
echo "APERTIUM-$APERTLANG ja està instaŀlat" |
||
fi |
fi |
||
| Line 259: | Line 262: | ||
done |
done |
||
fi |
fi |
||
</pre> |
|||
Revision as of 13:42, 17 January 2008
Script per a instalar automàticament LTTOOLBOX, APERTIUM, un paquet d'idioma i habilitar el mode d'estadístiques.
#!/bin/bash
######################################################################################
#
# APERTIUM INSTALL
#
######################################################################################
errormsg()
{
cat - << EOF
S'ha produït un error mentre s'instaŀlava el paquet $1.
Comproveu els errors que s'han produït i contacteu amb l'administrador del vostre sistema.
EOF
}
fullusage()
{
cat - << EOF
This script installs lttoolbox and apertium packages, as well as language pairs defined as arguments.
Aquest guió instal·la els paquets lttoolbox i apertium, i els parells de llengües definits com a arguments.
EOF
usage
}
usage()
{
cat - << EOF
usage: $0 [-h|--help] [-l pair [-s]] [-i|--install local|global [-p path]]
example: $0 -l es-ca -i global
EOF
}
while getopts ":hl:i:p:s" opt ; do
case $opt in
h ) fullusage ; exit 1;;
l ) APERTLANG=$OPTARG ;;
i ) TYPEINSTALL=$OPTARG ;;
p ) PREFIX=$OPTARG ;;
s ) STATS=1 ;;
? ) echo "An invalid option was encountered."; echo "S'ha trobat una opció invàlida."; echo; usage ; exit 1;;
* ) echo "An unexpected error occured."; echo "S'ha produit un error desconegut."; echo; usage ; exit 1 ;;
esac
done
shift $((OPTIND - 1))
if [ x$APERTLANG != x ]; then
echo "Language selected: $APERTLANG"
else
echo "No language pair selected"
fi
if [ x$TYPEINSTALL != x ]; then
echo "$TYPEINSTALL installation mode"
if [ x$TYPEINSTALL != xlocal ]; then
TYPEINSTALL=global
fi
else
echo "Default installation mode"
fi
###
# preparem la ruta de la instalacio
#
if [ x$TYPEINSTALL = xlocal ]; then
if [ x$PREFIX = x ]; then
PREFIX=~/localEXAV/
fi
MKINST=""
else
PREFIX=/usr/local/
MKINST="sudo "
fi
PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig/
export PKG_CONFIG_PATH
LD_LIBRARY_PATH=$PREFIX/lib
export LD_LIBRARY_PATH
PATH=$PREFIX/bin/:$PATH
export PATH
LOGFILE=`pwd`/`date +%Y%m%e-%H%M%S`.logfile
###
# comprovem si ja està instaŀlat lttoolbox, i actuem
# en consecuència
#
echo "Instaŀlant el paquet LTTOOLBOX..."
if [ ! -e $PREFIX/bin/lt-proc ]; then
# no existeix lttoolbox, per tant l'instaŀlem
LTTOOLBOXPACK=`ls -l --time-style=long-iso *lttoolbox* | head -n 1 | sed -e "s/ */ /g" | cut -f 8 -d " "`
LTTOOLBOXFOLDER=`tar tvzf $LTTOOLBOXPACK | head -n 1 | sed -e "s/ */ /g" | cut -f 6 -d " "`
tar xzf $LTTOOLBOXPACK
if [ x$LTTOOLBOXFOLDER != x ]; then
if [ -d $LTTOOLBOXFOLDER ]; then
cd $LTTOOLBOXFOLDER
if [ -e ./configure ]; then
./configure --prefix=$PREFIX >> $LOGFILE 2>&1
else
./autogen.sh --prefix=$PREFIX >> $LOGFILE 2>&1
fi
make >> $LOGFILE 2>&1
$MKINST make install >> $LOGFILE 2>&1
rm -rf *
rm -rf .*
cd ..
rmdir $LTTOOLBOXFOLDER
TOADDPATH="PATH=$PREFIX/bin/:\$PATH;export PATH;"
echo "" >> ~/.bashrc
echo $TOADDPATH >> ~/.bashrc
echo "" >> ~/.bashrc
echo "LTTOOLBOX instaŀlat correctament"
fi
fi
else
echo "LTTOOLBOX ja està instaŀlat"
fi
if [ ! -e $PREFIX/bin/lt-proc ]; then
errormsg "lttoolbox"
exit 1
fi
###
# comprovem si ja està instaŀlat apertium, i actuem
# en consecuència
#
echo "Instaŀlant el paquet APERTIUM..."
if [ ! -e $PREFIX/bin/apertium-transfer ]; then
# no existeix apertium, per tant l'instaŀlem
APERTIUMPACK=`ls -l --time-style=long-iso *apertium* | head -n 1 | sed -e "s/ */ /g" | cut -f 8 -d " "`
APERTIUMFOLDER=`tar tvzf $APERTIUMPACK | head -n 1 | sed -e "s/ */ /g" | cut -f 6 -d " "`
tar xzf $APERTIUMPACK
if [ x$APERTIUMFOLDER != x ]; then
if [ -d $APERTIUMFOLDER ]; then
cd $APERTIUMFOLDER
if [ -e ./configure ]; then
./configure --prefix=$PREFIX >> $LOGFILE 2>&1
else
./autogen.sh --prefix=$PREFIX >> $LOGFILE 2>&1
fi
make >> $LOGFILE 2>&1
$MKINST make install >> $LOGFILE 2>&1
rm -rf *
rm -rf .*
cd ..
rmdir $APERTIUMFOLDER
echo "APERTIUM instaŀlat correctament"
fi
fi
else
echo "APERTIUM ja està instaŀlat"
fi
if [ ! -e $PREFIX/bin/apertium-transfer ]; then
errormsg "apertium"
exit 1
fi
###
# si no cal instalar paquet d'idioma...
#
if [ x$APERTLANG = x ]; then
exit 1;
fi
###
# comprovem si està instaŀlat el paquet d'idioma
#
echo "Instaŀlant el paquet d'idioma $APERTLANG..."
if [ ! -e $PREFIX/share/apertium/apertium-$APERTLANG ]; then
# no existeix lttoolbox, per tant l'instaŀlem
LANGPACK=`ls -l --time-style=long-iso *apertium*$APERTLANG* | head -n 1 | sed -e "s/ */ /g" | cut -f 8 -d " "`
LANGFOLDER=`tar tvzf $LANGPACK | head -n 1 | sed -e "s/ */ /g" | cut -f 6 -d " "`
tar xzf $LANGPACK
if [ x$LANGFOLDER != x ]; then
if [ -d $LANGFOLDER ]; then
cd $LANGFOLDER
echo $PKG_CONFIG_PATH
if [ -e ./configure ]; then
./configure --prefix=$PREFIX >> $LOGFILE 2>&1
else
./autogen.sh --prefix=$PREFIX >> $LOGFILE 2>&1
fi
make >> $LOGFILE 2>&1
$MKINST make install >> $LOGFILE 2>&1
rm -rf *
rm -rf .*
cd ..
rmdir $LANGFOLDER
echo "APERTIUM-$APERTLANG instaŀlat correctament"
fi
fi
else
echo "APERTIUM-$APERTLANG ja està instaŀlat"
fi
if [ ! -e $PREFIX/share/apertium/apertium-$APERTLANG ]; then
errormsg "apertium-"$APERTLANG
exit 1
fi
###
# una vegada instalat el paquet d'idioma, habilitem
# els modes d'estadístiques
#
if [ x$STATS != x ]; then
echo "Habilitant el mode d'estadístiques..."
MODES=`find $PREFIX/share/apertium/apertium-$APERTLANG -name '*.mode' -exec basename {} .mode \;`
for arg in $MODES
do
RUTA=$PREFIX/share/apertium/modes/
MODE=$RUTA$arg.mode
ESTADISTIQUES=$RUTA$arg-estadistiques.mode
echo " ... direcció $arg"
sed -e "s/automorf\.bin |/automorf\.bin \> \$LOGSDIR.tmp.\$SEC.org;/" < $MODE |\
sed -e "s/\.prob |/\.prob < \$LOGSDIR.tmp.\$SEC.org |/" > $ESTADISTIQUES
done
fi