forked from jonashackt/vagrant-github-actions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
report_v2.sh
executable file
·143 lines (134 loc) · 4.06 KB
/
report_v2.sh
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
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
if [ ! $# -eq 7 ]
then
echo "Usage: $0 OS STABLE FULL_LOG BUILD_LOG INFO_LOG KEY STAGE"
exit 1
else
OS=$1
STABLE=$2
FULL=$3
BUILD=$4
INFO=$5
KEY=$6
STAGE=$7
if [ ! -f "$FULL" ]; then
echo "$FULL does not exist."
exit 1
fi
if [ ! -f "$BUILD" ]; then
echo "$BUILD does not exist."
exit 1
fi
if [ ! -f "$INFO" ]; then
echo "$INFO does not exist."
exit 1
fi
fi
TITLE=$(grep -i -A 1 "Details might be found in the build log:" $FULL | tail -n1 | sed 's/.*portage\/\(.*\)\/temp.*/\1/')$(grep -i -A 1 "I tried running" $FULL | tail -n1 )
TITLE="$TITLE: bootstrap-prefix.sh $STAGE fails"
# EXTRAOS filters the OS name for the reports title, however we do include it in the title of the search!
EXTRAOS="unknown"
if [[ "$OS" == *"Microsoft"* ]] ; then
if [[ "$OS" == *"Linux"* ]] ; then
EXTRAOS="WSL"
else
EXTRAOS="Microsoft"
fi
fi
if [[ "$OS" == *"Linux"* ]] ; then
EXTRAOS="Linux"
fi
if [[ "$OS" == *"Darwin"* ]] ; then
EXTRAOS="Darwin"
fi
if [[ "$OS" == *"ubuntu"* ]] ; then
EXTRAOS="Ubuntu"
fi
if [[ "$OS" == *"centos"* ]] ; then
EXTRAOS="CentOS"
fi
if [[ "$OS" == *"Cygwin"* ]] ; then
EXTRAOS="Cygwin"
fi
if [[ "$os" == *"debian"* ]] ; then
extraos="Debian"
fi
if [[ "$os" == *"fedora"* ]] ; then
extraos="Fedora"
fi
if [[ "$os" == *"gentoo"* ]] ; then
extraos="Gentoo"
fi
# compress both logs with bz2
# TODO do we want to keept the uncompressed logs with -k ?
xz --compress -9e $FULL
xz --compress -9e $BUILD
FULL=$FULL.xz
BUILD=$BUILD.xz
# with explicit connection name to avoid missing default config error
BUGZ="bugz --key $KEY --config-file gentoo.conf --connection Gentoo"
##################
# Report the bug #
##################
# Search for existing bugs
$BUGZ search "$TITLE" -r "alexander@neuwirth-informatik.de" | tee bgo.out
echo "Failed: $TITLE"
TITLEBUG=$( grep -c "$TITLE" bgo.out )
if [ $TITLEBUG -ge 1 ] ; then
echo "found"
else
echo "not found"
fi
# We count with -c instead of -Fq due to cygwin... -> turned out to be a bug pybugz with windwos/cygwin
NOBUG=$( grep -c "Info: No bugs" bgo.out )
if [ $NOBUG -ge 1 ] ; then
echo "Reporting the bug"
# Post the bug
$BUGZ post \
--product "Gentoo/Alt" \
-a prefix@gentoo.org \
--component "Prefix Support" \
--version "unspecified" \
--title "$TITLE (on $EXTRAOS)" \
--op-sys "Linux" \
--platform "All" \
--priority "Normal" \
--severity "Normal" \
--alias "" \
--description-from "$INFO" \
--batch \
--default-confirm n \
--cc alexander@neuwirth-informatik.de \
| tee bgo.out
id=$(grep "Info: Bug .* submitted" bgo.out | sed 's/[^0-9]//g')
# Attach the logs
$BUGZ attach --content-type "application/x-xz" --description "" $id $FULL | tee bgo.out
$BUGZ attach --content-type "application/x-xz" --description "" $id $BUILD | tee bgo.out
else
echo "Bug exists"
#exit 1
# abort if multiple bugs reported
ONEBUG=$( grep -c "Info: 1 bug" bgo.out)
if [ $ONEBUG -ge 1 ]
then
# get bug id
id=$(cat bgo.out | tail -n2 | head -n1 | awk '{print $1}')
echo "Bug id: $id"
$BUGZ get "$id" | tee bgo.out
OSBUG=$(grep -c "$OS $STABLE prefix" bgo.out)
if [ $OSBUG -ge 1 ]
then
# already reportet for this OS
echo "Bug already reported for $OS $STABLE prefix"
else
echo "Adding message for $OS $STABLE prefix"
# add message fails for this os as well
$BUGZ modify --comment-from "$INFO" $id | tee bgo.out
# attach logs
$BUGZ attach --content-type "application/x-xz" --description "" $id $FULL | tee bgo.out
$BUGZ attach --content-type "application/x-xz" --description "" $id $BUILD | tee bgo.out
fi
else
echo "Multiple bugs found, aborting"
fi
fi