#!/bin/bash
#################################################################
# Inicio de scripts sumapack.org
# Software Libre bajo la AGPLv3+: http://www.fsf.org/licensing/licenses/gpl.html
# Diego Saravia  dsa@unsa.edu.ar Diego.Saravia@gmail.com
################################################################3



TEMP=$(getopt -o hvs --long help,version -- "$@")

#if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi

# Note the quotes around "$TEMP": they are essential!
eval set -- "$TEMP"

hacesolo=0;

while true ; do
	case "$1" in
		-h|--help) echo "Help" ; shift ; exit ;;
		-v|--version) echo "Version" ; shift ; exit  ;;
                -s) hacesolo=1; break;;
		--) shift ; break ;;
		*) echo "Bad Parameter!>: $1" ; exit 1 ;;
	esac
done
#echo "Remaining arguments:"
#for arg do echo "--> $arg" ; done

#################################################################
# Informacion de sistema para instalar paquetes y distribuciones
# Software Libre bajo la AGPLv3+: http://www.fsf.org/licensing/licenses/gpl.html
# Diego Saravia  dsa@unsa.edu.ar Diego.Saravia@gmail.com
################################################################3


#DAT=$0
#echo directorio ejecucion $DAT
#DATS=$(echo $DAT | sed 's/\/bin\/infosis//')
#DATS2=$(echo $DATS | sed 's/\/configure//')
#DATOS=$DATS2/share/sumapack
#prefix=@prefix@
#DATOS=@datarootdir@/sumapack
#NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN Nota esto era infosis.in, sacado para simplificar, reponer
# OJO COORDINAR CON MAKEFILE
#prefix=/usr
#DATOS=/usr/share/sumapack
#VAR=$prefix/var/sumapack
#echo "export DIRDATO=$DATOS"
#echo "export VARDATO=$VAR"

# i486/Pentium
# i686
# Pentium3
# Pentium4
# Duron
# Athlon XP
# Athlon MP
# K8 [Athlon64-Sempron]
# Intel/64 [Pentium4-Xeon]

#Yo tengo en mi maquina un Sempron de 2.4 y pues nada aqui esta directo
#para bajar pero mi duda es nada por que esta en el mismo link de un
#Athlon64 ya que esta maquina Sempron que yo tengo no es de 64 si no de
#32 bits o es que en mi País Venezuela estamos usando otra nomenclatura
#para los CPU por que aquí tenemos Sempron que es como los celeron de
#intel y los Semprun un cpu de 64bits es mas mi tarjeta madre la que
#uso con ese cpu que tengo es una K7 de MSI ... por eso no puede ser de
#la rama de los K8 ??

#La compilacion de Sempron es "k8" igual que la de Athlon64
#Para el sempron de 32 bits la correcta es la Athlon-XP
#La generica de AMD que es "duron-athlon" tambien se ejecutara, como asi
#tambien la generica "i686"
#Pero con la version athlon-XP obtendras mejor rendimiento en un
#Sempron32

#TIPPRO=$(cat /proc/cpuinfo |grep "model name" |awk '\
#       /Mobile Intel\(R\) Pentium\(R\) 4/ {if (SI!=1) print
#"pentium4m" ;     SI=1;}\
#       /Pentium\(R\) 4/ {if (SI!=1) print "pentium4" ;    SI=1;}\
#       /Celeron/        {if (SI!=1) print "celeron";      SI=1;}\
# (Coppermine)
#       /Pentium III/    {if (SI!=1) print "pentium3";     SI=1;}\#
#Pentium III (Katmai)
#       /Athlon/         {if (SI!=1) print "athlon";       SI=1;}\
##AMD Athlon(tm) Processor
#       /Pentium II/     {if (SI!=1) print "pentium2";     SI=1;}\
##Pentium II (Deschutes)
#       /Duron/          {if (SI!=1) print "duron-athlon"; SI=1;}\
##duron-athlon es un duron, historico
#       /END/            {if (SI!=1) print "i386";         SI=1;}\')
      

NUMPRO=$(cat /proc/cpuinfo |grep 'model name' |wc -l)

TIPPRO=$(cat /proc/cpuinfo |grep 'model name' |awk ' \
        /Extreme Edition/ {if (SI!=1) print "i7EE" ;    SI=1;}\
        /Extreme/         {if (SI!=1) print "coreE" ;    SI=1;}\
        /i7/              {if (SI!=1) print "i7" ;    SI=1;}\
        /i5/              {if (SI!=1) print "i5" ;    SI=1;}\
        /i3/              {if (SI!=1) print "i3" ;    SI=1;}\
        /Xeon/            {if (SI!=1) print "xeon" ;    SI=1;}\
        /Itanium/         {if (SI!=1) print "itanium" ;    SI=1;}\
        /Atom/            {if (SI!=1) print "atom" ;    SI=1;}\
        /Quad/           {if (SI!=1) print "cuad" ;    SI=1;}\
        /Duo/            {if (SI!=1) print "duo" ;    SI=1;}\
        /Solo/            {if (SI!=1) print "duo" ;    SI=1;}\
        /vPro/            {if (SI!=1) print "duo" ;    SI=1;}\
        /Core(TM)2/      {if (SI!=1) print "core2" ;    SI=1;}\
        /Core/           {if (SI!=1) print "core" ;    SI=1;}\
        /Pentium\(R\) 4/ {if (SI!=1) print "pentium4" ;    SI=1;}\
        /Celeron/        {if (SI!=1) print "celeron";      SI=1;}\
        /Pentium III/    {if (SI!=1) print "pentium3";     SI=1;}\
        /K5/         {if (SI!=1) print "k5";       SI=1;}\
        /K6/         {if (SI!=1) print "k6";       SI=1;}\
        /Athlon 64 X2/         {if (SI!=1) print "athlon64X2";       SI=1;}\
        /Athlon 64 FX/         {if (SI!=1) print "athlon64FX";       SI=1;}\
        /Athlon 64/         {if (SI!=1) print "athlon64";       SI=1;}\
        /Athlon XP-M/         {if (SI!=1) print "athlonXPM";       SI=1;}\
        /Athlon XP/         {if (SI!=1) print "athlonXP";       SI=1;}\
        /Athlon II/         {if (SI!=1) print "athlonII";       SI=1;}\
        /Athlon X2/         {if (SI!=1) print "athlonX2";       SI=1;}\
        /Athlon 6/         {if (SI!=1) print "athlon6";       SI=1;}\
        /Athlon 4/         {if (SI!=1) print "athlon4";       SI=1;}\
        /Athlon/         {if (SI!=1) print "athlon";       SI=1;}\
       /Turion 64 X2/       {if (SI!=1) print "turion64X2";       SI=1;}\
        /Turion 64/       {if (SI!=1) print "turion64";       SI=1;}\
        /Turion/         {if (SI!=1) print "turion";       SI=1;}\
       /Phenom FX/         {if (SI!=1) print "phenomFX";       SI=1;}\
       /Phenom X4/         {if (SI!=1) print "phenomX4";       SI=1;}\
       /Phenom X3/         {if (SI!=1) print "phenomX3";       SI=1;}\
        /Phenom II/         {if (SI!=1) print "phenomII";       SI=1;}\
        /Phenom/         {if (SI!=1) print "phenom";       SI=1;}\
        /Sempron/         {if (SI!=1) print "sempron";       SI=1;}\
        /Opteron/         {if (SI!=1) print "opteron";       SI=1;}\
        /Pentium II/     {if (SI!=1) print "pentium2";     SI=1;}\
        /Duron/          {if (SI!=1) print "duron-athlon"; SI=1;}\
        END               {if (SI!=1) print "i386";         SI=1;}\
        ')
#Pentium Pro
#Pentium mmx
# DX SX SL DX2
#Pentium II Xeon
#Pentium M
#Celeron M
#Pentium Dual Core

TIPPROM=$(cat /proc/cpuinfo |grep 'model name' |awk '\
        /Mobile/ {if (SI!=1) print "m" ;     SI=1;}\
        /mobile/ {if (SI!=1) print "m" ;     SI=1;}\
        END      {if (SI!=1) print "0";      SI=1;}\
        ')
#mayusculas/minusculas/awk regex


# (Coppermine)
#pentium-mmx
#c2*  i586*
#pentiumpro
#pentium*
#athlon* i686*  i*86* winchip i486* i386*
#Pentium III (Katmai) 
#AMD Athlon(tm) Processor 
#Pentium II (Deschutes) 
#duron-athlon es un duron, historico




# como source variables internas

# revisar config.sub

LINUXKERNEL=$(cat /proc/version | awk '\
       /SUSE/     {if (SI!=1) print "SuSE";        SI=1;}\
       /musix/    {if (SI!=1) print "Musix";       SI=1;}\
       /RePortE/  {if (SI!=1) print "UtutoR";      SI=1;}\
       /ututo-xs/ {if (SI!=1) print "UtutoEXS";    SI=1;}\
       /ututo/    {if (SI!=1) print "Ututo";       SI=1;}\
       /Ubuntu/   {if (SI!=1) print "Ubuntu";      SI=1;}\
       /Debian/   {if (SI!=1) print "Debian";      SI=1;}\
       /Gentoo/   {if (SI!=1) print "Gentoo";      SI=1;}\
       /fedora/   {if (SI!=1) print "Fedora";      SI=1;}\
       /red-hat/  {if (SI!=1) print "Red-Hat";     SI=1;}\
       /centos/   {if (SI!=1) print "CentOs";      SI=1;}\
       /linux/    {if (SI!=1) print "GNULinux";    SI=1;}\
       /./        {if (SI!=1) print "NoSe";        SI=1;}\
       ')
#       /sarge/    {if (SI!=1) print "DebianSarge"; SI=1;}\


echo "export LINUXKERNEL=$LINUXKERNEL"

# no se que saca

#revisar fedora redhat centos
SISTEMA=$(uname -o)
SISVERSION=$(uname -r|awk -F'.' '{print $ 1"."$ 2"."$ 3}')

MARCHITECTURE=$(uname -p)

if test "x$SISTEMA" != "xGNU/Linux" ; then
   case $SISTEMA in
       Cygwin*)  echo "";   DISTRO=CYGWIN      ;;
       MINGW*)   echo "";   DISTRO=MINGW      ;;
       FreeBSD ) echo "";   DISTRO=FREEBSD  ;;
       Solaris ) echo "";   DISTRO=SOLARIS  ;;
       SunOS )   echo "";   DISTRO=SUNOS  ;;
       OpenBSD ) echo "";   DISTRO=OPENBSD  ;;
       NetBSD )  echo "";   DISTRO=NETBSD  ;;
       * )       echo ""; DISTRO=NONGNULINUX   ;;
             
   esac


else
if test -e /etc/SuSE-release; then
   DISTRO=SUSE
   CD=$(cat /etc/SuSE-release) 
   DISTCOMP=$(echo  $CD |sed  's/\s/\_\_/g'|sed  's/[()]/_/g'|sed  's/=/:/g' )
   SVERSION=$(echo $CD | head -n1 | awk -F' ' '/VERSION/ {print $ 2 }')
   # se puede usar la segunda linea
   #11.2
   ESOPEN=$(echo $CD |grep open)
     if test "x$ESOPEN" != x ; then
        SUBDISTRO=openSUSE
        DVERSION=$SVERSION
     fi
# antes que redhat porque madriva tiene un redhat-release con el mismo contenido que el mandriva-release
elif test -e /etc/mandriva-release; then
     DISTRO=MANDRIVA
     CD=$(cat /etc/mandriva-release)
elif test -e /etc/redhat-release; then
   DISTRO=REDHAT
   CD=$(cat /etc/redhat-release)
   SVERSION=$CD 
   DVERSION=$SVERSION
   DISTCOMP=$(echo  $CD |sed  's/\s/\_\_/g'|sed  's/[()]/_/g'|sed  's/=/:/g' )
   if test -e /etc/fedora-release; then
     SUBDISTRO=Fedora
     SVERSION=$(cat /etc/fedora-release) 
   elif test "x$(echo $CD |grep CentOS)" != x ; then
     SUBDISTRO=CentOS
     SVERSION=$CD 
   fi
elif test -e /etc/debian_version; then
   DISTRO=DEBIAN
   SVERSION=$(cat /etc/debian_version) 
   DVERSION=$SVERSION
   VERSIONNORM=$SVERSION
   if test "x$(echo $SVERSION| grep sid)" != x ; then
     VERSIONNORM=sid
     # el paquete base-files que contiene ese archivo fue parte de sid cuando se instalo, y en ese
     # momento el nombre que lo precede squeezy, (squeezy/sid, por ejemplo) estaba en testing
     # asumimos entonces que la distro es unstable, o sea sid y ponemos en sid los repos a agregar
   fi 
   VERSIONDEBIANCODE=stable
   case "$VERSIONNORM" in
                 1.1) VERSIONDEBIANCODE=buzz;    NOEX=1 ;; 
                 1.2) VERSIONDEBIANCODE=rex;     NOEX=1 ;; 
                 1.3) VERSIONDEBIANCODE=bo;      NOEX=1 ;; 
                 2.0) VERSIONDEBIANCODE=hamm;    NOEX=1 ;; 
                 2.1) VERSIONDEBIANCODE=slink;   NOEX=1 ;; 
                 2.2) VERSIONDEBIANCODE=potato;  NOEX=1 ;; 
                 3.0) VERSIONDEBIANCODE=woody;   NOEX=1 ;; 
                 3.1) VERSIONDEBIANCODE=sarge;   NOEX=1 ;; 
                 4.0) VERSIONDEBIANCODE=etch;    NOEX=0 ;; 
                 5.0*) VERSIONDEBIANCODE=lenny;   NOEX=0 ;;  #5.0.3
       #             squeeze) VERSIONDEBIANCODE=squeeze; NOEX=0 ;; # no hay ni habra un debian asi
       # ningun paquete en basic-files tiene ese /etc/debian_version
       # sera mejor usar lsb_release, que dara en caso de squeeze, testing?
       #lsb_release da unstable/stable/etc y en codename sid/etc
                 sid) VERSIONDEBIANCODE=sid;     NOEX=0 ;;  # lenny/sid squeeze/sid
        experimental) VERSIONDEBIANCODE=experimental;     NOEX=0 ;;
        # buzz 1.1,rex 1.2, bo 1.3, hamm 2.0, slink 2.1, potato 2.2, 
        #woody 3.0, sarge 3.1, etch 4.0, lenny 5.0, squeeze, sid, experimental
              *) VERSIONDEBIANCODE=stable;    NOEX=0 ;; 
    esac 
    if test "x$NOEX" = "x1"; then 
         VERSIONDEBIANCODE=stable   
    fi
    EXISTEVERSIONDEBIAN=$NOEX
   if test -e /etc/issue -a "x$(grep 'Ubuntu' </etc/issue)" != "x" ; then
#cat /etc/issue
#Ubuntu 9.10 \n \l

         SUBDISTRO=Ubuntu
         DVERSION=$SVERSION
         SVERSION=$(cat  /etc/issue | awk -F' ' '{print $ 2}')
#cat /etc/musix-version
#1.0R6b1
         #CDS=$(cat /etc/fedora-release)
   elif test -d /etc/musix ; then
         SUBDISTRO=Musix
         if test -e /etc/musix-version; then
            SVERSION=$(cat /etc/musix-version)
         fi
   fi

# antes que gentoo, porque algunos ututos tienen un gentoo-release con el mismo contenido que el ututo-release
elif test -e /etc/ututo-release -o -e /ututo.lastversion -o "x$(cat /etc/issue|grep ututo)" != x ; then
    DISTRO=UTUTO
    if test  -e /ututo.lastversion; then
      SVERSION=$(cat /ututo.lastversion | sed 's/\s/_/g' |sed 's/(//'|sed 's/)//g')
     else
      SVERSION=
    fi
    #NOPORAHORA=$(cat /etc/ututo-release)
    if test -e /etc/gentoo-release; then
      DVERSION=$(cat /etc/gentoo-release | sed 's/\s/_/g')
      
    fi
elif test -e /etc/gentoo-release; then
     DISTRO=GENTOO
     SVERSION=$(cat /etc/gentoo-release | sed 's/\s/_/g')
elif test -e /etc/slackware-version; then
     DISTRO=SLACKWARE
     SVERSION=$(cat /etc/slackware-version |awk -F' ' '{print $ 2}')
     # ojo repos necesitan solo dos primeros componentes
     # Slackware 12.2.0
     if test -e /etc/slax-version; then
       SUBDISTRO=Slax
       #Slax 6.1.2
       DVERSION=$(cat /etc/slax-version |awk -F' ' '{print $ 2}')
     fi
elif test -e /etc/release; then
     #caso que no es linux, reevisar
     CD=$(cat /etc/release) 
     ESSOL=$(echo $CD |grep Solaris)
     if test "x$ESSOL" != x ; then
        DISTRO=SOLARIS
     fi
else

#    DIST Tomado de sysinfo.sh
#    Copyright (C) 2006  Makarand Hazarika
#    You can contact the author at <makarand.hazarika@gmail.com>
#    http://www.novell.com/coolsolutions/tools/17005.html

    DISTRO=$(for i in /etc/*[rv]e[lr][es][ai][so][en] 
	do 
		if [ -L "$i" ]
		then 
			echo > /dev/null
		else  
			echo "$i"
		fi
	done 2> /dev/null | sed '/LSB/d'|sed '/_//' |sed '/-//' | tr \n ' '  )
     CD=$(for i in /etc/*[rv]e[lr][es][ai][so][en] 
	do 
		if [ -L "$i" ]
		then 
			echo > /dev/null
		else  
			cat "$i"
		fi
	done 2> /dev/null  )
     if "x$DISTRO" = "x" ; then
        DISTRO=$(cat /etc/issue)
     fi
fi
fi







echo "export SISTEMA=$SISTEMA"
echo "export LINUXSISTEMA=\"$(uname -a)\""
echo "export MARCHITECTURE=\"$MARCHITECTURE\""
#echo "export VERSION=$VERSION"
# eliminar esta version, choca con la version del paquete
echo "export SVERSION=$SVERSION"
echo "export DVERSION=$DVERSION"
echo "export DISTCOMP=\"$DISTCOMP\""
echo "export SISVERSION=$SISVERSION"
echo "export DISTRO=$DISTRO"
echo "export SUBDISTRO=$SUBDISTRO"

# la distro es distr-dversion
# la subdistro o version de distro es subdistr-version 
echo "export DISTROVECTOR='$SISTEMA:$SISVERSION:$DISTRO:$DVERSION:$SUBDISTRO:$VERSION'"



#echo "export CDIST=$CDIST"
#CDIST=$(echo $CD|cut -d' ' -f1)
#CDISTS=$(echo $CDS|cut -d' ' -f1)
#CDISTG=$(echo $CDG|cut -d' ' -f1)
#CDIST2=$(echo $CD2|cut -d' ' -f1)

#DISTCOMPS=$(echo  $CDS |sed  "s/ /\_\_/g"|sed  "s/[()]/_/g" )
#DISTCOMPG=$(echo  $CDG |sed  "s/ /\_\_/g"|sed  "s/[()]/_/g" )
#DISTCOMP2=$(echo  $CD2 |sed  "s/ /\_\_/g"|sed  "s/[()]/_/g" )

#echo CDIST $CDIST $CDISTS $CDISTG $CDIST2 DISTCOMP $DISTCOMP $DISTCOMPS  $DISTCOMPG  $DISTCOMP2 


#Linux gnu249 2.6.11-HR1 #1 SMP esto es un ututo!

#fedora
#esto no sirve para chroot, porque saca de /proc/version

#en el fondo ningun sistema con repositorios dinamicos tiene una
#version fija, en todo caso la version seria un vector de dimension
#igual al numero de paquetes que tenes,
#pero no veo mal que se pueda tener un recuerdo de desde donde se
#instalo el sistema
#/etc/lsb-release
# /etc/SuSE-release
# /etc/gentoo-release
# /etc/fedora-release
#/etc/redhat-release -> fedora-release
#/etc/system-release -> fedora-release
#/etc/debian_version
#/etc/ututo-release
#UTUTO XS GNU System
#/ututo.lastversion
#XS2010 (07)
#/etc/gentoo-release
#Gentoo Base System release 1.12.13
#cat /etc/slackware-version
#The file /etc/debian-version for lenny will contain, from now on,
#a string of the form 5.0.n where n is an integer number.
#I have "5.0" on a lenny system and "squeeze/sid" on sid. The file
#belongs to the package base-files. Which version of base-files do you
#have installed (apt-cache-policy base-files)?


#cat /etc/redhat-release
#Red Hat Enterprise Linux Server release 5.1 (Tikanga)
#cat /etc/redhat-release
#Red Hat Enterprise Linux ES release 4 (Nahant Update 3)
#cat /etc/redhat-release
#Fedora release 8 (Werewolf)
#cat /etc/issue :
#Debian GNU/Linux 4.0 \n \l
#    * use /etc/redhat-release or /etc/SuSE-release (/etc/issue for Ubuntu)
#    * uname helps you identify if you're using a 32bit or 64bit kernel
#    * lsb_release command shows you release information as per LSB specification
#cat /etc/redhat-release
#Red Hat Enterprise Linux Client release 5 (Tikanga)
#cat /etc/issue
#Ubuntu 6.10 n l
#cat /etc/SuSE-release
#SUSE Linux Enterprise Desktop 10 (x86_64)
#VERSION = 10
#cat /etc/release
#            Solaris 8 2/04 s28s_hw4wos_05a SPARC
#Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
#                 Assembled 08 January 2004
#/mandriva/etc/mandrake-release  /mandriva/etc/mandrakelinux-release  
#esos 3 son links a 
#/mandriva/etc/mandriva-release
#Mandriva Linux release 2010.0 (Official) for x86_64
#/etc/slackware-version
#Slackware 12.2.0
#/slackware/etc/slax-version
#Slax 6.1.2


#DIST HERRAMIENTA - REPOSITORIOS


# ver config.sub de autotools
# uname MSYS
# MINGW32_NT-5.1
# -a
# MINGW32_NT-5.1 DESKTOP 1.0.11()
# uname -a
# CYGWIN_NT-5.1 desktop 1.5.25() blabla
#uname
# CYGWIN_NT-5.1
# uname -a SunOS sun 5.10 Generic_120012-14 i86pc i386 i86pc

#SOURCE, por ejemplo linux from scratch  u otro construido a mano
#REP: repositorio

#if test "x$PACKUSE" = "xrpm" ; then
#  if test "x$DISTRO" = "xSUSE"; then
#      REPPACK=SUSE-RPM
#    else
#      if test "x$DISTRO" = "xREDHAT"; then
#         REPPACK=REDHAT-RPM
#        else
#          if test "x$DISTRO" = "xMANDRIVA"; then
#              REPPACK=MANDRIVA-RPM
#          fi
#       fi
#  fi
# else
#  if test "x$PACKUSE" = "xdeb" ; then 
#    if test "x$DISTRO" = "xUBUNTU"; then
#      REPPACK=UBUNTU-DEB
#     else
#      if test "x$DISTRO" = "xDEBIAN"; then
#        REPPACK=DEBIAN-DEB
#      fi
#    fi
#   else 
#    if test "x$PACKUSE" = "xebuild" ; then 
#       #REPPACK=UTUTO-TBZ2
#       REPPACK=GENTOO-EBUILD
#    fi
#  fi
#fi
#REPPACK=SLACKWARE-TXZ
#REPPACK=SOURCE-MAKE
#REPPACK=BSD-PKGINST
#REPPACK=SOLARIS-PORT
###############3

# ver de detectar si usa zypper yum apt-get emerge?



#echo "export REPPACK=$REPPACK"

#########################################################
#/etc/issue

#DISTR=$(for i in /etc/*[rv]e[lr][es][ai][so][en] 
#	do 
#		if [ -L "$i" ]
#		then 
#			echo > /dev/null
#		else  
#			cat "$i"
#		fi
#	done 2> /dev/null | sed '/LSB/d' | head -n 1)
#
#LINUXDIST=$DISTR





#usaremos VERSIONXXX para agregar repos



#debian unstable
#debian codename sid
#suse release 11.2
#suse docename n/a
#squeeze/sid  lenny/sid


#DIRECTORIOS REALES
# buzz 1.1,rex 1.2, bo 1.3, hamm 2.0, slink 2.1, potato 2.2, woody 3.0, sarge 3.1, etch 4.0, lenny 5.0, squeeze, sid, experimental
# nombres que equivalen a versiones, el numero se asigna despues del nombre, cuando es estable o publicada

#LINKS

# estos son links simbolicos a los nombres anteriores:
#VARIABLES: oldstable, stable, testing, 
# frozen no se
#FIJOS: unstable (es un link permanente a  sid), experimental no es un link






# paquetes son binary-all son noarch, binary-[i386,m68k,sparc,alpha,powerpc,arm,hurd-i386]






#if test "x$DIST" = "xopenSUSE"; then
#   DISTRO=SUSE
#else
#if test "x$DIST" = "xFedora"; then
#   DISTRO=REDHAT
#else
#if test "x$DIST" = "xGentoo"; then
#   DISTRO=GENTOO
#else
#if test "x$DIST" = "xMandriva"; then
#   DISTRO=MANDRIVA
#else
#if test -e /etc/debian_version; then
#   DISTRO=DEBIAN
#
#fi
#fi
#fi
#fi
#fi




if test "x$hacesolo" = x1; then
   exit;
fi

###############33
TAMZ=1
TAMW=$(ls /etc/setup/*.lst.gz  2>/dev/null  | wc -l)
TAME=$(ls /var/db/pkg/*  2>/dev/null  | wc -l)
TAMS=$(ls /var/log/package/*  2>/dev/null  | wc -l)
# ojo en ubunto con pkg install
TAMD=$(ls /var/lib/dpkg/info/*.list  2>/dev/null |wc -l  )  
TAMR=$(rpm  -qa --queryformat '%{NAME}\n'  2>/dev/null |wc -l   )
PACKUSE=$(echo -e "make\n$TAME ebuild\n$TAMD deb\n$TAMS slackware\n$TAMR rpm\n$TAMW cygwin\n $TAMZ" |sort -n|tail -n1 | awk '{print $ 2} ')

#echo "E:$TAME D:$TAMD R:$TAMR G:$PACKUSE "

echo "export PACKCYGWIN=$TAMW"
echo "export PACKSLACKWARE=$TAMS"
echo "export PACKRPM=$TAMR"
echo "export PACKDEB=$TAMD"
echo "export PACKEBUILD=$TAME"
echo "export PACKUSE=$PACKUSE"



######################################### LSB

#LSB Version:    core-2.0-noarch:core-3.2-noarch:core-4.0-noarch:core-2.0-x86_64:core-3.2-x86_64:core-4.0-x86_64:desktop-4.0-amd64:desktop-4.0-noarch:graphics-2.0-amd64:graphics-2.0-noarch:graphics-3.2-amd64:graphics-3.2-noarch:graphics-4.0-amd64:graphics-4.0-noarch
#Distributor ID: SUSE LINUX
#Description:    openSUSE 11.2 (x86_64)
#Release:        11.2
#Codename:       n/a
#LSB Version:    :core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:desktop-3.1-amd64:desktop-3.1-noarch:desktop-3.2-amd64:desktop-3.2-noarch
#Distributor ID: Fedora
#Description:    Fedora release 12 (Constantine)
#Release:        12
#Codename:       Constantine
#LSB Version:    n/a
#Distributor ID: Gentoo
#Description:    Gentoo Base System release 1.12.13
#Release:        1.12.13
#Codename:       n/a
#No LSB modules are available.
#Distributor ID: Debian
#Description:    Debian GNU/Linux unstable (sid)
#Release:        unstable
#Codename:       sid
#LSB Version:    :core-3.0-amd64:core-3.0-ia32:core-3.0-noarch:graphics-3.0-amd64:graphics-3.0-ia32:graphics-3.0-noarch 
#Distributor ID: RedHatEnterpriseWS
#Description:    Red Hat Enterprise Linux WS release 4 (Nahant Update 4)
#Release:        4
#Codename:       NahantUpdate4
#LSB Version:    :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch
#Distributor ID: RedHatEnterpriseClient
#Description:    Red Hat Enterprise Linux Client release 5 (Tikanga)
#Release:        5
#Codename:       Tikanga
#LSB Version:    core-2.0-noarch:core-3.0-noarch:core-2.0-x86_64:core-3.0-x86_64:desktop-3.1-amd64:desktop-3.1-noarch:graphics-2.0-amd64:graphics-2.0-noarch:graphics-3.1-amd64:graphics-3.1-noarch
#Distributor ID: SUSE LINUX
#Description:    SUSE Linux Enterprise Desktop 10 (x86_64)
#Release:        10
#Codename:       n/a
#No LSB modules are available.
#Distributor ID: Ubuntu
#Description:    Ubuntu 7.04
#Release:        7.04
#Codename:       feisty


#emerge  lsb-release
#yum install redhat-lsb
#apt-get install lsb-release
#comando: lsb_release -a
#lsb_release -i
#ututo-get install lsb-release

#echo LSBREL $LSBREL
#if test -x "$LSBREL"; then




#Mejor instalar lsb_release en cada distro y listo
LSBVERSION=$(lsb_release -v  2>/dev/null | sed 's/LSB\ Version:\s\+//')
LSBDISTRO=$(lsb_release -i| awk -F: '{print $ 2}'| sed 's/\s\+//')
LSBDESC=$(lsb_release -d| awk -F: '{print $ 2}'| sed 's/\s\+//')
LSBRELEASE=$(lsb_release -r| awk -F: '{print $ 2}'| sed 's/\s\+//')
LSBCODENAME=$(lsb_release -c| awk -F: '{print $ 2}'| sed 's/\s\+//')



#fi
echo "export LSBVERSION=\"$LSBVERSION\""
echo "export LSBDISTRO=\"$LSBDISTRO\""
echo "export LSBRELEASE=\"$LSBRELEASE\""
echo "export LSBCODENAME=\"$LSBCODENAME\""
echo "export LSBDESC=\"$LSBDESC\""

# sacar descripcion del item y espacio, cut

     MEM=$(cat /proc/meminfo |awk '/MemTotal/ {print $ 2}')
  KERNEL=$(cat /proc/version |awk '{print $ 3}')
     GCC=$(cat /proc/version |awk '{print $ 7}')
  GCCDIA=$(cat /proc/version |awk '{print $ 8}')
    COMP=$(cat /proc/version |awk '{print $ 4}')
BOGOMIPS=$(cat /proc/cpuinfo |awk ' /bogomips/ {TOT=TOT+$ 3; } END {print TOT }')


#echo $NUMPRO:$TIPPRO:$MEM:$BOGOMIPS:$KERNEL:$COMP:$GCC:$GCCDIA:$DIST



echo "export NUMPRO=$NUMPRO"
echo "export TIPPRO=$TIPPRO"
echo "export TIPPROM=$TIPPROM"
echo "export MEM=$MEM"
echo "export BOGOMIPS=$BOGOMIPS"
echo "export KERNEL=$KERNEL"
echo "export GCC=$GCC"

