summaryrefslogtreecommitdiff
path: root/fix-pinned-dependencies
blob: 3c7754d0d8a5ee3c89112364d71fcc4761253c28 (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
#!/bin/bash

if [ $# -ne 1 ] || [ ! -f "$1/PKGBUILD" ]; then
  printf 'usage: %s $pkg\n' "$0"
  exit 1
fi

diff=$(cat)

sed -i '
  /^_pinned_dependencies=(/,/^)/ {
    '"$(
      printf '%s\n' "${diff}" \
      | sed -n '
        s/^claimed\s\+//
        T
        s@[.*+]@[\0]@g
        s@.*@/^\\s*'"'"'\0=/d@
        p
      '
    )"'
  }
' "$1/PKGBUILD"

sed -i '
  /^_pinned_dependencies=(/ a '"$(
    printf '%s\n' "${diff}" \
    | sed -n '
      s/^actual\s\+//
      T
      p
    ' \
    | sed '
      $! s/$/\\/
    '
  )"'
' "$1/PKGBUILD"

./bumpPkgrel "$1"