Perbarui :
Script sekarang memeriksa apakah ppa mendukung distro Anda, dan kemudian meminta konfirmasi jika Anda ingin menambahkan repo ke daftar sumber Anda dan hanya kemudian menginstal paket.
Gunakan ini dengan risiko Anda sendiri! Saya hanya menguji ini pada dua ppa! Saya tidak akan bertanggung jawab atas paket yang rusak!
kode:
#!/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/
pemakaian:
Tidak ada yang mendukung ppa
./support.sh ppa:m-gehre/ppa
saucy is not supported
didukung ppa
./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
....
Lihat skrip dalam aksi:
Memperbaikinya. Jawaban asli oleh Wilf