| @@ -1,15 +1,15 @@ | | | @@ -1,15 +1,15 @@ |
1 | #!@AWK@ -f | | 1 | #!@AWK@ -f |
2 | # $NetBSD: create-report-html.awk,v 1.10 2008/04/07 19:41:07 joerg Exp $ | | 2 | # $NetBSD: create-report-html.awk,v 1.11 2008/06/11 19:27:03 joerg Exp $ |
3 | # | | 3 | # |
4 | # Copyright (c) 2007, 2008 Joerg Sonnenberger <joerg@NetBSD.org>. | | 4 | # Copyright (c) 2007, 2008 Joerg Sonnenberger <joerg@NetBSD.org>. |
5 | # All rights reserved. | | 5 | # All rights reserved. |
6 | # | | 6 | # |
7 | # This code was developed as part of Google's Summer of Code 2007 program. | | 7 | # This code was developed as part of Google's Summer of Code 2007 program. |
8 | # | | 8 | # |
9 | # Redistribution and use in source and binary forms, with or without | | 9 | # Redistribution and use in source and binary forms, with or without |
10 | # modification, are permitted provided that the following conditions | | 10 | # modification, are permitted provided that the following conditions |
11 | # are met: | | 11 | # are met: |
12 | # | | 12 | # |
13 | # 1. Redistributions of source code must retain the above copyright | | 13 | # 1. Redistributions of source code must retain the above copyright |
14 | # notice, this list of conditions and the following disclaimer. | | 14 | # notice, this list of conditions and the following disclaimer. |
15 | # 2. Redistributions in binary form must reproduce the above copyright | | 15 | # 2. Redistributions in binary form must reproduce the above copyright |
| @@ -83,80 +83,139 @@ function print_pre_fail_reason(PKGNAME, | | | @@ -83,80 +83,139 @@ function print_pre_fail_reason(PKGNAME, |
83 | else if (chars[i] == "&") | | 83 | else if (chars[i] == "&") |
84 | printf "&" > html_report | | 84 | printf "&" > html_report |
85 | else | | 85 | else |
86 | printf "%s", chars[i] > html_report | | 86 | printf "%s", chars[i] > html_report |
87 | continue | | 87 | continue |
88 | } | | 88 | } |
89 | printf "%s", chars[i] > html_report | | 89 | printf "%s", chars[i] > html_report |
90 | } | | 90 | } |
91 | printf "\n" > html_report | | 91 | printf "\n" > html_report |
92 | } | | 92 | } |
93 | | | 93 | |
94 | function print_failed(PKGNAME, cmd, has_pre_clean, has_depends, | | 94 | function print_failed(PKGNAME, cmd, has_pre_clean, has_depends, |
95 | has_checksum,has_configure, has_build, has_install, has_package, | | 95 | has_checksum,has_configure, has_build, has_install, has_package, |
96 | has_clean, has_deinstall) { | | 96 | has_clean, has_deinstall, last_error) { |
97 | cmd = "ls " log_dir "/" PKGNAME " 2>/dev/null" | | | |
98 | if (status[PKGNAME] == "failed") { | | 97 | if (status[PKGNAME] == "failed") { |
| | | 98 | cmd = "ls " log_dir "/" PKGNAME " 2>/dev/null" |
99 | while ((cmd | getline) > 0) { | | 99 | while ((cmd | getline) > 0) { |
100 | if ($0 == "pre-clean.log") | | 100 | if ($0 == "pre-clean.log") |
101 | has_pre_clean = 1 | | 101 | has_pre_clean = 1 |
102 | else if ($0 == "depends.log") | | 102 | else if ($0 == "depends.log") |
103 | has_depends = 1 | | 103 | has_depends = 1 |
104 | else if ($0 == "checksum.log") | | 104 | else if ($0 == "checksum.log") |
105 | has_checksum = 1 | | 105 | has_checksum = 1 |
106 | else if ($0 == "configure.log") | | 106 | else if ($0 == "configure.log") |
107 | has_configure = 1 | | 107 | has_configure = 1 |
108 | else if ($0 == "build.log") | | 108 | else if ($0 == "build.log") |
109 | has_build = 1 | | 109 | has_build = 1 |
110 | else if ($0 == "install.log") | | 110 | else if ($0 == "install.log") |
111 | has_install = 1 | | 111 | has_install = 1 |
112 | else if ($0 == "package.log") | | 112 | else if ($0 == "package.log") |
113 | has_package = 1 | | 113 | has_package = 1 |
114 | else if ($0 == "clean.log") | | 114 | else if ($0 == "clean.log") |
115 | has_clean = 1 | | 115 | has_clean = 1 |
116 | else if ($0 == "deinstall.log") | | 116 | else if ($0 == "deinstall.log") |
117 | has_deinstall = 1 | | 117 | has_deinstall = 1 |
118 | } | | 118 | } |
119 | close(cmd) | | 119 | close(cmd) |
| | | 120 | |
| | | 121 | if (has_deinstall) |
| | | 122 | last_error = "deinstall.log" |
| | | 123 | else if (has_clean) |
| | | 124 | last_error = "clean.log" |
| | | 125 | else if (has_package) |
| | | 126 | last_error = "package.log" |
| | | 127 | else if (has_install) |
| | | 128 | last_error = "install.log" |
| | | 129 | else if (has_build) |
| | | 130 | last_error = "build.log" |
| | | 131 | else if (has_configure) |
| | | 132 | last_error = "configure.log" |
| | | 133 | else if (has_checksum) |
| | | 134 | last_error = "checksum.log" |
| | | 135 | else if (has_depends) |
| | | 136 | last_error = "depends.log" |
| | | 137 | else if (has_pre_clean) |
| | | 138 | last_error = "pre-clean.log" |
120 | } | | 139 | } |
121 | print "<tr class=\"" status[PKGNAME] "\">" > html_report | | 140 | print "<tr class=\"" status[PKGNAME] "\">" > html_report |
122 | print "<td>" location[PKGNAME] "</td>" > html_report | | 141 | if (last_error) |
| | | 142 | print "<td><a href=\"../" PKGNAME "/" last_error "\"> " location[PKGNAME] "</a></td>" > html_report |
| | | 143 | else |
| | | 144 | print "<td>" location[PKGNAME] "</td>" > html_report |
123 | print "<td>" PKGNAME "</td>" > html_report | | 145 | print "<td>" PKGNAME "</td>" > html_report |
124 | if (depth[PKGNAME] == 0) | | 146 | if (depth[PKGNAME] == 0) |
125 | print "<td> </td>" > html_report | | 147 | print "<td> </td>" > html_report |
126 | else | | 148 | else |
127 | print "<td>" depth[PKGNAME] "</td>" > html_report | | 149 | print "<td>" depth[PKGNAME] "</td>" > html_report |
128 | print "<td>" maintainer[PKGNAME] "</td>" > html_report | | 150 | print "<td>" maintainer[PKGNAME] "</td>" > html_report |
129 | print "<td>" status[PKGNAME] "</td>" > html_report | | 151 | print "<td>" status[PKGNAME] "</td>" > html_report |
130 | print_failed_log_line(PKGNAME, "pre-clean", has_pre_clean) | | 152 | print_failed_log_line(PKGNAME, "pre-clean", has_pre_clean) |
131 | print_failed_log_line(PKGNAME, "depends", has_depends) | | 153 | print_failed_log_line(PKGNAME, "depends", has_depends) |
132 | print_failed_log_line(PKGNAME, "checksum", has_checksum) | | 154 | print_failed_log_line(PKGNAME, "checksum", has_checksum) |
133 | print_failed_log_line(PKGNAME, "configure", has_configure) | | 155 | print_failed_log_line(PKGNAME, "configure", has_configure) |
134 | print_failed_log_line(PKGNAME, "build", has_build) | | 156 | print_failed_log_line(PKGNAME, "build", has_build) |
135 | print_failed_log_line(PKGNAME, "install", has_install) | | 157 | print_failed_log_line(PKGNAME, "install", has_install) |
136 | print_failed_log_line(PKGNAME, "package", has_package) | | 158 | print_failed_log_line(PKGNAME, "package", has_package) |
137 | print_failed_log_line(PKGNAME, "clean", has_clean) | | 159 | print_failed_log_line(PKGNAME, "clean", has_clean) |
138 | print_failed_log_line(PKGNAME, "deinstall", has_deinstall) | | 160 | print_failed_log_line(PKGNAME, "deinstall", has_deinstall) |
139 | print "</tr>" > html_report | | 161 | print "</tr>" > html_report |
| | | 162 | if (status[PKGNAME] == "indirect-failed") { |
| | | 163 | print "<tr class=\"" status[PKGNAME] "\">" > html_report |
| | | 164 | printf "<td> </td>" > html_report |
| | | 165 | printf "<td colspan=\"13\"> Failed: " > html_report |
| | | 166 | printf "%s", failed_pkgs[PKGNAME] > html_report |
| | | 167 | print "</td>" > html_report |
| | | 168 | print "</tr>" > html_report |
| | | 169 | } |
140 | if (status[PKGNAME] == "prefailed") { | | 170 | if (status[PKGNAME] == "prefailed") { |
141 | print "<tr class=\"" status[PKGNAME] "\">" > html_report | | 171 | print "<tr class=\"" status[PKGNAME] "\">" > html_report |
142 | printf "<td> </td>" > html_report | | 172 | printf "<td> </td>" > html_report |
143 | printf "<td colspan=\"13\">" > html_report | | 173 | printf "<td colspan=\"13\">" > html_report |
144 | print_pre_fail_reason(PKGNAME) | | 174 | print_pre_fail_reason(PKGNAME) |
145 | print "</td>" > html_report | | 175 | print "</td>" > html_report |
146 | print "</tr>" > html_report | | 176 | print "</tr>" > html_report |
147 | } | | 177 | } |
148 | } | | 178 | } |
149 | | | 179 | |
| | | 180 | function compute_direct_failure(CUR, dep, cur_dep, cur_depends, found, i) { |
| | | 181 | if (failed_pkgs[CUR] != "") |
| | | 182 | return |
| | | 183 | split(depends[CUR], cur_depends, "[ \t]+") |
| | | 184 | for (dep in cur_depends) { |
| | | 185 | cur_dep = cur_depends[dep] |
| | | 186 | if (status[cur_dep] == "failed") { |
| | | 187 | failed_pkgs[CUR] = failed_pkgs[CUR] " " cur_dep |
| | | 188 | } else if (status[cur_dep] == "indirect-failed") { |
| | | 189 | compute_direct_failure(cur_dep) |
| | | 190 | failed_pkgs[CUR] = failed_pkgs[cur_dep] " " failed_pkgs[CUR] |
| | | 191 | } |
| | | 192 | } |
| | | 193 | split(failed_pkgs[CUR], cur_depends, "[ \t]+") |
| | | 194 | failed_pkgs[CUR] = "" |
| | | 195 | for (dep in cur_depends) { |
| | | 196 | cur_dep = cur_depends[dep] |
| | | 197 | found[cur_dep] = 1 |
| | | 198 | } |
| | | 199 | i = 0 |
| | | 200 | for (dep in found) { |
| | | 201 | if (++i == 10) { |
| | | 202 | failed_pkgs[CUR] = failed_pkgs[CUR] " ..." |
| | | 203 | break; |
| | | 204 | } |
| | | 205 | failed_pkgs[CUR] = failed_pkgs[CUR] " " dep |
| | | 206 | } |
| | | 207 | } |
| | | 208 | |
150 | BEGIN { | | 209 | BEGIN { |
151 | meta_dir = ARGV[1] | | 210 | meta_dir = ARGV[1] |
152 | log_dir = ARGV[2] | | 211 | log_dir = ARGV[2] |
153 | report_file = meta_dir "/report" | | 212 | report_file = meta_dir "/report" |
154 | html_report = meta_dir "/report.html" | | 213 | html_report = meta_dir "/report.html" |
155 | status_file = meta_dir "/status" | | 214 | status_file = meta_dir "/status" |
156 | tmp_sort = meta_dir "/tmp_sort" | | 215 | tmp_sort = meta_dir "/tmp_sort" |
157 | | | 216 | |
158 | pkgs_done = 0 | | 217 | pkgs_done = 0 |
159 | pkgs_failed = 0 | | 218 | pkgs_failed = 0 |
160 | pkgs_prefailed = 0 | | 219 | pkgs_prefailed = 0 |
161 | pkgs_indirect_failed = 0 | | 220 | pkgs_indirect_failed = 0 |
162 | pkgs_indirect_prefailed = 0 | | 221 | pkgs_indirect_prefailed = 0 |
| @@ -176,39 +235,42 @@ BEGIN { | | | @@ -176,39 +235,42 @@ BEGIN { |
176 | while ((getline < report_file) > 0) { | | 235 | while ((getline < report_file) > 0) { |
177 | if ($0 ~ "^PKGNAME=") | | 236 | if ($0 ~ "^PKGNAME=") |
178 | cur = substr($0, 9) | | 237 | cur = substr($0, 9) |
179 | else if ($0 ~ "^MAINTAINER=") | | 238 | else if ($0 ~ "^MAINTAINER=") |
180 | maintainer[cur] = substr($0, 12) | | 239 | maintainer[cur] = substr($0, 12) |
181 | else if ($0 ~ "^PKG_LOCATION=") | | 240 | else if ($0 ~ "^PKG_LOCATION=") |
182 | location[cur] = substr($0, 14) | | 241 | location[cur] = substr($0, 14) |
183 | else if ($0 ~ "^PKG_DEPTH=") | | 242 | else if ($0 ~ "^PKG_DEPTH=") |
184 | depth[cur] = substr($0, 11) - 1 | | 243 | depth[cur] = substr($0, 11) - 1 |
185 | else if ($0 ~ "^BUILD_STATUS=") | | 244 | else if ($0 ~ "^BUILD_STATUS=") |
186 | status[cur] = substr($0, 14) | | 245 | status[cur] = substr($0, 14) |
187 | else if ($0 ~ "^PKG_FAIL_REASON=") | | 246 | else if ($0 ~ "^PKG_FAIL_REASON=") |
188 | pre_fail_reason[cur] = substr($0, 17) | | 247 | pre_fail_reason[cur] = substr($0, 17) |
| | | 248 | else if ($0 ~ "^DEPENDS=") |
| | | 249 | depends[cur] = substr($0, 9) |
189 | } | | 250 | } |
190 | close(report_file) | | 251 | close(report_file) |
191 | | | 252 | |
192 | for (pkg in status) { | | 253 | for (pkg in status) { |
193 | if (status[pkg] == "done") | | 254 | if (status[pkg] == "done") |
194 | ++pkgs_done | | 255 | ++pkgs_done |
195 | else if (status[pkg] == "failed") | | 256 | else if (status[pkg] == "failed") |
196 | ++pkgs_failed | | 257 | ++pkgs_failed |
197 | else if (status[pkg] == "prefailed") | | 258 | else if (status[pkg] == "prefailed") |
198 | ++pkgs_prefailed | | 259 | ++pkgs_prefailed |
199 | else if (status[pkg] == "indirect-failed") | | 260 | else if (status[pkg] == "indirect-failed") { |
| | | 261 | compute_direct_failure(pkg) |
200 | ++pkgs_indirect_failed | | 262 | ++pkgs_indirect_failed |
201 | else if (status[pkg] == "indirect-prefailed") | | 263 | } else if (status[pkg] == "indirect-prefailed") |
202 | ++pkgs_indirect_prefailed | | 264 | ++pkgs_indirect_prefailed |
203 | } | | 265 | } |
204 | | | 266 | |
205 | print "<html>" > html_report | | 267 | print "<html>" > html_report |
206 | print " <head>" > html_report | | 268 | print " <head>" > html_report |
207 | printf(" <title> pkgsrc bulk build for %s from %s</title>\n", | | 269 | printf(" <title> pkgsrc bulk build for %s from %s</title>\n", |
208 | pkgsrc_platform, pkgsrc_build_start_iso) > html_report | | 270 | pkgsrc_platform, pkgsrc_build_start_iso) > html_report |
209 | print " </head>" > html_report | | 271 | print " </head>" > html_report |
210 | print " <body>" > html_report | | 272 | print " <body>" > html_report |
211 | printf(" <h1> pkgsrc bulk build for %s</h1>\n", pkgsrc_platform) > html_report | | 273 | printf(" <h1> pkgsrc bulk build for %s</h1>\n", pkgsrc_platform) > html_report |
212 | printf(" <h2> Build start: %s</h2>\n", pkgsrc_build_start_iso) > html_report | | 274 | printf(" <h2> Build start: %s</h2>\n", pkgsrc_build_start_iso) > html_report |
213 | printf(" <h2> Build end: %s</h2>\n", pkgsrc_build_end_iso) > html_report | | 275 | printf(" <h2> Build end: %s</h2>\n", pkgsrc_build_end_iso) > html_report |
214 | print " <hr />" > html_report | | 276 | print " <hr />" > html_report |