-
Notifications
You must be signed in to change notification settings - Fork 0
/
repo
executable file
·79 lines (73 loc) · 2.55 KB
/
repo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
SPAM=("http://" "ppa.launchpad.net/" "/ubuntu" ".com" "/deb")
ALL=(artful zesty yakkety
xenial wily vivid utopic trusty
saucy raring quantal precise
oneiric natty maverick lucid
karmic jaunty intrepid hardy
gutsy feisty edgy dapper
breezy hoary warty)
RELEASES=()
#RELEASES=(wily vivid utopic trusty)
# Remember that arrays start at 0. So "seq 0 3" is 4
# releases starting with the leftmost one in the array.
for i in `seq 0 3`; do RELEASES+=("${ALL[$i]}"); done
if [ -t 1 ]; then
ncolors=$(tput colors)
if test -n "$ncolors" && test $ncolors -ge 8; then
bold="$(tput bold)"
normal="$(tput sgr0)"
red="$(tput setaf 1)"
green="$(tput setaf 2)"
white="$(tput setaf 7)"
fi
fi
sourcesFiles=$(ls /etc/apt/sources.list.d/ | grep -v .save)
repositoryList=$(cd /etc/apt/sources.list.d && cat $sourcesFiles /etc/apt/sources.list | grep deb\ http.* | sed -e 's/.*help\.ubuntu\.com.*//' -e 's/^#.*//' -e 's/deb\ //' -e 's/deb-src\ //' -e '/^$/d' | sort -u | awk '{print $1"|"$2}' | sed -e 's/\/|/|/' -e 's/-[a-z]*$//' | uniq && cd)
for index in ${!RELEASES[@]}; do
printf "${white}${bold}${RELEASES[$index]^^}\t"
done
printf "REPOSITORY${normal}\n"
for repository in $repositoryList; do
setDistro="$(echo $repository | sed 's/.*|//')"
repoURL="$(echo $repository | sed 's/|.*//')"
availableDistros=$(curl --silent $repoURL/dists/ | grep -oi href\=\"[^\/].*/\" | sed -e 's/href\=\"//i' -e 's/\/\"//' -e 's/-.*//' -e 's/\ NAME.*//i' | sort -u | uniq)
if [ "$availableDistros" = "" ]; then
availableDistros=$(curl --silent $repoURL/ | grep -oi href\=\"[^\/].*\" | sed -e 's/href\=\"//i' -e 's/\/\"//' -e 's/-.*//' -e 's/\ NAME.*//i' -e 's/\/index\.html\"//' -e 's/.*".*//' -e 's/http.*//' | sort -u | uniq)
fi
foundCurrent=false
hadNo=false
for index in ${!RELEASES[@]}; do
if [[ $(echo "$availableDistros" | grep -oi "${RELEASES[$index]}") ]]; then
if [ "$setDistro" = "${RELEASES[$index]}" ]; then
foundCurrent=true
if [ $index == 0 -o "$hadNo" = true ]; then
printf "${green}[Yes]${normal}\t"
else
printf "[Yes]\t"
fi
else
if ! $foundCurrent; then
printf "${red}${bold}Yes${normal}\t"
else
printf "Yes\t"
fi
fi
elif [ "$availableDistros" = "" ]; then
printf "?\t" # For example the google chrome repo gives us a 404
else
hadNo=true
printf "No\t"
fi
done
for s in "${SPAM[@]}"; do
repoURL=${repoURL#$s}
repoURL=${repoURL%$s}
done
if [ "$foundCurrent" = true ]; then
printf "$repoURL\n"
else
printf "$repoURL (${white}$setDistro${normal})\n"
fi
done
printf "Thanks for all the fish.\n"