Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I often use the terminal to add a PPA to my resources list, only to find out afterwards that the PPA doesn't support my Ubuntu version, Allas, thus am greeted with a error:

404  Not Found

How can I check via terminal, if, the to be added ppa, supports my Ubuntu version?

share|improve this question
    
@Wilf, preferably. But, if there is no terminal option. Am willing to accept a gui solutions, after a decent amount of time. –  blade19899 Feb 19 at 19:32
    
I edited my answer with a working script ;) –  MrVaykadji Feb 19 at 20:58
    
@MrVaykadji, nice one. –  blade19899 Feb 19 at 21:13
add comment

4 Answers 4

A bash script to try a PPA for your distribution :

I just learned some bash for you haha. This works great, I'm proud (and thanks to Wilf for his answer)

#!/bin/bash
# usage : bash myscript ppa:something/something

# get list of ppa's supported distribution
wget http://ppa.launchpad.net/$(echo $1 | sed -e 's/ppa://g')/ubuntu/dists -O /tmp/test-ppa.tmp -q

# check if your release is in the downloaded list
RELEASE=`cat /tmp/test-ppa.tmp | grep $(lsb_release -sc)`
if [[ -n "$RELEASE" ]] ; then 
    echo "$1 will work with $(lsb_release -si) $(lsb_release -sr) $(lsb_release -sc)"
else 
    echo "$1 won't work with $(lsb_release -si) $(lsb_release -sr) $(lsb_release -sc)"
fi

# cleaning
rm /tmp/test-ppa.tmp

Usage :

1) Copy this in a text file somewhere (in the example below it's ~/myscript)

2) Use the command :

bash myscript ppa:something/something 

Note : you can also copy that script in /usr/bin/ folder with sudo cp ~/myscript /usr/bin/ppa-test && sudo chmod +x /usr/bin/ppa-test to use directly in command-lines :

ppa-test ppa:something/something


Example :

(here I used : ppa:libreoffice/ppa with ~/myscript)

ppa-check

Edit: updated with blade19899's idea of using lsb_release

share|improve this answer
    
Note : for french people, I did a fr-version with a help section and a dedicated topic : forum.ubuntu-fr.org/viewtopic.php?id=1504971 –  MrVaykadji Feb 19 at 23:35
add comment

Update:

The script now checks if the ppa supports your distro, and then aks for confirmation for if you want the add the repo to your sources list, and install the packages.

Use this at your own risk! I only tested this on two ppa's! I will not be held responsible for broken packages!

code:

#!/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/

usage:

None supported ppa's

./support.sh ppa:m-gehre/ppa
saucy is not supported

supported ppa's

./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
....

See the script in action:

Improved it. Original answer by Wilf

share|improve this answer
    
Also nice, but I recently (haha) learn that if [[ -n something]] is the bash command for "if something as an output", which help reduce the temporary files created. –  MrVaykadji Feb 19 at 21:18
    
@MrVaykadji don't fix what isn't broken! :D –  blade19899 Feb 19 at 21:24
    
Right haha ! Nb : I updated my answer with your lsb_release -sc idea, and even used it on the output ;) –  MrVaykadji Feb 19 at 21:33
    
@MrVaykadji, quick learner! xD –  blade19899 Feb 19 at 21:45
    
In my defense, I used to know some C and (most importantly) I took some classes of "programming principles", from there, I just had to google "how to do X in bash" and voilà. –  MrVaykadji Feb 19 at 22:26
show 3 more comments

I ain't tested it, but a script like this should work:

#!/bin/bash
echo "http://ppa.launchpad.net/$(echo $1 | sed -e 's/ppa://g')/ubuntu/dists"

You have to run this as ./SCRIPTNAME ppa:WHATEVER/WHATEVER - this one liner also works, but you have insert the PPA name (where ppa:gnome3-team/gnome3 is):

echo "http://ppa.launchpad.net/$(echo ppa:gnome3-team/gnome3 | sed -e 's/ppa://g')/ubuntu/dists"

You can then open the link in terminal (some terminals automatically show clickable links), or run it with curl to download it as text. It should just show the list of folders for the supported releases for the ppa.

I recently added a ppa, so I looked at that plus the Software and Updates thing and made a guess...

share|improve this answer
    
I should of mentioned, you have to run it as ./SCRIPTNAME ppa:WHATEVER/WHATEVER - it does seem to work though :) –  Wilf Feb 19 at 19:57
1  
Upvoted it does work! –  blade19899 Feb 19 at 21:14
add comment

Well I might have a GUI solution for you! The best way for me is PPA Manager:

sudo add-apt-repository ppa:webupd8team/y-ppa-manager
sudo apt-get update
sudo apt-get install y-ppa-manager

when you added ppa or ppas already added in your system, open PPA Manager and click manage ppas it will take you to new window with a list of ppas in your system click on any ppa and choose list packages below, if there be any packages available it will list if not you can delete it. Worked for me even yesterday I had ppa for Saucy and Trusty so list packages showed me "0" and I removed it :)

share|improve this answer
    
Yo dawg, I heard you wanted to check out a PPA, so there's a PPA to check your PPA :D –  MrVaykadji Feb 19 at 23:58
    
whatever the best :) –  JohnnyEnglish Feb 20 at 0:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.