summaryrefslogtreecommitdiffstats
path: root/bin/dobuildlog
blob: 793daf20e7bfd920ccce3ff2b8dfc3ac0e08ad3b (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash -e
#
# Copyright © 2002 Rick Younie <rick@def.debian.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see
# <http://www.gnu.org/licenses/>.
#
#######################################################################

#
# craft a bug report or fail/success reply to a buildd log mail
# using vim, mutt and optionally quintuple-agent:
#   mutt
#		'f'orward the message
#       (may require autoedit & edit_headers .muttrc settings)
#   vim
#		map <F3> :%!~buildd/bin/dobuildlog agpg<CR>
#		map <S-F3> :%!~buildd/bin/dobuildlog gpg<CR>
#		map <F4> :%!~buildd/bin/dobuildlog bug<CR>

# these require setting by the user
SIGNOPTS='--clearsign --default-key younie@debian.org'
FROM="$EMAIL"	# "Your Name <your@addr.ess>"
ARCH=m68k		# for the bug report log link

print_header () {
    echo "From: $FROM"
    sed -n '
		/^-----/,/^Automatic/ {
			s/From: /To: /p
			s/^Subject: Log/Subject: Re: Log/p
		}'
    echo
}

fail_options () {
	cat << EOF
failed
 this one takes a comment,
 multi-line, indenting optional
dep-wait
  - usage: dep-wait some-package (>= version), another-package (>> version)
giveback
manual
newvers
not-for-us
purge
  - purges the source tree from the chroot
retry
upload-rem


EOF
}

success_fail () {
    STATUS=$(sed -n '/^-----/,/^Automatic/ s/^Subject: Log for \([^ ]*\) build .*/\1/p')

    case "$STATUS" in
	successful )
	    print_header
	    sed -n '/\.changes:$/,$ {
				/^Format: /,/^$/p
			}' |$SIGNPRG 2>/dev/null
	    ;;
	failed )
	    print_header
	    fail_options
	    sed -n '/^Automatic build of/,$p'
	    ;;
	* )
	    echo "..this doesn't appear to be a buildd success/fail message"
	    exit 1
	    ;;
    esac
}

bug_report () {
    PKG=$1
    VERS=$2

    cat << EOF
From: $FROM
To: submit@bugs.debian.org
Subject: $PKG_VERS: fails to build

Package: $PKG
Version: $VERS
Severity: serious

Hi,


EOF

    sed -n '/^Automatic build of/,/^Build needed/ s/^/| /p'
    cat <<EOF


The $ARCH build logs for $PKG can be found at
 http://buildd.debian.org/build.php?arch=$ARCH&pkg=$PKG


EOF
}

case "$1" in
    gpg | agpg )
	SIGNPRG="$1 $SIGNOPTS"
	success_fail
	exit 0
	;;
    bug )
	PKG_VERS=$(sed -n '/^-----/,/^Automatic/ s/^Subject: Log for \([^ ]*\) build of \([^ ]*\) .*/\2/p')
	bug_report $(echo "$PKG_VERS" |sed 's/_/ /')
	;;
    * )
	echo "Usage: $(basename $0) gpg|agpg|bug"
	exit 1
	;;
esac