Mar 26 2007

Un script muy útil

Ya tenemos encima la salida de Feisty, y muchos preferimos hacer una instalación limpia en vez de actualizar. Lo que hace este script es crear una lista de todos los paquetes instalados desde el inicio de tu (*)Ubuntu. Además nos da a elegir si queremos que nos liste también las librerá­as ya que la mayorí­a de estas son dependencias de los programas principales. Como salida podemos optar por un archivo de texto con el listado de todas nuestras aplicaciones.

 

Para usar el script, abrimos una terminal y escribimos:

gedit paquetes_instalados

Para Kubuntu remplazar gedit por kate Al abrirse gedit o kate copiamos lo siguiente:

#!/bin/bash

#Ask for version to set DESKTOP
while [ "$answer" != "ubuntu" ] && [ "$answer" != "kubuntu" ] && [ "$answer" != "xubuntu" ]; do
	echo "Was your install cd ubuntu, kubuntu, or xubuntu (type out exactly)?"
        read answer
done

#Get the installed packages
INSTALLED_PACKAGES=$(ls /var/lib/dpkg/info | grep .list | sed 's/.list//')

#Get date of minimal and use that to find untouched packages
INSTALL_DATE=$(ls -l /var/lib/dpkg/info | grep ubuntu-minimal.list | awk '{print $6}')
BASE_PKG=$(ls -l /var/lib/dpkg/info | grep $INSTALL_DATE | awk '{print $8}' | sed 's/.list//g')

#Get the dependencies of the meta packages used during install
STANDARD=$(apt-cache show ubuntu-standard | grep -E ^Depends | sed 's/^Depends: //' |
sed 's/, /n/g' | sed 's/ | /n/g')
MINIMAL=$(apt-cache show ubuntu-minimal | grep -E ^Depends | sed 's/^Depends: //' |
sed 's/, /n/g' | sed 's/ | /n/g')
DESKTOP=$(apt-cache show $answer"-desktop" | grep -E ^Depends | sed 's/^Depends: //' |
sed 's/, /n/g' | sed 's/ | /n/g')

#Set up the grep strings (what a stupid way to do this)
GREP_STRING=$(for x in $(echo $BASE_PKG) $(echo $STANDARD) $(echo $MINIMAL)
$(echo $DESKTOP) ; do echo "$x|" ; done)
CLEAN_GREP=$(echo $GREP_STRING | sed 's/ //g' | sed "s/|$/'/" | sed "s/^/'/")

# Find the new packages and setup nolib
NEW_PACKAGES=$(echo "$INSTALLED_PACKAGES" | grep -Evw $CLEAN_GREP)
NOLIB=$(echo "$NEW_PACKAGES" | grep -Ev ^lib)

# Ask for libraries or no libraries and output file or not
while [ "$choice" != "y" ] && [ "$choice" != "n" ]; do
	echo "Do you want to include libraries in the results (y/n)?"
        read choice
done

if [ "$choice" = "y" ] ; then
	OUTPUT=$(echo -e "$NEW_PACKAGES")
else
	OUTPUT=$(echo -e "$NOLIB")
fi

while [ "$input" != "y" ] && [ "$input" != "n" ]; do
	echo "Do you want to output the package list to a text file (y/n)?"
        read input
done

if [ $input = "n" ] ; then
	echo "$OUTPUT"
else
	echo -e "What should the name of the file be?n(Make sure you can write
to it and make sure the path exists)"
	read file
	if [ "${file%%/*}" = "~" ] ; then
		file="/home/$(whoami)$(echo $file | sed 's/~//')"
	fi
echo "$OUTPUT" > $file
fi
exit

Después grabamos y cerramos. Volvemos a la Terminal y escribimos:

chmod +x paquetes_instalados

y luego para poder correr el script entramos:

./paquetes_instalados

Ahora solo hay que contestarle al prompt, cuando nos pregunta que CD usamos al instalar : (ubuntu, kubuntu o xubuntu)

 

Si deseamos listar también las librerí­as (y,n)

 

Si queremos crar un archivo de texto con la lista de paquetes (y,n)

 

Y por último darle un nombre al archivo a crear (Ej. paquetes.txt)

ETIQUETAS:

6 Comentarios en esta entrada

Trackbacks

  1. superpiwiNo Gravatar dijo:


    Que ganas de que llegue Feisty,

    Marzo 27th, 2007 at 5:29 am
  2. OsendoNo Gravatar dijo:


    Muy bueno ,lo voy a probar esta tarde.

    Marzo 28th, 2007 at 4:45 am
  3. keoghNo Gravatar dijo:


    Que tiene de malo la actualización? en lugar de instalar todo de cero?

    Buen script.

    s4lu2

    Marzo 31st, 2007 at 3:01 pm
  4. engerixNo Gravatar dijo:


    No tiene nada de malo la actualización. Solo que yo tengo mi /home en una partición diferente y prefiero hacer una instalación limpia y después desde Synaptic agregar todos los paquetes que me tira el script.

    Marzo 31st, 2007 at 3:34 pm
  5. Anonimous dijo:


    Cuando selecciono la distribución me arroja el siguiente mensaje. aunque al final parece funcionar bien:

    ./paquetes_instalados: command substitution: line 27: error de sintaxis cerca de token no esperado `$(echo $DESKTOP)’
    ./paquetes_instalados: command substitution: line 27: `$(echo $DESKTOP) ; do echo “$x|” ; done’

    Abril 12th, 2007 at 1:23 pm
  6. d_6_2No Gravatar dijo:


    Cuando la lista de paquetes esta completa,como seria el comando para instalarlas todas?

    Julio 10th, 2007 at 9:02 pm

DEJAR UN COMENTARIO

Subscribe Form

Suscríbete al Blog

Sponsors

Para poner tu banner aquí, Contáctame
Banners disponibles: 2

MyBlogLog

JOIN MY COMMUNITY!