Actualización :
La secuencia de comandos ahora comprueba si el ppa admite su distribución, y luego solicita confirmación si desea agregar el repositorio a su lista de fuentes y solo luego instala los paquetes.
¡Usa esto bajo tu propio riesgo! ¡Solo probé esto en dos ppa's! ¡No seré responsable por paquetes rotos!
código:
#!/bin/bash
#-----------------------------------------------
# Author : Imri Paloja
# Email : ****.******@*****.***
# HomePage : www.eurobytes.nl
# Version : 3.0
# Name : add-ppa
#-----------------------------------------------
# CHANGELOG
#
# 1. Asks for confirmation if ppa supports distro.
mkdir /tmp/add-ppa/
wget --quiet "http://ppa.launchpad.net/$(echo $1 | sed -e 's/ppa://g')/ubuntu/dists" -O /tmp/add-ppa/support.html
grep "$(lsb_release -sc)" "/tmp/add-ppa/support.html" >> /tmp/add-ppa/found.txt
cat /tmp/add-ppa/found.txt | sed 's|</b>|-|g' | sed 's|<[^>]*>||g' >> /tmp/add-ppa/stripped_file.txt
if [[ -s /tmp/add-ppa/stripped_file.txt ]] ; then
echo "$(lsb_release -sc) is supported"
read -p "Do you wish to install add the ppa to your source, and install the binaries [y/n] ?"
if [ "$REPLY" == "y" ] ; then
echo "Adding it to your sources list"
sudo add-apt-repository $1
echo "Refreshing your sources list"
sudo apt-get update
# Searching for the needed files, and installing them
wget --quiet "http://ppa.launchpad.net/$(echo $1 | sed -e 's/ppa://g')/ubuntu/dists/$(lsb_release -sc)/main/binary-amd64/Packages" -O /tmp/add-ppa/packages.html
grep "Package:" "/tmp/add-ppa/packages.html" >> /tmp/add-ppa/packages.txt
cat /tmp/add-ppa/packages.txt | sed ':a;N;$!ba;s/\n/ /g' >> /tmp/add-ppa/packages_stripped_file.txt
cat /tmp/add-ppa/packages_stripped_file.txt | sed 's|Package:||g' >> /tmp/add-ppa/packages_stripped_file2.txt
sudo apt-get install $(grep -vE "^\s*#" /tmp/add-ppa/packages_stripped_file2.txt | tr "\n" " ")
else
exit 0
fi
else
echo "$(lsb_release -sc) is not supported"
fi;
#Cleanup
rm -r /tmp/add-ppa/
uso:
Ninguno compatible con ppa
./support.sh ppa:m-gehre/ppa
saucy is not supported
ppa soportado
./support.sh ppa:banshee-team/ppa
saucy is supported
Do you wish to add the ppa to your sources list, and install the binaries [y/n] ??
Adding it to your sources list
...
Refreshing your sources list
...
sudo apt-get install
....
Ver el guión en acción:
Lo mejoré. Respuesta original de Wilf