summaryrefslogtreecommitdiff
path: root/finde-dateien
blob: eeccfc9d9155ee6ba8d11c30e6fa946dd3c7b265 (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
#!/bin/bash

set -e

if [ $# -eq 0 ]
then
  $0 $(
    ls /usr/ports/distfiles | \
      grep '^wurzel-' | \
      sed 's|-[0-9.]\+\.tar\.bz2$||' | \
      sort -u
  ) > \
    "$(dirname "$0")/dateien"
  exit $?
elif [ $# -gt 1 ]
then
  for pkg in "$@"
  do
    echo "${pkg}"
  done | \
    parallel "$0"
  exit $?
fi

. "/usr/ports/deepthought/$1/Pkgfile"

beenden()
{
  if [ -n "${tmpDir}" ]
  then
    rm -rf "${tmpDir}"
  fi
  exit $1
}

tmpDir="$(mktemp -d)"

cd "${tmpDir}"
tar -xjf "/usr/ports/distfiles/${source##*/}"

dateien="$(
  find . -type f -exec basename {} \; | \
    sort
)"

if [ -n "$(echo "${dateien}" | uniq -d)" ]
then
  >&2 echo "Im Paket ${name} gibt es manche Dateinamen doppelt - soetwas kann ich nicht! Ich beende."
  beenden 1
fi

summen="$(
  find . -type f -exec sha512sum {} \; | \
    sed 's|^\(\S\+  \).*\(/[^/]*\)$|\\(^\1.*\2$\\)\\|' | \
    tr '\n' '|' | \
    sed 's@\\|$@@'
)"

matchExpr="$(
  echo "${dateien}" | \
    sed 's|^|-name |; s|$| -o|' | \
    tr '\n' ' ' | \
    sed 's| -o $||'
)"

ssh wurzel '
  find /usr/bin texmf M/texmf -xdev -type f -exec sha512sum {} \; 2> /dev/null
  find / . -xdev -type f \( '"${matchExpr}"' \) -exec sha512sum {} \; 2> /dev/null
' | \
  grep "${summen}" | \
  sort -u | \
  sed '
    /texmf\|bin/{
      s|^\(\S\+\)\s\+|\1 0 |;
      be;
    }
    /digital-server/{
      s|^\(\S\+\)\s\+|\1 1 |;
      be;
    }
    /[sS]tyles/{
      s|^\(\S\+\)\s\+|\1 2 |;
      be;
    }
    s|^\(\S\+\)\s\+|\1 3 |;
    :e
  ' | \
  sort | \
  uniq -m1 | \
  cut -d' ' -f3 | \
  sed 's|^\./||; s|^|'"${name}"':|' | \
  sort

beenden 0