summaryrefslogtreecommitdiff
path: root/compare-my-ports-to-others
blob: cab06b17da2096695e14bbe0587c0bc01fe297fb (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
#!/bin/bash

for pkg in $( \
  curl 'https://crux.eckner.net/REPO' 2> /dev/null | \
    grep '^d:' | \
    cut -d : -f 2
)
do
  inhalt="$( \
    curl "https://crux.nu/portdb/index.php?q=${pkg}&a=search" 2> /dev/null \
  )"
  echo "${inhalt}" | \
    grep -v '>deepthought<' | \
    grep -q '<td><a href="?a=repo&q=' \
  || continue

  for pkgfile in $( \
    echo "${inhalt}" | \
      tr '\n' ' ' | \
      sed 's|<tr>|\n<tr>|g' | \
      grep -v '>deepthought<' | \
      tr '"' '\n' | \
      grep 'Pkgfile$' \
  )
  do
    remPkgCont="$(
      wget -O - "${pkgfile}" 2> /dev/null
    )"
    numLinesDiff=$( \
      diff \
        <( \
          echo "${remPkgCont}" | \
            sed 's|^\s*||' | \
            sed 's|#.*$||' | \
            grep -v '^$'
        ) \
        <( \
          curl "https://crux.eckner.net/${pkg}/Pkgfile" 2> /dev/null | \
            sed 's|^\s*||' | \
            sed 's|#.*$||' | \
            grep -v '^$'
        ) | \
        grep -c '^[<>]' \
      )
    [ ${numLinesDiff} -ge 10 ] && echo "${pkg}: ${numLinesDiff}" && continue
    echo "${pkg} gibt es noch mal so ähnlich: ${pkgfile}"
    diff -u3 \
      <( \
        echo "${remPkgCont}" | \
          grep -v '^#' | \
          sed 's|^\s\+| |' \
      ) \
      <( \
        curl "https://crux.eckner.net/${pkg}/Pkgfile" 2> /dev/null | \
          grep -v '^#' | \
          sed 's|^\s\+| |' \
      )
  done

done