#!/bin/bash
export TEXTDOMAIN="zero-lliurex-flavours"
# LLiurex-info-version
FICHERO='/tmp/version.txt'
SALIDA='/tmp/salida.txt'
MSG_INFO=$(gettext "Operating System:")
MSG_BASADO=$(gettext "Based on:")
MSG_KERNEL=$(gettext "Kernel:")
MSG_TITLE=$(gettext "ABOUT")
MSG_USER=$(gettext "User")
cat /dev/null > $FICHERO
cat /dev/null > $SALIDA
lsb_release -a > $FICHERO
uname -a >> $FICHERO
DESCRIPTION=$(grep Description $FICHERO | cut -c14-)
DISTRIBUTION=$(grep Distributor $FICHERO | cut -c17-)
RELEASE=$(grep Release $FICHERO | cut -c10-)
CODENAME=$(grep Codename $FICHERO | cut -c11-)
LINUX=$(grep Linux $FICHERO| cut -d" " -f3)
WHOAMI=$(whoami)
#CADENA="$MSG_INFO\n$DESCRIPTION\n$MSG_BASADO\n$DISTRIBUTION $RELEASE ($CODENAME)\n$MSG_KERNEL\n$LINUX\n$MSG_USER\n$WHOAMI"
#Si el usuario (aparecía root siempre al lanzarse desde el zero center)
CADENA="$MSG_INFO\n$DESCRIPTION\n$MSG_BASADO\n$DISTRIBUTION $RELEASE ($CODENAME)\n$MSG_KERNEL\n$LINUX"
zenity --info --text="$CADENA" --title="$MSG_TITLE"
# End of Lliurex-info-version
MSG_WINDOW=$(gettext "Flavour Utility")
MSG_DISTRIBUTION=$(gettext "Your Lliurex flavour. Choose new flavour to incorporate or cancel button.")
MSG_CHECK=$(gettext "Check")
MSG_DESCRIPTION=$(gettext "Description")
MSG_ADVERTISE=$(gettext "Now, You will see your actual distribution.\nIf you want to change it, check.\n(It will install a metapackage)")
MSG_NOVERSION=$(gettext "No version detected: Check one at least.")
MSG_INCOMPATIBILITY1=$(gettext "Incompatibility between Server and Client detected.")
MSG_INCOMPATIBILITY2=$(gettext "Incompatibility between Biblio and Client detected.")
# Sabores de Lliurex
FLAVORSERVER="Lliurex Server"
FLAVORCLIENT="Lliurex Client"
FLAVORDESKTOP="Lliurex Desktop"
FLAVORMUSIC="Lliurex Music"
FLAVORINFANTIL="Lliurex Infantil"
FLAVORLITE="Lliurex Lite"
FLAVORTEACHERS="Lliurex Teachers"
FLAVORPIME="Lliurex Pime"
FLAVORBIBLIO="Lliurex Biblio"
FLAVORGVA="Lliurex Gva"
#Variable sin inicializar en /usr/share/lliurex-up/common-upgrade-vars.sh
#IS_PIME=0
ALL_CEROS="1111111111"
source /usr/share/lliurex-up/common-upgrade-vars.sh
_researchCddVersion
_discoverCddVersion
#Booleanos de LLiurex
IS_SERVER_BOOL="FALSE"
IS_CLIENT_BOOL="FALSE"
IS_DESKTOP_BOOL="FALSE"
IS_MUSIC_BOOL="FALSE"
IS_INFANTIL_BOOL="FALSE"
IS_LITE_BOOL="FALSE"
IS_TEACHERS_BOOL="FALSE"
IS_PIME_BOOL="FALSE"
IS_BIBLIO_BOOL="FALSE"
IS_GVA_BOOL="FALSE"
IFS="+"
#Inicializando la lista doble (check -- descripción)
TODOS=$IS_SERVER$IS_CLIENT$IS_DESKTOP$IS_MUSIC$IS_INFANTIL$IS_LITE$IS_TEACHERS$IS_PIME$IS_BIBLIO$IS_GVA
if [ $TODOS = $ALL_CEROS ] ; then
FLAVORS=("FALSE""+"$FLAVORSERVER"+""FALSE""+"$FLAVORCLIENT"+""FALSE""+"$FLAVORDESKTOP\
"+""FALSE""+"$FLAVORMUSIC"+""FALSE""+"$FLAVORINFANTIL"+""FALSE""+"$FLAVORLITE\
"+""FALSE""+"$FLAVORTEACHERS"+""FALSE""+"$FLAVORPIME"+""FALSE""+"$FLAVORBIBLIO"+""FALSE""+"$FLAVORGVA)
zenity --error --text="$MSG_NOVERSION"
else
if [ $IS_SERVER -eq 0 ] ; then IS_SERVER_BOOL="TRUE" ; fi
if [ $IS_CLIENT -eq 0 ] ; then IS_CLIENT_BOOL="TRUE" ; fi
if [ $IS_DESKTOP -eq 0 ] ; then IS_DESKTOP_BOOL="TRUE" ; fi
if [ $IS_MUSIC -eq 0 ] ; then IS_MUSIC_BOOL="TRUE" ; fi
if [ $IS_INFANTIL -eq 0 ] ; then IS_INFANTIL_BOOL="TRUE" ; fi
if [ $IS_LITE -eq 0 ] ; then IS_LITE_BOOL="TRUE" ; fi
if [ $IS_TEACHERS -eq 0 ] ; then IS_TEACHERS_BOOL="TRUE" ; fi
if [ $IS_PIME -eq 0 ] ; then IS_PIME_BOOL="TRUE" ; fi
if [ $IS_BIBLIO -eq 0 ] ; then IS_BIBLIO_BOOL="TRUE" ; fi
if [ $IS_GVA -eq 0 ] ; then IS_GVA_BOOL="TRUE" ; fi
FLAVORS=($IS_SERVER_BOOL"+"$FLAVORSERVER"+"$IS_CLIENT_BOOL"+"$FLAVORCLIENT"+"$IS_DESKTOP_BOOL"+"$FLAVORDESKTOP"+"$IS_MUSIC_BOOL"+"$FLAVORMUSIC"+"$IS_INFANTIL_BOOL"+"$FLAVORINFANTIL"+"$IS_LITE_BOOL"+"$FLAVORLITE"+"$IS_TEACHERS_BOOL"+"$FLAVORTEACHERS"+"$IS_PIME_BOOL"+"$FLAVORPIME"+"$IS_BIBLIO_BOOL"+"$FLAVORBIBLIO"+"$IS_GVA_BOOL"+"$FLAVORGVA)
zenity --info --text="$MSG_ADVERTISE"
fi
for elemento in $FLAVORS; do
LIST=(${LIST[@]} "$elemento")
done
RESULTADO=$(zenity --title="$MSG_WINDOW" --width=600 --height=400 --text="$MSG_DISTRIBUTION" --list --column="$MSG_CHECK" --column="$MSG_DESCRIPTION" --checklist ${LIST[*]})
IFS="|"
#Comprobar la incompatibilidad SERVER-CLIENT y BIBLIO-CLIENT
RESULT_SERVER=0
RESULT_CLIENT=0
RESULT_BIBLIO=0
for result in $RESULTADO ; do
if [ $FLAVORSERVER = $result ] ; then RESULT_SERVER=1 ; fi
if [ $FLAVORCLIENT = $result ] ; then RESULT_CLIENT=1 ; fi
if [ $FLAVORBIBLIO = $result ] ; then RESULT_BIBLIO=1 ; fi
done
if [ $RESULT_SERVER$RESULT_CLIENT = "11" ] ; then
zenity --error --text="$MSG_INCOMPATIBILITY1"
exit 0
fi
if [ $IS_SERVER$RESULT_CLIENT = "01" ] ; then
zenity --error --text="$MSG_INCOMPATIBILITY1"
exit 0
fi
if [ $RESULT_SERVER$IS_CLIENT = "10" ] ; then
zenity --error --text="$MSG_INCOMPATIBILITY1"
exit 0
fi
if [ $RESULT_BIBLIO$RESULT_CLIENT = "11" ] ; then
zenity --error --text="$MSG_INCOMPATIBILITY2"
exit 0
fi
if [ $IS_BIBLIO$RESULT_CLIENT = "01" ] ; then
zenity --error --text="$MSG_INCOMPATIBILITY2"
exit 0
fi
if [ $RESULT_BIBLIO$IS_CLIENT = "10" ] ; then
zenity --error --text="$MSG_INCOMPATIBILITY2"
exit 0
fi
#Vaciar el fichero metapaquetes
:>/tmp/metapaquetes
#Arrastrar el metapaquete adecuado
echo $RESULTADO
for result in $RESULTADO ; do
if [ $FLAVORCLIENT = $result ] ; then echo "lliurex-meta-client install" >> /tmp/metapaquetes ; fi
if [ $FLAVORDESKTOP = $result ] ; then
if [ $RESULT_SERVER -eq 1 ] ; then
echo "lliurex-meta-server install" >> /tmp/metapaquetes
else
echo "lliurex-meta-escriptori install" >> /tmp/metapaquetes
fi
fi
if [ $FLAVORMUSIC = $result ] ; then echo "lliurex-meta-musica install" >> /tmp/metapaquetes ; fi
if [ $FLAVORINFANTIL = $result ] ; then echo "lliurex-meta-infantil install" >> /tmp/metapaquetes ; fi
if [ $FLAVORLITE = $result ] ; then echo "lliurex-meta-lleuger install" >> /tmp/metapaquetes; fi
if [ $FLAVORTEACHERS = $result ] ; then echo "lliurex-meta-mestre install" >> /tmp/metapaquetes ; fi
if [ $FLAVORPIME = $result ] ; then echo "lliurex-meta-pime install" >> /tmp/metapaquetes ; fi
if [ $FLAVORBIBLIO = $result ] ; then echo "lliurex-meta-biblioteca install" >> /tmp/metapaquetes ; fi
if [ $FLAVORGVA = $result ] ; then echo "lliurex-meta-gva install" >> /tmp/metapaquetes ; fi
done
apt-get update
synaptic --hide-main-window --non-interactive --set-selections-file /tmp/metapaquetes
exit 0