Un script muy útil
- 6 Comentarios
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)
6 Comentarios en esta entrada
Trackbacks
-
superpiwi
dijo:
Que ganas de que llegue Feisty,Marzo 27th, 2007 at 5:29 am -
Osendo
dijo:
Muy bueno ,lo voy a probar esta tarde.Marzo 28th, 2007 at 4:45 am -
keogh
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 -
engerix
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 -
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 -
d_6_2
dijo:
Cuando la lista de paquetes esta completa,como seria el comando para instalarlas todas?Julio 10th, 2007 at 9:02 pm

















