summaryrefslogtreecommitdiff
path: root/generate-bug-report
blob: e59935282b6ff325b9eb35758b1153b7319ac779 (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
#!/bin/bash

git pull --ff-only || exit $?

if ! diff -u PKGBUILD ../../trunk/PKGBUILD; then
  >&2 echo "trunk differs - say something and I won't create a bug report."
  read -r s
  if [ -n "$s" ]; then
    exit
  fi
fi

if ! git archive HEAD -- PKGBUILD | tar -Ox | diff -u --color - PKGBUILD; then
  >&2 echo "PKGBUILD differs from git - say something and I won't create a bug report."
  read -r s
  if [ -n "$s" ]; then
    exit
  fi
fi

git_revision=$(
  git rev-parse HEAD
)

if ! makepkg_info=$(makepkg --verifysource 2>&1); then
  bug_report=$(
    makepkg --verifysource 2>&1
  )
  fail_command='makepkg --verifysource'
else
  >&2 echo 'Nothing wrong with upstream'"'"'s source - should I try to build? (empty="yes")'
  read -r s
  if [ -n "$s" ]; then
    exit
  fi
  {
    extra-x86_64-build 2>&1
    echo $?
  } | \
    tee log.x86_64
  error=$(
    sed -i '
      $ {
        w /dev/stdout
        d
      }
    ' log.x86_64
  )
  if [ "${error}" = '0' ]; then
    >&2 echo 'Builds fine on x86_64.'
    exit
  fi
  bug_report='extra-x86_64-build fails with:'
  fail_command='extra-x86_64-build'
  log='full log is attached'
  log_file=$(readlink -f 'log.x86_64')
fi

printf 'Bug report:\n\n'
printf 'Description:\n\n'
printf '%s\n' "${bug_report}"
printf 'Additional info:\n'
printf '* package version(s)\n'
printf '%s\n' \
  "${makepkg_info}" | \
  sed -n '
    s/^==> Making package: \(\S\+ \S\+\) (.*$/\1/
    T
    p
  ' | \
  tr -d '\n'
printf ' (git revision %s)\n' \
  "${git_revision}"
if [ -n "${log}" ]; then
  printf '* config and/or log files etc.\n'
  printf '%s\n' "${log}"
fi
printf '\n'
printf 'Steps to reproduce:\n'
printf '> git checkout %s\n' \
  "${git_revision}"
printf '> cd %s\n' \
  "$(
    pwd | \
      sed '
        s,^.*/\([^/]\+/repos/[^/]\+\)$,\1,
      '
  )"
printf '> %s\n' "${fail_command}"
if [ -n "${log_file}" ]; then
  printf '\nupload: %s\n' "${log_file}"
fi