#!/bin/bash
# ututo-get.conf - Configuration file for UTUTO-Get
#
# Autor: Martin Andres Gomez Gimenez <mggimenez@ututo.org>
# Mantenido por: Pablo Manuel Rizzo <info@pablorizzo.com>
#
# Copyright (C) 2006 The UTUTO Project
# Distributed under the terms of the GNU General Public License v3 or new
#
# $Header: $

# UTUTO-Get muestra los mensajes en el idioma indicado por la 
# variable LANGUAGE. Válidos: es, en y cualquiera en /etc/ututo-get/lang/
UGET_LANG="es"

# La variable PROCESSOR se usa para indicar el valor correspondiente al
# procesador. Debe corresponder a uno de los siguientes valores:
#
# athlon-mp
# athlon-xp
# duron-athlon
# i486
# i586
# i686
# k6-2
# k6-3
# pentium3
# pentium4
# sempron
# xeon64
# NONE
PROCESSOR="NONE"
if [ -x "$(which select_cpu-type.sh 2>/dev/null)" -a "x$PROCESSOR" = "xNONE" ]; then
	PROCESSOR=$(select_cpu-type.sh -u)
fi
[ "x$PROCESSOR" = "x" ] && PROCESSOR="NONE"

# La variable PKGDIR define la ubicación donde deberÃ­an descargarse los
# archivos .tbz2 correspondienes a paquetes binarios.
PKGDIR="/usr/portage/packages/All"
# La variable PORTDIR define la ubicación del árbol del portage.
PORTDIR="/usr/portage"
# Directorio de instalación de uget
UGETDIR=/usr/libexec/uget
# Directorio de configuracion de uget
CONFIGDIR=/etc/uget
# Directorio de versiones de uget
VERSDIR=$CONFIGDIR/version
# Ubicacion del repositorio de scripts
REPOSDIR=/var/db/uget
# Directorio de logs
LOGSDIR=/var/log/uget
# Directorio para mover temporalmente el portage
TMPUGETDIR="/usr/portage/tmpuget"


# Opciones para controlar el gestor de descargas (por defecto wget).
GET_PROGRAM="wget"

# Protocolo a utilizar en las descargas (https, http, ftp)
PROTOCOL="http"

# La variable GET_OPTIONS indica las opciones que deben pasarse al
# programa de descarga.
GET_OPTIONS="--continue --proxy --passive-ftp --no-cache --timeout 20 -U uget-0.x "

# If using https, don't forget to use --no-check-certificate
[ $PROTOCOL = "https" -a "x${GET_OPTIONS//--no-check-certificate/}" == "x$GET_OPTIONS" ] && GET_OPTIONS="$GET_OPTIONS --no-check-certificate "

# If using wget v1.9, use "--proxy yes|no" but don't use "--no-check-certificate"
if [ "$GET_PROGRAM" = "wget" ]; then
	WGETVERSION=$(wget --version | head -n 1 | grep "1.9")
	if [ "x$WGETVERSION" != "x" ]; then
		GET_OPTIONS=$(echo $GET_OPTIONS | sed "s/--no-check-certificate//")
		GET_OPTIONS=$(echo $GET_OPTIONS | sed "s/--no-cache//")
		GET_OPTIONS=$(echo $GET_OPTIONS | sed -r "s/--proxy[ ]*-/--proxy yes -/" | sed -r "s/--proxy[ ]*$/--proxy yes /")
		GET_OPTIONS=$(echo $GET_OPTIONS | sed -r "s/-Y[ ]*-/-Y yes -/" | sed -r "s/-Y[ ]*$/-Y yes /")
	fi
fi
[ "$GET_PROGRAM" = "axelGet" ] && GET_OPTIONS=""


# Repositorio a utilizar. Por defecto packages.ututo.org Cambiado al framework pkg.ututo
SERVER="packages.ututo.org"

# Permite indicar un programa diferente para descargar los paquetes binarios
# DEFAULT="wget"
# ALTERNATIVE="axelGet" (requires axel)
GET_PROGRAM_PKG=$GET_PROGRAM

# Permite indicar parametros diferentes para descargar los paquetes binarios
GET_OPTIONS_PKG=$GET_OPTIONS
[ "$GET_PROGRAM_PKG" = "axelGet" ] && GET_OPTIONS_PKG=""

# Permite indicar un protocolo diferente para descargar los paquetes binarios
PROTOCOL_PKG=$PROTOCOL

# Permite indicar un servidor diferente para descargar los paquetes binarios
SERVER_PKG=$SERVER

GET="$GET_PROGRAM $GET_OPTIONS"
GETPKG="$GET_PROGRAM_PKG $GET_OPTIONS_PKG"

##############################################################################
# FUNCION: axelGet
#
# Descarga utilizando axel en vez de wget, para acelerar las descargas
# Esta función está aquí hasta tanto sea movida a una librería de funciones
axelGet() {
	local params="--alternate -n 2"
	
	for var in http_proxy https_proxy ftp_proxy
	do
		[ "x${!var}" != "x" ] && export $(echo "$var"  | tr [:lower:] [:upper:])=${!var}
	done
		
	while [ $# -gt 1 ]; do
		params="$params $1"
		shift
	done
# 	set -x
	axel $params $1 -o ${1/*\//}
# 	set +x
}


# La variable NICELEVEL indica el nivel de prioridad (niceness) con que se 
# ejecutar� los procesos de instalaci� que mas CPU consumen. Los valores
# posibles son enteros en el rango -20 (mayor prioridad) a 20 (menor prioridad)
# El valor por defecto es 0 (igual que la mayor� de los procesos del usuario)
NICELEVEL="5"

# La variable INSTALL indica la aplicación a utilizar para instalar paquetes.
# Por defecto se utiliza emerge. Vea la página de manual de emerge para más
# información.
INSTALL="nice -n $NICELEVEL emerge"

# La variable INSTALL_OPTIONS indica las opciones que deben pasarse al
# programa de instalación.
INSTALL_OPTIONS="--nodeps --usepkgonly --quiet"

# La variable TAR_OPTIONS indica las opciones que deben pasarse al
# programa tar. El valor por defecto es: "-xvjpf" donde (vea la página de
# manual de tar para mas detalles):
# -x, --extract
# -v, --verbose
# -j, --bzip2
# -p, --preserve-permissions
# -f, --file=FICHERO
TAR_OPTIONS="-xvjpf"

# Si utiliza UTUTO-Get-GUI, deje las siguientes variables vacias para visualizar
# mejor la salida
#
if [ "x$(ps ax | grep ututo-get-gui.kmdr | grep -v grep | wc -l)" = "x0" ]; then
	# Configuracion para consola
	WHITE="\033[1m"
	BEEP="\a"
	NO_COLOUR="\033[0m"
else 
	# Configuracion para GUI
	WHITE=""
	BEEP=""
	NO_COLOUR=""
	INSTALL_OPTIONS="$INSTALL_OPTIONS"
fi

##############################################################################
# Following lines are a workaround for some postinstall actions generated by
# the Developement Kit
SERVIDOR="$SERVER"
RES="$PROCESSOR"
INSTALAR="$INSTALL"
OPCION="$INSTALL_OPTIONS"
##############################################################################

# Esperar respuestas del usuario por TOUT segundos y seleccionar el default si
# no hay respuesta
TOUT="10"

# Ejecutar prelink al final del proceso?
# 0:NO	
# 1:SI	
# -1:PREGUNTAR
PRELINK="-1"

# Imprime informacion de debug para desarrolladores
DEBUG="1"

# What repository to use?
#REPOSITORIO="disponibles"
#REPOSITORIO="disponibles_testing"
REPOSITORIO="disponibles"

# Where to download disponibles.NN from
case $REPOSITORIO in
	"disponibles_testing" )
		DISPONIBLES_URL="$PROTOCOL://$SERVER/paquetes"
		#DISPONIBLES_FILE="disponibles_testing.tar.bz2"
		#DISPONIBLES_URL="http://backup.dnsready.net/ututo"
		DISPONIBLES_FILE="disponibles_testing.7z"
	;;
	* )
		DISPONIBLES_URL="$PROTOCOL://$SERVER/paquetes"
		#DISPONIBLES_FILE="disponibles.tar.bz2"
		#DISPONIBLES_URL="http://backup.dnsready.net/ututo"
		#DISPONIBLES_URL="http://backup.dnsready.net/ututo"
		DISPONIBLES_FILE="disponibles.7z"
	;;
esac



# Where to download portage from
PORTAGE_URL="http://packages.ututo.org/ututo-portage"
PORTAGE_FILE="ututo-portage-latest.tar.bz2"


# Repositorio de actualizacion de ututo-get
# TRUNK This is the bleeding edge version
#UTUTOGET_URL="http://ututo.conmutador.net/svn.ututo.org/ututo-src/ututo-get/trunk"
# ACTUAL This is the current "stable" version
#UTUTOGET_URL="http://ututo.conmutador.net/svn.ututo.org/ututo-src/ututo-get/tags/actual"
#UTUTOGET_URL="http://ututo.conmutador.net/svn.ututo.org/ututo-src/ututo-get/trunk"
UTUTOGET_URL="http://packages.ututo.org/svn.ututo.org/ututo-src/ututo-get/trunk"

# Configurar el servidor proxy
#export http_proxy="http://proxyserver:3128"
#export http_proxy="http://10.10.4.115:3128"
#export https_proxy="http://proxyserver:3128"
#export ftp_proxy="http://proxyserver:3128"

