| @@ -1,15 +1,15 @@ | | | @@ -1,15 +1,15 @@ |
1 | #!/usr/bin/awk -f | | 1 | #!/usr/bin/awk -f |
2 | # $NetBSD: genreadme.awk,v 1.45 2021/02/22 05:32:02 nia Exp $ | | 2 | # $NetBSD: genreadme.awk,v 1.46 2021/02/22 09:32:55 nia Exp $ |
3 | # | | 3 | # |
4 | # Copyright (c) 2002-2021 The NetBSD Foundation, Inc. | | 4 | # Copyright (c) 2002-2021 The NetBSD Foundation, Inc. |
5 | # All rights reserved. | | 5 | # All rights reserved. |
6 | # | | 6 | # |
7 | # This code is derived from software contributed to The NetBSD Foundation | | 7 | # This code is derived from software contributed to The NetBSD Foundation |
8 | # by Dan McMahill. | | 8 | # by Dan McMahill. |
9 | # | | 9 | # |
10 | # Redistribution and use in source and binary forms, with or without | | 10 | # Redistribution and use in source and binary forms, with or without |
11 | # modification, are permitted provided that the following conditions | | 11 | # modification, are permitted provided that the following conditions |
12 | # are met: | | 12 | # are met: |
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 |
| @@ -191,30 +191,26 @@ BEGIN { | | | @@ -191,30 +191,26 @@ BEGIN { |
191 | pkgdir2name[$2] = $3; | | 191 | pkgdir2name[$2] = $3; |
192 | next; | | 192 | next; |
193 | } | | 193 | } |
194 | | | 194 | |
195 | /^license /{ | | 195 | /^license /{ |
196 | license[$2] = $3; | | 196 | license[$2] = $3; |
197 | next; | | 197 | next; |
198 | } | | 198 | } |
199 | | | 199 | |
200 | /^wildcard /{ | | 200 | /^wildcard /{ |
201 | wildcard[$2] = $3; | | 201 | wildcard[$2] = $3; |
202 | } | | 202 | } |
203 | | | 203 | |
204 | # | | | |
205 | # Now recurse the tree to give a flattened depends list for each pkg | | | |
206 | # | | | |
207 | | | | |
208 | END { | | 204 | END { |
209 | readme = TMPDIR "/" readme_name; | | 205 | readme = TMPDIR "/" readme_name; |
210 | | | 206 | |
211 | printf("Making sure binary package cache file is up to date...\n"); | | 207 | printf("Making sure binary package cache file is up to date...\n"); |
212 | if ( quiet == "yes" ){ | | 208 | if ( quiet == "yes" ){ |
213 | cmd = sprintf("%s AWK=%s CMP=%s FIND=%s GREP=%s GZIP_CMD=\"%s\" PKG_INFO=\"%s\" PKG_SUFX=%s SED=%s SORT=%s %s/mk/scripts/binpkg-cache %s --packages %s", | | 209 | cmd = sprintf("%s AWK=%s CMP=%s FIND=%s GREP=%s GZIP_CMD=\"%s\" PKG_INFO=\"%s\" PKG_SUFX=%s SED=%s SORT=%s %s/mk/scripts/binpkg-cache %s --packages %s", |
214 | SETENV, AWK, CMP, FIND, GREP, GZIP_CMD, PKG_INFO, PKG_SUFX, SED, SORT, PKGSRCDIR, summary, PACKAGES); | | 210 | SETENV, AWK, CMP, FIND, GREP, GZIP_CMD, PKG_INFO, PKG_SUFX, SED, SORT, PKGSRCDIR, summary, PACKAGES); |
215 | } else { | | 211 | } else { |
216 | cmd = sprintf("%s AWK=%s CMP=%s FIND=%s GREP=%s GZIP_CMD=\"%s\" PKG_INFO=\"%s\" PKG_SUFX=%s SED=%s SORT=%s %s/mk/scripts/binpkg-cache %s --packages %s --verbose", | | 212 | cmd = sprintf("%s AWK=%s CMP=%s FIND=%s GREP=%s GZIP_CMD=\"%s\" PKG_INFO=\"%s\" PKG_SUFX=%s SED=%s SORT=%s %s/mk/scripts/binpkg-cache %s --packages %s --verbose", |
217 | SETENV, AWK, CMP, FIND, GREP, GZIP_CMD, PKG_INFO, PKG_SUFX, SED, SORT, PKGSRCDIR, summary, PACKAGES); | | 213 | SETENV, AWK, CMP, FIND, GREP, GZIP_CMD, PKG_INFO, PKG_SUFX, SED, SORT, PKGSRCDIR, summary, PACKAGES); |
218 | } | | 214 | } |
219 | if (debug) printf("\nExecute: %s\n",cmd); | | 215 | if (debug) printf("\nExecute: %s\n",cmd); |
220 | rc = system(cmd); | | 216 | rc = system(cmd); |
| @@ -232,29 +228,29 @@ END { | | | @@ -232,29 +228,29 @@ END { |
232 | printf("* List of binary packages will not be generated\n") > "/dev/stderr"; | | 228 | printf("* List of binary packages will not be generated\n") > "/dev/stderr"; |
233 | printf("**** ------- ****\n") > "/dev/stderr"; | | 229 | printf("**** ------- ****\n") > "/dev/stderr"; |
234 | } else { | | 230 | } else { |
235 | | | 231 | |
236 | printf("Loading binary package cache file...\n"); | | 232 | printf("Loading binary package cache file...\n"); |
237 | load_cache_file( PACKAGES "/.pkgcache" ); | | 233 | load_cache_file( PACKAGES "/.pkgcache" ); |
238 | if(pkg_count["unknown"] > 0 ) { | | 234 | if(pkg_count["unknown"] > 0 ) { |
239 | printf(" Loaded %d binary packages with unknown PKGPATH\n", pkg_count["unknown"]); | | 235 | printf(" Loaded %d binary packages with unknown PKGPATH\n", pkg_count["unknown"]); |
240 | } | | 236 | } |
241 | } | | 237 | } |
242 | | | 238 | |
243 | # extract date for vulnerabilities file | | 239 | # extract date for vulnerabilities file |
244 | if (SCAN_VULNERABILITIES == 0) | | 240 | if (SCAN_VULNERABILITIES == 0) |
245 | vuldate="<TR><TD><I>(no vulnerabilities list, update pkg_install)</I>"; | | 241 | vuldate="<li><em>(no vulnerabilities list, update pkg_install)</em></li>"; |
246 | else if (SCAN_VULNERABILITIES == 1) | | 242 | else if (SCAN_VULNERABILITIES == 1) |
247 | vuldate="<TR><TD><I>(no vulnerabilities list available)</I>"; | | 243 | vuldate="<li><em>(no vulnerabilities list available)</em></li>"; |
248 | | | 244 | |
249 | if (SINGLEPKG != "" ) { | | 245 | if (SINGLEPKG != "" ) { |
250 | printf("Only creating README for %s\n",SINGLEPKG); | | 246 | printf("Only creating README for %s\n",SINGLEPKG); |
251 | for( key in depends ) { | | 247 | for( key in depends ) { |
252 | delete depends[key]; | | 248 | delete depends[key]; |
253 | } | | 249 | } |
254 | depends[SINGLEPKG] = "yes"; | | 250 | depends[SINGLEPKG] = "yes"; |
255 | } | | 251 | } |
256 | | | 252 | |
257 | printf("Generating README.html files\n"); | | 253 | printf("Generating README.html files\n"); |
258 | pkgcnt = 0; | | 254 | pkgcnt = 0; |
259 | if (do_pkg_readme) { | | 255 | if (do_pkg_readme) { |
260 | templatefile = PKGSRCDIR "/templates/README.pkg"; | | 256 | templatefile = PKGSRCDIR "/templates/README.pkg"; |
| @@ -282,33 +278,33 @@ END { | | | @@ -282,33 +278,33 @@ END { |
282 | if (SCAN_VULNERABILITIES == 2) { | | 278 | if (SCAN_VULNERABILITIES == 2) { |
283 | pkgbase = pkgdir2name[toppkg]; | | 279 | pkgbase = pkgdir2name[toppkg]; |
284 | sub("-[^-]*$", "", pkgbase); | | 280 | sub("-[^-]*$", "", pkgbase); |
285 | cmd = sprintf("%s audit-history %s", PKG_ADMIN, pkgbase); | | 281 | cmd = sprintf("%s audit-history %s", PKG_ADMIN, pkgbase); |
286 | while (cmd | getline vuln_entry) { | | 282 | while (cmd | getline vuln_entry) { |
287 | split(vuln_entry, entry, " "); | | 283 | split(vuln_entry, entry, " "); |
288 | status_cmd = sprintf("if %s pmatch '%s' %s; then echo open; else echo fixed; fi", | | 284 | status_cmd = sprintf("if %s pmatch '%s' %s; then echo open; else echo fixed; fi", |
289 | PKG_ADMIN, entry[1], pkgdir2name[toppkg]); | | 285 | PKG_ADMIN, entry[1], pkgdir2name[toppkg]); |
290 | status_cmd | getline status | | 286 | status_cmd | getline status |
291 | close(status_cmd) | | 287 | close(status_cmd) |
292 | if (status == "fixed") | | 288 | if (status == "fixed") |
293 | continue | | 289 | continue |
294 | status = "a " status; | | 290 | status = "a " status; |
295 | vul = sprintf("%s<LI>%s <a href=\"%s\">%s</a> vulnerability</LI>\n", | | 291 | vul = sprintf("%s<li>%s <a href=\"%s\">%s</a> vulnerability</li>\n", |
296 | vul, status, entry[3], entry[2]); | | 292 | vul, status, entry[3], entry[2]); |
297 | } | | 293 | } |
298 | close(cmd); | | 294 | close(cmd); |
299 | | | 295 | |
300 | if ( vul == "" ) { | | 296 | if ( vul == "" ) { |
301 | vul="<I>(no vulnerabilities known)</I>"; | | 297 | vul="<em>(no vulnerabilities known)</em>"; |
302 | } | | 298 | } |
303 | } | | 299 | } |
304 | | | 300 | |
305 | if (debug) { | | 301 | if (debug) { |
306 | printf("Checking for binary package with lookup_cache( %s)\n", | | 302 | printf("Checking for binary package with lookup_cache( %s)\n", |
307 | toppkg); | | 303 | toppkg); |
308 | } | | 304 | } |
309 | # lookup_cache( wildcard ) will produce HTML for the packages which are found | | 305 | # lookup_cache( wildcard ) will produce HTML for the packages which are found |
310 | lookup_cache( toppkg ); | | 306 | lookup_cache( toppkg ); |
311 | | | 307 | |
312 | while((getline < templatefile) > 0){ | | 308 | while((getline < templatefile) > 0){ |
313 | gsub(/%%PORT%%/, toppkg); | | 309 | gsub(/%%PORT%%/, toppkg); |
314 | gsub(/%%PKG%%/, pkgdir2name[toppkg]); | | 310 | gsub(/%%PKG%%/, pkgdir2name[toppkg]); |
| @@ -390,99 +386,79 @@ END { | | | @@ -390,99 +386,79 @@ END { |
390 | tot_numpkg = 0; | | 386 | tot_numpkg = 0; |
391 | top_make = PKGSRCDIR"/Makefile"; | | 387 | top_make = PKGSRCDIR"/Makefile"; |
392 | while((getline < top_make) > 0){ | | 388 | while((getline < top_make) > 0){ |
393 | if ($0 ~ /^[ \t]*SUBDIR.*=[^\$]*$/) { | | 389 | if ($0 ~ /^[ \t]*SUBDIR.*=[^\$]*$/) { |
394 | category = $0; | | 390 | category = $0; |
395 | gsub(/^[ \t]*SUBDIR.*=[ \t]*/, "", category); | | 391 | gsub(/^[ \t]*SUBDIR.*=[ \t]*/, "", category); |
396 | catdir = PKGSRCDIR"/"category; | | 392 | catdir = PKGSRCDIR"/"category; |
397 | readmenew = catdir"/"readme_name; | | 393 | readmenew = catdir"/"readme_name; |
398 | if (quiet != "yes") { | | 394 | if (quiet != "yes") { |
399 | printf("Category = %s\n", category); | | 395 | printf("Category = %s\n", category); |
400 | } | | 396 | } |
401 | cat_make = catdir"/Makefile"; | | 397 | cat_make = catdir"/Makefile"; |
402 | pkgs = ""; | | 398 | pkgs = ""; |
403 | pkgs_file = TMPDIR "/pkgs_file"; | | | |
404 | printf("") > pkgs_file; | | | |
405 | numpkg = 0; | | 399 | numpkg = 0; |
406 | print "" > readme; | | 400 | print "" > readme; |
407 | while((getline < cat_make) > 0){ | | 401 | while((getline < cat_make) > 0){ |
408 | if ($0 ~ /^[ \t]*SUBDIR.*=[^\$]*$/) { | | 402 | if ($0 ~ /^[ \t]*SUBDIR.*=[^\$]*$/) { |
409 | pkg = $0; | | 403 | pkg = $0; |
410 | gsub(/^[ \t]*SUBDIR.*=[ \t]*/, "", | | 404 | gsub(/^[ \t]*SUBDIR.*=[ \t]*/, "", |
411 | pkg); | | 405 | pkg); |
412 | dir = category"/"pkg; | | 406 | dir = category"/"pkg; |
413 | numpkg++; | | 407 | numpkg++; |
414 | tot_numpkg++; | | 408 | tot_numpkg++; |
415 | if (debug) { | | 409 | if (debug) { |
416 | printf("\tAdding %s (%s : %s)\n", | | 410 | printf("\tAdding %s (%s : %s)\n", |
417 | dir, | | 411 | dir, |
418 | pkgdir2name[dir], | | 412 | pkgdir2name[dir], |
419 | comment[dir]); | | 413 | comment[dir]); |
420 | } | | 414 | } |
421 | # pkgs = sprintf("%s<TR><TD VALIGN=TOP><a href=\"%s/%s\">%s</a>: %s<TD>\n", | | 415 | pkgs = sprintf("%s<dt><a href=\"%s/%s\">%s</a></dt><dd>%s</dd>\n", |
422 | # pkgs, pkg, readme_name, | | 416 | pkgs, |
423 | # pkgdir2name[dir], | | 417 | pkg, readme_name, |
424 | # comment[dir]); | | 418 | pkgdir2name[dir], |
425 | # We use a temp file to hold the list of all packages because | | 419 | comment[dir]); |
426 | # this list can get very very large and | | 420 | allpkg[tot_numpkg] = sprintf("<!-- %s (for sorting) --><tr><td><a href=\"%s/%s/%s\">%s</a></td><td><a href=\"%s/%s\">%s</a></td><td>%s</td>\n", |
427 | # become larger than what some awk implementations can deal | | | |
428 | # with. The nawk shipped with solaris 9 is an example of | | | |
429 | # such a limited awk. | | | |
430 | printf("<TR><TD VALIGN=TOP><a href=\"%s/%s\">%s</a>: %s<TD>\n", | | | |
431 | pkg, readme_name, | | | |
432 | pkgdir2name[dir], | | | |
433 | comment[dir]) >> pkgs_file; | | | |
434 | allpkg[tot_numpkg] = sprintf("<!-- %s (for sorting) --><TR VALIGN=TOP><TD><a href=\"%s/%s/%s\">%s</a>: <TD>(<a href=\"%s/%s\">%s</a>) <td>%s\n", | | | |
435 | pkgdir2name[dir], | | 421 | pkgdir2name[dir], |
436 | category, pkg, | | 422 | category, pkg, |
437 | readme_name, | | 423 | readme_name, |
438 | pkgdir2name[dir], | | 424 | pkgdir2name[dir], |
439 | category, | | 425 | category, |
440 | readme_name, | | 426 | readme_name, |
441 | category, | | 427 | category, |
442 | comment[dir]); | | 428 | comment[dir]); |
443 | # we need slightly fewer escapes here since we are not gsub()-ing | | 429 | # we need slightly fewer escapes here since we are not gsub()-ing |
444 | # allpkg[] into the output files but just printf()-ing it. | | 430 | # allpkg[] into the output files but just printf()-ing it. |
445 | gsub(/\\&/, "\\&", allpkg[tot_numpkg]); | | 431 | gsub(/\\&/, "\\&", allpkg[tot_numpkg]); |
446 | } else if ($0 ~ /^[ \t]*COMMENT/) { | | 432 | } else if ($0 ~ /^[ \t]*COMMENT/) { |
447 | descr = $0; | | 433 | descr = $0; |
448 | gsub(/^[ \t]*COMMENT.*=[ \t]*/, "", | | 434 | gsub(/^[ \t]*COMMENT.*=[ \t]*/, "", |
449 | descr); | | 435 | descr); |
450 | } | | 436 | } |
451 | } | | 437 | } |
452 | while ((getline < templatefile) > 0){ | | 438 | while ((getline < templatefile) > 0){ |
453 | gsub(/%%CATEGORY%%/, category); | | 439 | gsub(/%%CATEGORY%%/, category); |
454 | gsub(/%%NUMITEMS%%/, numpkg); | | 440 | gsub(/%%NUMITEMS%%/, numpkg); |
455 | gsub(/%%DESCR%%/, descr); | | 441 | gsub(/%%DESCR%%/, descr); |
| | | 442 | gsub(/%%SUBDIR%%/, ""pkgs""); |
456 | | | 443 | |
457 | line = $0 | | 444 | print $0 >> readme; |
458 | | | | |
459 | if( $0 ~/%%SUBDIR%%/ ) { | | | |
460 | gsub(/%%SUBDIR%%/, "", line); | | | |
461 | while((getline < pkgs_file) > 0) { | | | |
462 | gsub(/README.html/, readme_name); | | | |
463 | print >> readme; | | | |
464 | } | | | |
465 | close( pkgs_file ); | | | |
466 | } | | | |
467 | | | | |
468 | print line >> readme; | | | |
469 | } | | 445 | } |
470 | close(readme); | | 446 | close(readme); |
471 | close(templatefile); | | 447 | close(templatefile); |
472 | copy_readme(readmenew, readme); | | 448 | copy_readme(readmenew, readme); |
473 | | | 449 | |
474 | gsub(/href=\"/, "href=\""category"/", pkgs); | | 450 | gsub(/href=\"/, "href=\""category"/", pkgs); |
475 | allcat = sprintf("%s<TR><TD VALIGN=TOP><a href=\"%s/%s\">%s</a>: %s<TD>\n", | | 451 | allcat = sprintf("%s<dt><a href=\"%s/%s\">%s</a></dt><dd>%s</dd>\n", |
476 | allcat, category, readme_name, | | 452 | allcat, category, readme_name, |
477 | category, descr); | | 453 | category, descr); |
478 | close(cat_make); | | 454 | close(cat_make); |
479 | } | | 455 | } |
480 | } | | 456 | } |
481 | close(top_make); | | 457 | close(top_make); |
482 | | | 458 | |
483 | printf("Generating toplevel readmes:\n"); | | 459 | printf("Generating toplevel readmes:\n"); |
484 | templatefile = PKGSRCDIR "/templates/README.top"; | | 460 | templatefile = PKGSRCDIR "/templates/README.top"; |
485 | fatal_check_file(templatefile); | | 461 | fatal_check_file(templatefile); |
486 | readmenew = PKGSRCDIR "/"readme_name; | | 462 | readmenew = PKGSRCDIR "/"readme_name; |
487 | printf("\t%s\n", readmenew); | | 463 | printf("\t%s\n", readmenew); |
488 | print "" > readme; | | 464 | print "" > readme; |
| @@ -546,27 +522,27 @@ function create_htmldeps(dependslist){ | | | @@ -546,27 +522,27 @@ function create_htmldeps(dependslist){ |
546 | printf("\tdpkg=%s, pat2dir[%s] = %s\n", | | 522 | printf("\tdpkg=%s, pat2dir[%s] = %s\n", |
547 | dpkgs[i], | | 523 | dpkgs[i], |
548 | dpkgs[i], | | 524 | dpkgs[i], |
549 | pat2dir[dpkgs[i]]); | | 525 | pat2dir[dpkgs[i]]); |
550 | } | | 526 | } |
551 | htmldeps = sprintf("%s<a href=\"../../%s/%s\">%s</a>\n", | | 527 | htmldeps = sprintf("%s<a href=\"../../%s/%s\">%s</a>\n", |
552 | htmldeps, | | 528 | htmldeps, |
553 | pat2dir[dpkgs[i]], | | 529 | pat2dir[dpkgs[i]], |
554 | readme_name, | | 530 | readme_name, |
555 | pat2dir[dpkgs[i]]); | | 531 | pat2dir[dpkgs[i]]); |
556 | i = i + 1; | | 532 | i = i + 1; |
557 | } | | 533 | } |
558 | if ( i == 1 ) { | | 534 | if ( i == 1 ) { |
559 | htmldeps = "<EM>none</EM>"; | | 535 | htmldeps = "<em>(none)</em>"; |
560 | } | | 536 | } |
561 | return htmldeps; | | 537 | return htmldeps; |
562 | } | | 538 | } |
563 | | | 539 | |
564 | # | | 540 | # |
565 | # take a string which has special characters like '+' in it and | | 541 | # take a string which has special characters like '+' in it and |
566 | # escape them. Also put a space before and after since that's how | | 542 | # escape them. Also put a space before and after since that's how |
567 | # we'll distinguish things like gnome from gnome-libs | | 543 | # we'll distinguish things like gnome from gnome-libs |
568 | # | | 544 | # |
569 | function reg2str(reg){ | | 545 | function reg2str(reg){ |
570 | gsub(/\./, "\\.", reg); | | 546 | gsub(/\./, "\\.", reg); |
571 | gsub(/\+/, "\\+", reg); | | 547 | gsub(/\+/, "\\+", reg); |
572 | gsub(/\*/, "\\*", reg); | | 548 | gsub(/\*/, "\\*", reg); |
| @@ -740,25 +716,25 @@ function load_cache_file( file, pkgfile, | | | @@ -740,25 +716,25 @@ function load_cache_file( file, pkgfile, |
740 | } | | 716 | } |
741 | | | 717 | |
742 | # close the cache file | | 718 | # close the cache file |
743 | close( file ); | | 719 | close( file ); |
744 | } | | 720 | } |
745 | | | 721 | |
746 | function lookup_cache( d, binpkgs) { | | 722 | function lookup_cache( d, binpkgs) { |
747 | if( debug ) printf("lookup_cache( %s ): pkg_count = %d\n", | | 723 | if( debug ) printf("lookup_cache( %s ): pkg_count = %d\n", |
748 | d, pkg_count[d]); | | 724 | d, pkg_count[d]); |
749 | | | 725 | |
750 | binpkgs_file = TMPDIR "/binpkgs"; | | 726 | binpkgs_file = TMPDIR "/binpkgs"; |
751 | spipe = SORT " > " binpkgs_file; | | 727 | spipe = SORT " > " binpkgs_file; |
752 | for(i=1 ; i<=pkg_count[d]; i=i+1) { | | 728 | for(i=1 ; i<=pkg_count[d]; i=i+1) { |
753 | printf("<TR><TD>%s:<TD><a href=\"%s/%s\">%s</a><TD>(%s %s)\n", | | 729 | printf("<tr><td>%s:<td><a href=\"%s/%s\">%s</a><td>(%s %s)\n", |
754 | march_list[d, i], PKG_URL, pkgfile_list[d, i], pkgnm_list[d, i], | | 730 | march_list[d, i], PKG_URL, pkgfile_list[d, i], pkgnm_list[d, i], |
755 | opsys_list[d, i], osver_list[d, i]) | spipe; | | 731 | opsys_list[d, i], osver_list[d, i]) | spipe; |
756 | } | | 732 | } |
757 | if( pkg_count[d] == 0 ) { | | 733 | if( pkg_count[d] == 0 ) { |
758 | printf("<TR><TD><EM>none</EM></TD></TR>\n") | spipe; | | 734 | printf("<tr><td><em>(none)</em></td></tr>\n") | spipe; |
759 | } | | 735 | } |
760 | | | 736 | |
761 | close( spipe ); | | 737 | close( spipe ); |
762 | } | | 738 | } |
763 | | | 739 | |
764 | | | 740 | |