summaryrefslogtreecommitdiff
path: root/find-deprecated-pkgs
blob: 8b9121149c56522744f872831c5552f5797f7990 (plain)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
# 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_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

# Parabola repos for checking blacklists like your-privacy,
# which sometimes block [libre] and [pcr] packages.
# [nonprism] and [nonsystemd] are not listened because
# we do not blacklists those packages anywhere
repos_parabola="pcr pcr-multilib pcr-multilib-testing pcr-testing libre libre-multilib libre-multilib-testing libre-testing"

# Set the blacklist files
# aur-blacklist.txt is not here since we want to check Arch's official repos
blacklists="blacklist.txt"

# List here files that may also blacklist Parabola packages.
# These are intended to be used with $repos_parabola
blacklists_parabola="your-initfreedom-blacklist.txt your-privacy-blacklist.txt your-freedom_emu-blacklist.txt"

# Mirrors. Please choose HTTPS over HTTP when possible
# x86_64 mirrors
for r in $repos_x86_64; do
  mirrors+=(https://mirrors.edge.kernel.org/archlinux/$r/os/x86_64/)
done
# i686 mirrors
for r in $repos_i686; do
  mirrors+=(https://mirror.archlinux32.org/i686/$r/)
done
# armv7h mirrors
for r in $repos_armv7h; do
  mirrors+=(https://fl.us.mirror.archlinuxarm.org/armv7h/$r/)
done

# Parabola mirrors, used to check [libre] and [pcr] packages
for r in $1 $2; do
if [[ $r = parabola ]]; then
for r in $repos_parabola; do
  mirrors+=(https://mirror.grapentin.org/parabola/$r/os/x86_64/)
  mirrors+=(https://mirror.grapentin.org/parabola/$r/os/i686/)
  mirrors+=(https://mirror.grapentin.org/parabola/$r/os/armv7h/)
done
fi
done

# Sed expresion tested for Nginx, change if needed
sedexp='s/.*href="//;s/\-any.pkg.tar.xz.*//;s/\-x86_64.pkg.tar.xz.*//;s/\-i686.pkg.tar.xz.*//;s/\-armv7h.pkg.tar.xz.*//'
# extra sedexps for special characters/symbols
sedexp+=';s/%2B/+/g;s/%3A/:/g;s/%40/@/g'

usage() {
cat <<EOM
Usage: ${0##*/} [arch|parabola]
Check if there are inexistent packages in the blacklists.

Arguments:
  arch                        Compares ArchLinux{32,ARM} blacklists
                              with their repositories
  parabola                    Compares Arch/Parabola blacklists (e.g.
                              your-privacy) with Parabola's and Arch's
                              repos

The 'parabola' argument compares with our repositories and Arch's
since in blacklists like your-privacy and your-initfreedom we also block
some packages from [pcr] (like jitsi) and [libre] (like icedove), and
probably also from their -multilib, -testing and -multilib-testing derivatives.

To easily remove a line, you can use the following sed expresion:

  sed '/^pkgname:/d' -i blacklist_file.txt
EOM
}

mkpkglist() {
  parabola_pkgs=$(mktemp)
  arch_pkgs=$(mktemp)
  case $1 in
        parabola) curl -s ${mirrors[@]} | grep '".*.pkg.tar.xz"' | sed $sedexp |
                  for f in $(cat /dev/stdin); do echo ${f%-*-*} >> $parabola_pkgs; done
        ;;
        arch) curl -s ${mirrors[@]} | grep '".*.pkg.tar.xz"' | sed $sedexp |
              for f in $(cat /dev/stdin); do echo ${f%-*-*} >> $arch_pkgs; done
        ;;
  esac
}

err() {
  printf '%s==> Error:%s %s\n' \
         "$(tput bold;tput setaf 1)" \
         "$(tput sgr0)" \
         "$1"
  false
}

msg() {
  printf '%s==>%s %s\n' \
         "$(tput bold;tput setaf 2)" \
         "$(tput sgr0)" \
         "$1"
}

submsg() {
  printf '  %s->%s %s\n' \
         "$(tput bold;tput setaf 4)" \
         "$(tput sgr0)" \
         "$1"
}

check(){
  mkpkglist $1
  case $1 in
        parabola) msg 'Comparing blacklists with Parabola packages ...'
                  pkgs=$(cut -d ":" -f 1 $blacklists_parabola | grep -v ^#)
                  for p in $pkgs; do
                    grep -xw ^$p$ $parabola_pkgs &> /dev/null || submsg "$p was not found"
                  done
                  msg 'done'
        ;;
        arch) msg 'Comparing blacklists with Arch packages ...'
              pkgs=$(cut -d ":" -f 1 $blacklists | grep -v ^#)
              for p in $pkgs; do
                grep -xw ^$p$ $arch_pkgs &> /dev/null || submsg "$p was not found"
              done
              msg 'done'
        ;;
        *) err "$1 is not a valid argument"
        ;;
  esac
}

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'
  for arg in $@; do check $arg; done
fi