From db02b4aa8839b57f2cccc34d177b5a8ec8ac0ef5 Mon Sep 17 00:00:00 2001 From: archcrack Date: Thu, 28 Jan 2021 22:26:45 -0300 Subject: [PATCH] v0.9.1: Fixed blacklists filter --- .SRCINFO | 4 +-- PKGBUILD | 4 +-- isfree | 97 ++++++++++++++++++++++++++++++++++++++------------------ 3 files changed, 71 insertions(+), 34 deletions(-) diff --git a/.SRCINFO b/.SRCINFO index 32cde72..c49a164 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -1,7 +1,7 @@ pkgbase = isfree pkgdesc = Check your Arch system for nonfree software - pkgver = 0.9.0 - pkgrel = 2 + pkgver = 0.9.1 + pkgrel = 1 url = https://github.com/leo-arch/isfree arch = any license = GPL2 diff --git a/PKGBUILD b/PKGBUILD index e774973..60d4d76 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,8 +1,8 @@ # Maintainer: archcrack pkgname=isfree -pkgver=0.9.0 -pkgrel=2 +pkgver=0.9.1 +pkgrel=1 pkgdesc="Check your Arch system for nonfree software" arch=(any) url="https://github.com/leo-arch/isfree" diff --git a/isfree b/isfree index 4bc43b1..e78d4c7 100644 --- a/isfree +++ b/isfree @@ -61,8 +61,8 @@ nc="" ### PROGRAM DATA ### ME="IsFree" -VERSION="0.9.0" -DATE="Jan 15, 2021" +VERSION="0.9.1" +DATE="Jan 28, 2021" AUTHOR="L. Abramovich" LICENSE="GPL2" WEBSITE="https://github.com/leo-arch/isfree" @@ -317,8 +317,24 @@ blacklist_line () local pack="$1" counter="$2" bl_line="" bl_line="$(/usr/bin/grep "^$pack:" -- "$tmp_file")" - - case "$bl_line" in +# bl_line="webkit2gtk:webkit2gtk::: depends of geoclue2" + +# if [[ $bl_line == *"depends"* ]]; then +# local pkg_dep="$(echo "$bl_line" \ +# | grep -o "depends".* | cut -d" " -f3)" +# if [[ $bl_line == *"$pkg_dep" ]]; then +# if [[ -z $pkg_dep || $(ls -d /var/lib/pacman/local/"$pkg_dep"* 2>/dev/null) ]]; then +# : +# else +# return -1 +# fi +# fi +# fi + + desc="$(echo "$bl_line" | cut -d":" -f 5-10)" + + case "$desc" in + *\[technical\]*|*\[branding\]*) echo -ne "$white$counter$nc) $green$pack: $nc" \ && (( technical++ )) @@ -339,23 +355,29 @@ blacklist_line () && (( fix_doc++ )) ;; - *) + "") echo -ne "$white$counter$nc) $blue$pack: $nc\n" \ && (( no_desc++ )) ;; + + *) + echo -ne "$white$counter$nc) $cyan$pack: $nc" \ + && (( no_tag++ )) + ;; esac # Get package description if [[ $nocolor -eq 0 ]]; then export GREP_COLORS="mt=1;36" - echo "$bl_line" | /usr/bin/cut -d":" -f5-10 \ - | /usr/bin/grep --color=always -- "\[technical\]\|\[branding\]\|\[nonfree\]\|\[semifree\]\|\[uses-nonfree\]\|\[recommends-nonfree\]\|\[FIXME description\]\|\[FIXME package\]" + if ! echo "$desc" | /usr/bin/grep --color=always -- "\[technical\]\|\[branding\]\|\[nonfree\]\|\[semifree\]\|\[uses-nonfree\]\|\[recommends-nonfree\]\|\[FIXME description\]\|\[FIXME package\]"; then + echo "$desc" + fi unset GREP_COLORS else - echo "$bl_line" | /usr/bin/cut -d":" -f5-10 + echo "$desc" fi } @@ -432,7 +454,7 @@ free_alternative () color_codes () { - local nonfree=$1 semifree=$2 technical=$3 fix_doc=$4 no_desc=$5 + local nonfree=$1 semifree=$2 technical=$3 fix_doc=$4 no_desc=$5 no_tag=$6 echo -e "\n${bold}Color codes:" @@ -459,9 +481,15 @@ color_codes () "description needs to be corrected ($fix_doc)." fi + if [[ $no_tag -gt 0 ]]; then + echo -e "${cyan}Cyan:$nc No" \ + "tag in the descrition of this package in" \ + "Parabola's blacklist ($no_tag)." + fi + if [[ $no_desc -gt 0 ]]; then - echo -e "${blue}Blue:$nc there is no" \ - "description of this package in" \ + echo -e "${blue}Blue:$nc No" \ + "description for this package in" \ "Parabola's blacklist ($no_desc)." fi } @@ -480,15 +508,15 @@ check_native () if [[ $full_bl -eq 0 ]]; then # By default, remove all branding and merely technical #+ non-free packs - /usr/bin/grep ":\[semifree\]\|:\[nonfree\]\|:\[uses-nonfree\]\|::::$" \ + /usr/bin/grep ":\[semifree\]\|:\[nonfree\]\|:\[uses-nonfree\]\|^[^[]*$" \ -- "$tmp_file" | /usr/bin/sudo -u "$user" /usr/bin/tee \ /tmp/parabola_bl_official 1>/dev/null || exit $ERROR tmp_file="/tmp/parabola_bl_official" fi - # NOTE: the "::::$" condition in grep is aimed to keep lines - #+ coming from the AUR blacklist + # NOTE: the "^[^[]*$" condition in grep is aimed to keep lines + #+ having no square brackets at all parabola_repo_download echo -ne "$blue::$nc$bold Getting installed native packages...$nc " @@ -504,20 +532,22 @@ check_native () local counter=0 - fix_doc=0; nonfree=0; semifree=0; technical=0; no_desc=0 + fix_doc=0; nonfree=0; semifree=0; technical=0; no_desc=0; no_tag=0; replacement_counter=0 # Compare blocks of 20 pkgs AT ONCE against the blacklist # This is fast! But there should be a still better solution for #+ this + mapfile -t non_free < <(for ((i=0; i<${#pkgs[*]}; i=$((i+20)))); do - /usr/bin/grep -- "^${pkgs[$i]}:\|^${pkgs[$((i+1))]}:\|^${pkgs[$((i+2))]}:\|^${pkgs[$((i+3))]}:\|^${pkgs[$((i+4))]}:\|^${pkgs[$((i+5))]}:\|^${pkgs[$((i+6))]}:\|^${pkgs[$((i+7))]}:\|^${pkgs[$((i+8))]}:\|^${pkgs[$((i+9))]}:\|^${pkgs[$((i+10))]}:\|^${pkgs[$((i+11))]}:\|^${pkgs[$((i+12))]}:\|^${pkgs[$((i+13))]}:\|^${pkgs[$((i+14))]}:\|^${pkgs[$((i+15))]}:\|^${pkgs[$((i+16))]}:\|^${pkgs[$((i+17))]}:\|^${pkgs[$((i+18))]}:\|^${pkgs[$((i+19))]}:" "$tmp_file" | /usr/bin/cut -d":" -f1 + /usr/bin/grep -- "^${pkgs[$i]}:\|^${pkgs[$((i+1))]}:\|^${pkgs[$((i+2))]}:\|^${pkgs[$((i+3))]}:\|^${pkgs[$((i+4))]}:\|^${pkgs[$((i+5))]}:\|^${pkgs[$((i+6))]}:\|^${pkgs[$((i+7))]}:\|^${pkgs[$((i+8))]}:\|^${pkgs[$((i+9))]}:\|^${pkgs[$((i+10))]}:\|^${pkgs[$((i+11))]}:\|^${pkgs[$((i+12))]}:\|^${pkgs[$((i+13))]}:\|^${pkgs[$((i+14))]}:\|^${pkgs[$((i+15))]}:\|^${pkgs[$((i+16))]}:\|^${pkgs[$((i+17))]}:\|^${pkgs[$((i+18))]}:\|^${pkgs[$((i+19))]}:" \ + "$tmp_file" | /usr/bin/cut -d":" -f1 done) for (( i=0; i<${#non_free[*]}; i++ )); do - blacklist_line "${non_free[$i]}" "$((i+1))" - free_alternative "${non_free[$i]}" + blacklist_line "${non_free[$i]}" "$((i+1))" + free_alternative "${non_free[$i]}" done counter=$i @@ -530,7 +560,7 @@ check_native () if [[ $nocolor -eq 0 ]]; then color_codes "$nonfree" "$semifree" "$technical" "$fix_doc" \ - "$no_desc" + "$no_desc" "$no_tag" fi echo -e "\n$nc${bold}Packages with no free/libre alternatives (yet):$nc" @@ -589,7 +619,7 @@ check_aur () get_blacklist "aur" if [[ $full_bl -eq 0 ]]; then - /usr/bin/grep "::::$\|:\[semifree\]\|:\[nonfree\]\|:\[uses-nonfree\]" \ + /usr/bin/grep "::::$\|:\[semifree\]\|:\[nonfree\]\|:\[uses-nonfree\]\|^[^[]*$" \ -- "$tmp_file" | /usr/bin/sudo -u "$user" /usr/bin/tee \ /tmp/parabola_bl_aur 1>/dev/null || exit $ERROR @@ -605,7 +635,7 @@ check_aur () echo -e "${green}OK$nc" echo -e "Non-free installed AUR packages:$nc\n" - counter=0; fix_doc=0; nonfree=0; semifree=0; technical=0; no_desc=0 + counter=0; fix_doc=0; nonfree=0; semifree=0; technical=0; no_desc=0; no_tag=0; mapfile -t non_free < <(for (( i=0; i<${#aur_packs[*]}; i=$((i+10)) )); do /usr/bin/grep -- "^${aur_packs[$i]}:\|^${aur_packs[$((i+1))]}:\|^${aur_packs[$((i+2))]}:\|^${aur_packs[$((i+3))]}:\|^${aur_packs[$((i+4))]}:\|^${aur_packs[$((i+5))]}:\|^${aur_packs[$((i+6))]}:\|^${aur_packs[$((i+7))]}:\|^${aur_packs[$((i+8))]}:\|^${aur_packs[$((i+9))]}:" \ @@ -625,7 +655,7 @@ check_aur () fi if [[ $nocolor -eq 0 ]]; then - color_codes "$nonfree" "$semifree" "$technical" "$fix_doc" "$no_desc" + color_codes "$nonfree" "$semifree" "$technical" "$fix_doc" "$no_desc" "$no_tag" fi echo -e "\n-------------" @@ -681,7 +711,7 @@ check_repo () if [[ $full_bl -eq 0 ]]; then # By default, remove all branding and merely technical #+ non-free packs - /usr/bin/grep ":\[semifree\]\|:\[nonfree\]\|:\[uses-nonfree\]" \ + /usr/bin/grep ":\[semifree\]\|:\[nonfree\]\|:\[uses-nonfree\]\|^[^[]*$" \ -- "$tmp_file" | /usr/bin/sudo -u "$user" /usr/bin/tee \ /tmp/parabola_bl_official 1>/dev/null || exit $ERROR @@ -693,7 +723,7 @@ check_repo () echo -e "Non-free packages in repository $nc${bold}[$repo]$nc:\n" nonfree_counter=0; alt_counter=0 - fix_doc=0; nonfree=0; semifree=0; technical=0; no_desc=0; + fix_doc=0; nonfree=0; semifree=0; technical=0; no_desc=0; no_tag=0; for (( i=0; i<${#pkgs[*]}; i=$((i+20)) )); do /usr/bin/grep -- "^${pkgs[$i]}:\|^${pkgs[$((i+1))]}:\|^${pkgs[$((i+2))]}:\|^${pkgs[$((i+3))]}:\|^${pkgs[$((i+4))]}:\|^${pkgs[$((i+5))]}:\|^${pkgs[$((i+6))]}:\|^${pkgs[$((i+7))]}:\|^${pkgs[$((i+8))]}:\|^${pkgs[$((i+9))]}:\|^${pkgs[$((i+10))]}:\|^${pkgs[$((i+11))]}:\|^${pkgs[$((i+12))]}:\|^${pkgs[$((i+13))]}:\|^${pkgs[$((i+14))]}:\|^${pkgs[$((i+15))]}:\|^${pkgs[$((i+16))]}:\|^${pkgs[$((i+17))]}:\|^${pkgs[$((i+18))]}:\|^${pkgs[$((i+19))]}:" "$tmp_file" @@ -739,7 +769,7 @@ check_repo () fi if [[ $nocolor -eq 0 ]]; then - color_codes "$nonfree" "$semifree" "$technical" "$fix_doc" "$no_desc" + color_codes "$nonfree" "$semifree" "$technical" "$fix_doc" "$no_desc" "$no_tag" fi echo -e "\nPackages with no free alternatives (yet):" @@ -779,6 +809,7 @@ check_privacy () echo -e "Non-secure packages installed in your system:$nc\n" counter=0; fix_doc=0; nonfree=0; semifree=0; technical=0; no_desc=0 + no_tag=0; mapfile -t nonpriv < <(for ((i=0; i<${#pkgs[*]}; i=$((i+20)))); do /usr/bin/grep -- "^${pkgs[$i]}:\|^${pkgs[$((i+1))]}:\|^${pkgs[$((i+2))]}:\|^${pkgs[$((i+3))]}:\|^${pkgs[$((i+4))]}:\|^${pkgs[$((i+5))]}:\|^${pkgs[$((i+6))]}:\|^${pkgs[$((i+7))]}:\|^${pkgs[$((i+8))]}:\|^${pkgs[$((i+9))]}:\|^${pkgs[$((i+10))]}:\|^${pkgs[$((i+11))]}:\|^${pkgs[$((i+12))]}:\|^${pkgs[$((i+13))]}:\|^${pkgs[$((i+14))]}:\|^${pkgs[$((i+15))]}:\|^${pkgs[$((i+16))]}:\|^${pkgs[$((i+17))]}:\|^${pkgs[$((i+18))]}:\|^${pkgs[$((i+19))]}:" \ @@ -786,11 +817,13 @@ check_privacy () done) for (( i=0; i<${#nonpriv[*]}; i++ )); do +# if blacklist_line "${nonpriv[$i]}" "$((i+1))" -ne -1; then blacklist_line "${nonpriv[$i]}" "$((i+1))" free_alternative "${nonpriv[$i]}" + (( counter++ )) +# fi done - counter=$i if [[ $counter -eq 0 ]]; then echo -e "\e[1A${green}[+]$nc None! You're free from privacy" \ "risking packages!" @@ -798,12 +831,14 @@ check_privacy () fi if [[ $nocolor -eq 0 ]]; then - color_codes "$nonfree" "$semifree" "$technical" "$fix_doc" "$no_desc" + color_codes "$nonfree" "$semifree" "$technical" "$fix_doc" "$no_desc" "$no_tag" fi echo -e "\n-------------" echo -e "${red}[-]$nc ${counter}/$(/usr/bin/pacman -Q | /usr/bin/wc -l)" \ "packages might be compromizing your privacy." + + echo -e "\n${bold}NOTE$nc: Suggested alternatives come from Parabola libre repositories" } ################################ @@ -1046,7 +1081,7 @@ check_pkg () if [[ $full_bl -eq 0 ]]; then - /usr/bin/grep ":\[semifree\]\|:\[nonfree\]\|:\[uses-nonfree\]" \ + /usr/bin/grep ":\[semifree\]\|:\[nonfree\]\|:\[uses-nonfree\]\|^[^[]*$" \ -- "$tmp_file" | /usr/bin/sudo -u "$user" /usr/bin/tee \ /tmp/parabola_bl_official 1>/dev/null @@ -1099,8 +1134,10 @@ check_pkg () export GREP_COLORS="mt=1;36" if [[ -n $desc ]]; then - echo "$desc" \ - | /usr/bin/grep --color=always "\[technical\]\|\[branding\]\|\[nonfree\]\|\[semifree\]\|\[uses-nonfree\]\|\[recommends-nonfree\]\|\[FIXME:description\]\|\[FIXME:package\]" + if ! echo "$desc" \ + | /usr/bin/grep --color=always "\[technical\]\|\[branding\]\|\[nonfree\]\|\[semifree\]\|\[uses-nonfree\]\|\[recommends-nonfree\]\|\[FIXME:description\]\|\[FIXME:package\]"; then + echo "$desc" + fi else echo "None" fi