7

I use a lot of PPA's. I'd like to check if all of them have packages for Saucy before updating.

Is there a program which checks whether my PPAs have packages for a different version of Ubuntu?

3 Answers 3

7

This can be scripted... It'll need altered versions of two of my previous answers: one to get a list of all the PPAs and another to check if a URL is live. With those two techniques we can build a real launchpad URL and test it.

dist="saucy"
ppas=$(grep -RoPish "ppa.launchpad.net/[^/]+/[^/ ]+" /etc/apt | sort -u)
while read -r ppa; do
    url="http://$ppa/ubuntu/dists/$dist/"
    if [[ $(wget -O /dev/null "$url" 2>&1|grep "200 OK"|wc -l) == "0" ]]; then
        echo "$ppa does not have a $dist version"
    fi
done <<< "$ppas"

It's an ugly script but it's so beautiful at the same time.

2
  • 1
    Very nice (takes a while, though). If this is ugly then the script I was working on was downright horrible. Thanks!
    – kiri
    Oct 25, 2013 at 23:23
  • Hm, it was quite fast here. Took 1.9 seconds for 27 PPAs.
    – Oli
    Oct 25, 2013 at 23:26
2

With the inspiration of @Oli's answer and what I shared here, I've put some scripts together to validate existing PPAs as well as validating given PPA / URL before they are added.

check_all_ppa_validity also returns a list of failed PPAs, so, these can be removed/disabled if desired.

#!/bin/bash

COL_RED="\e[31m"
COL_GRN="\e[32m"
COL_YEL="\e[33m"
COL_BLU="\e[34m"
COL_MAG="\e[35m"
COL_DFL="\e[39m"

function func_print_ok_message() {
    echo -e "${COL_GRN}`date +"%D-%T"` ok  :${COL_DFL} ""$1" | tee -a install.log
}

function func_print_fail_message() {
    echo -e "${COL_RED}`date +"%D-%T"` fail:${COL_DFL} ""$1" | tee -a install.log
}

function func_print_warn_message() {
    echo -e "${COL_YEL}`date +"%D-%T"` warn:${COL_DFL} ""$1" | tee -a install.log
}

function func_print_info_message() {
    echo -e "${COL_BLU}`date +"%D-%T"` warn:${COL_DFL} ""$1" | tee -a install.log
}

function func_print_dbg_message() {
    if [ ! -z "$BASH_GEN_DBG" ]; then
    echo -e "${COL_MAG}`date +"%D-%T"` warn:${COL_DFL} ""$1" | tee -a install.log
    fi
}

function add_ppa() {
  local __ppa_name=""
  for __ppa_name_to_check in "$@"; do
    grep -h "^deb.*$__ppa_name_to_check" /etc/apt/sources.list.d/* > /dev/null 2>&1
    if [ "$?" != "0" ]
    then
        local __is_ppa_valid=""
        check_if_ppa_is_valid "__is_ppa_valid" "$__ppa_name_to_check"
        if [ "$__is_ppa_valid" == "0" ]; then
            echo "Adding ppa:$__ppa_name_to_check"
            sudo add-apt-repository -y ppa:$__ppa_name_to_check
            func_print_ok_message "add_ppa: $__ppa_name_to_check"
        else
            func_print_fail_message "add_ppa: $__ppa_name_to_check"
        fi
    else
        func_print_info_message "repo already exists ppa:$__ppa_name_to_check"
    fi
  done
}

function check_all_ppa_validity() {
    local __invalid_ppa_list=()
    for __ppa_to_chk in `grep -RoPish "ppa.launchpad.net/[^/]+/[^/ ]+" /etc/apt | sort -u | uniq | cut -d"/" -f2-`; do
        check_if_ppa_is_valid "__is_ppa_valid" "$__ppa_to_chk"
        if [ "$__is_ppa_valid" == "0" ]; then
            func_print_ok_message "check_ppa: $__ppa_to_chk"
        else
            func_print_fail_message "check_ppa: $__ppa_to_chk"
            __invalid_ppa_list+=("$__ppa_to_chk")
        fi
    done
    eval "$1=(${__invalid_ppa_list[*]})"
}

function check_if_ppa_is_valid() {
    local __ppa_name="$2"
    local __ppa_prefix=$(echo $__ppa_name | cut -d"/" -f1)
    local __ppa_suffix=${__ppa_name##*/}
    curl -fsSL https://launchpad.net/~"$__ppa_prefix"/+archive/ubuntu/"$__ppa_suffix" &>/dev/stdout | grep "\"`lsb_release -sc`\"" -m1 >/dev/null 2>&1
    eval "$1=\"$?\""
}

# example use
add_ppa "wireshark-dev/stable"
add_to_sources_list "http://gb.archive.ubuntu.com/ubuntu/" "multiverse"
check_if_ppa_is_valid is_valid "wireshark-dev/stable"
check_all_ppa_validity invalid_ppa_list && echo "invalid ppas: ${invalid_ppa_list[@]}"

This and more is available on this repo, under post_install/common_bash_funcs.sh.

1

I don't know of any software to do that, but from the PPA's webpage it is easy to check, by deploying the list in section "Overview of published packages" (see the image below).

published packages

Click to see a higher-resolution image.

If you use really a lot of PPAs, this can get tiring.

Perhaps an internet crawling script might help? With that I couldn't help you much, though.

Image taken from this Q&A in ask.libreoffice.org.

2
  • Yes, that's an option but I do have a lot of PPA's. I might write a script myself for this. Thanks for your help.
    – kiri
    Oct 25, 2013 at 22:50
  • 1
    Please share your script when you are done!
    – carnendil
    Oct 25, 2013 at 22:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .