summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid P <megver83@parabola.nu>2018-09-05 15:04:54 -0300
committerDavid P <megver83@parabola.nu>2018-09-05 15:04:54 -0300
commit402bdfe3d33ebc6d31c003ce7d700c6a0b45cdcc (patch)
treee80de056b4c95420e6a48b0f688997c507c3fde6
parentdb4d302c52870197ae7b0a01ec258c63a14e2d4b (diff)
find-deprecated-pkgs: be more precise
Signed-off-by: David P <megver83@parabola.nu>
-rwxr-xr-xfind-deprecated-pkgs98
1 files changed, 69 insertions, 29 deletions
diff --git a/find-deprecated-pkgs b/find-deprecated-pkgs
index 086d017..246369e 100755
--- a/find-deprecated-pkgs
+++ b/find-deprecated-pkgs
@@ -2,11 +2,9 @@
# Copyright (C) 2018 David P. <megver83@parabola.nu>
# Find deprecated Arch packages that are still in our blacklists.
-set -e
-
# Repositories for specific arch'es.
# Common repos are in 'repos' variable.
-repos="core extra community"
+repos="core community extra"
repos_x86_64="$repos testing multilib multilib-testing"
repos_i686="$repos testing build-support"
repos_armv7h="$repos alarm" # although we don't sync [alarm] we blacklist its packages to conflict with your-freedom
@@ -94,6 +92,7 @@ mkpkglist() {
done
done
cat $parabola_pkgs-{x86_64,i686,armv7h,any} | sort -u > $parabola_pkgs
+ rm $parabola_pkgs-{x86_64,i686,armv7h,any}
;;
arch) curl -s ${mirrors[@]} | grep '".*.pkg.tar.xz"' | sed $sedexp > $arch_pkgs
@@ -104,6 +103,7 @@ mkpkglist() {
done
done
cat $arch_pkgs-{x86_64,i686,armv7h,any} | sort -u > $arch_pkgs
+ rm $arch_pkgs-{x86_64,i686,armv7h,any}
;;
esac
}
@@ -113,7 +113,7 @@ err() {
"$(tput bold;tput setaf 1)" \
"$(tput sgr0)" \
"$1"
- false
+ exit 1
}
msg() {
@@ -128,12 +128,10 @@ submsg() {
"$(tput bold;tput setaf 4)" \
"$(tput sgr0)" \
"$1"
+ out=x
}
-compare_pkgs(){
- # $1 is the pkgname and replacement (used when checking Arch pkgs)
- # $2 is the packages file list
-
+get_libre_pkgs() {
# We'll use this when we check Arch's pkgs only
if ! [[ -e $libre_pkgs ]]; then
libre_pkgs=$(mktemp)
@@ -142,7 +140,7 @@ compare_pkgs(){
mirrors_parabola+=(https://mirror.grapentin.org/parabola/$r/os/i686/)
mirrors_parabola+=(https://mirror.grapentin.org/parabola/$r/os/armv7h/)
done
- curl -s ${mirrors[@]} | grep '".*.pkg.tar.xz"' | sed $sedexp > $libre_pkgs
+ curl -s ${mirrors_parabola[@]} | grep '".*.pkg.tar.xz"' | sed $sedexp > $libre_pkgs
for arch in x86_64 i686 armv7h any; do
grep $arch$ $libre_pkgs | for f in $(</dev/stdin); do
echo "${f%-*-*-*} $arch" >> $libre_pkgs-$arch
@@ -150,16 +148,23 @@ compare_pkgs(){
done
cat $libre_pkgs-{x86_64,i686,armv7h,any} | sort -u > $libre_pkgs
fi
+}
+
+compare_pkgs(){
+ # $1 is the pkgname and replacement (used when checking Arch pkgs)
+ # $2 is the packages file list
# First check if the pkg is available for
# a specific architecture, if not, check
# if it's for 'any'
package="${1%%:*}"
- replacement="$(cut -d ":" -f1 <(echo $1))"
+ replacement="$(cut -d ":" -f2 <(echo $1))"
+
for arch in x86_64 i686 armv7h; do
grep $arch$ $2 | awk '{print $1}' | grep -xw ^$package &> /dev/null || \
grep any$ $2 | awk '{print $1}' | grep -xw ^$package &> /dev/null || \
if [ $2 = $arch_pkgs ]; then
+ get_libre_pkgs
# Check if the package has a replacement, and
# if such replacement is available for the same
# architectures
@@ -167,8 +172,14 @@ compare_pkgs(){
# If this works, it means the pkg doesn't exist for $arch in Arch,
# but we have the [libre] replacement which should be deprecated.
grep $arch$ $libre_pkgs | awk '{print $1}' | grep -xw ^$replacement &> /dev/null || \
- grep any$ $libre_pkgs | awk '{print $1}' | grep -xw ^$replacement &> /dev/null && \
- to_be_removed+=($arch) || is_not_for+=($arch)
+ grep any$ $libre_pkgs | awk '{print $1}' | grep -xw ^$replacement &> /dev/null
+
+ case $? in
+ 0) to_be_removed+=($arch)
+ ;;
+ *) is_not_for+=($arch)
+ ;;
+ esac
else
# However if this fails, it means the pkg doesn't have a replacement
# for $arch, or it simply doesn't have a replacement.
@@ -178,48 +189,77 @@ compare_pkgs(){
if ! [[ $replacement = "" ]]; then
# Look for the replacement
grep $arch$ $parabola_pkgs | awk '{print $1}' | grep -xw ^$replacement &> /dev/null || \
- grep any$ $parabola_pkgs | awk '{print $1}' | grep -xw ^$replacement &> /dev/null && \
- to_be_deleted+=($arch) || isnt_for+=($arch)
+ grep any$ $parabola_pkgs | awk '{print $1}' | grep -xw ^$replacement &> /dev/null
+
+ case $? in
+ 0) to_be_deleted+=($arch)
+ ;;
+ *) isnt_for+=($arch)
+ ;;
+ esac
else
isnt_for+=($arch)
fi
fi
done
- for arch in ${to_be_removed[@]}; do
- submsg "$p ($arch) was not found, but we've a [libre] replacement which should be removed"
- done
-
- for arch in ${to_be_deleted[@]}; do
- submsg "$p ($arch) was not found, but we've $replacement as replacement and should be removed"
- done
-
+ # Arch
if [[ ${is_not_for[@]} = "x86_64 i686 armv7h" ]]; then
- submsg "$p was not found"
+ submsg "$package was not found"
+ elif [[ ${to_be_removed[@]} = "x86_64 i686 armv7h" ]]; then
+ submsg "$package was not found, but we've [libre] replacements which should be removed"
+ elif ! [[ ${is_not_for[@]} = "" ]] || ! [[ ${to_be_removed[@]} = "" ]]; then
+ for arch in ${to_be_removed[@]}; do
+ # If the replacement is available for the three arch'es supported
+ # by Parabola, then shut up
+ for a in x86_64 i686 armv7h; do
+ grep -xw "^$replacement $a$" $libre_pkgs &> /dev/null && arches+=($a)
+ done
+ if ! [[ ${arches[*]} = "x86_64 i686 armv7h" ]]; then
+ submsg "$package ($arch) was not found, but we've a [libre] replacement which should be removed"
+ fi
+ unset arches
+ done
fi
+ # Parabola
if [[ ${isnt_for[@]} = "x86_64 i686 armv7h" ]]; then
- submsg "$p was not found"
+ submsg "$package was not found"
+ elif ! [[ ${isnt_for[@]} = "" ]]; then
+ for arch in ${to_be_deleted[@]}; do
+ submsg "$package ($arch) was not found, but we've $replacement as replacement and should be removed"
+ done
fi
+
+ # Unset the variables so they can be re-used
+ unset to_be_deleted
+ unset to_be_removed
+ unset is_not_for
+ unset isnt_for
+ unset arch
+ unset package
+ unset replacement
}
check(){
mkpkglist $1
case $1 in
parabola) msg 'Comparing blacklists with Parabola packages ...'
- pkgs=$(cut -d ":" -f1 $blacklists_parabola | grep -v ^#)
+ pkgs=$(for bl in $blacklists_parabola; do grep -v ^# $bl | awk '{print $1}'; done)
for p in $pkgs; do
compare_pkgs $p $parabola_pkgs
done
- rm -f $parabola_pkgs
+ rm -f $parabola_pkgs $libre_pkgs
+ if [[ $out = x ]]; then submsg 'The blacklist matches all packages correctly'; fi
msg 'done'
;;
arch) msg 'Comparing blacklists with Arch packages ...'
- pkgs=$(grep -v ^# $blacklists | awk '{print $1}')
+ pkgs=$(for bl in $blacklists; do grep -v ^# $bl | awk '{print $1}'; done)
for p in $pkgs; do
compare_pkgs $p $arch_pkgs
done
- rm -f $arch_pkgs
+ rm -f $arch_pkgs $libre_pkgs
+ if [[ $out = x ]]; then submsg 'The blacklist matches all packages correctly'; fi
msg 'done'
;;
*) err "$1 is not a valid argument"
@@ -231,6 +271,6 @@ if [[ $@ = "" ]]; then
usage
else
ip r | grep ^default | awk '{print $3}' |
- ping -q -w 1 -c 1 $(tail -n1 /dev/stdin) &> /dev/null || err 'You must have internet connection to run this program'
+ ping -q -w1 -c1 $(tail -n1 /dev/stdin) &> /dev/null || err 'You must have internet connection to run this program'
for arg in $@; do check $arg; done
fi