summaryrefslogtreecommitdiff
path: root/openttd-git/update-patches
blob: 7b2e04b9d254ee929088265458d901c3f9be0caf (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
#!/bin/bash

cd "$(dirname "$0")"
eval "$(
  sed -n '
    /^source=(/,/)/ p
  ' PKGBUILD
)"

makepkg --verifysource
git -C openttd-git fetch local
git -C openttd-git fetch --all -p

sums=$(
  {
    printf '%s\n' "${source[@]}" \
      | sed '
        s/\.patch$//
        t
        s/^.*$/SKIP/
        w /dev/stderr
        d
      ' \
      | while read -r patch; do
        git -C openttd-git diff $(git -C openttd-git merge-base master "remotes/local/${patch}") "remotes/local/${patch}" -- \
          > "${patch}.patch"
        sha512sum "${patch}.patch" | \
          awk '{print $1}'
      done
  } 2>&1 \
    | sed '
      s/^/'"'"'/
      s/$/'"'"'/
      1  s/^/sha512sums=(/
      1! s/^/            /
      $  s/$/)/
    ' \
    | sed '
      :a
        N
        $! ba
      s/\n/\\n/g
    '
)

sed -i '
  /^sha512sums=(/,/^[^#]*)$/ {
    s/^sha512sums=(.*$/'"${sums}"'/
    t
    d
  }
' PKGBUILD