| @@ -1,738 +1,738 @@ | | | @@ -1,738 +1,738 @@ |
1 | #!/usr/bin/awk -f | | 1 | #!/usr/bin/awk -f |
2 | # $NetBSD: genreadme.awk,v 1.47 2021/02/24 08:16:32 nia Exp $ | | 2 | # $NetBSD: genreadme.awk,v 1.48 2021/03/08 16:37:59 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 |
16 | # notice, this list of conditions and the following disclaimer in the | | 16 | # notice, this list of conditions and the following disclaimer in the |
17 | # documentation and/or other materials provided with the distribution. | | 17 | # documentation and/or other materials provided with the distribution. |
18 | # | | 18 | # |
19 | # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 19 | # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
20 | # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | # POSSIBILITY OF SUCH DAMAGE. | | 29 | # POSSIBILITY OF SUCH DAMAGE. |
30 | # | | 30 | # |
31 | | | 31 | |
32 | | | 32 | |
33 | # Global variables | | 33 | # Global variables |
34 | #----------------- | | 34 | #----------------- |
35 | # The following associative arrays are used for storing the dependency | | 35 | # The following associative arrays are used for storing the dependency |
36 | # information and other information for the packages | | 36 | # information and other information for the packages |
37 | # | | 37 | # |
38 | # depends[] : index=pkgdir (math/scilab) | | 38 | # depends[] : index=pkgdir (math/scilab) |
39 | # List of explicitly listed depencencies by name. | | 39 | # List of explicitly listed depencencies by name. |
40 | # I.e. "xless-[0-9]* pvm-3.4.3" | | 40 | # I.e. "xless-[0-9]* pvm-3.4.3" |
41 | # | | 41 | # |
42 | # builddepends[] : index=pkgdir (math/scilab) | | 42 | # builddepends[] : index=pkgdir (math/scilab) |
43 | # List of explicitly listed depencencies by name. | | 43 | # List of explicitly listed depencencies by name. |
44 | # | | 44 | # |
45 | BEGIN { | | 45 | BEGIN { |
46 | do_pkg_readme=1; | | 46 | do_pkg_readme=1; |
47 | # set to 1 to use "README-new.html" as the name | | 47 | # set to 1 to use "README-new.html" as the name |
48 | use_readme_new=0; | | 48 | use_readme_new=0; |
49 | if (use_readme_new) { | | 49 | if (use_readme_new) { |
50 | readme_name = "README-new.html"; | | 50 | readme_name = "README-new.html"; |
51 | } | | 51 | } |
52 | else { | | 52 | else { |
53 | readme_name = "README.html"; | | 53 | readme_name = "README.html"; |
54 | } | | 54 | } |
55 | printf("Reading database file\n"); | | 55 | printf("Reading database file\n"); |
56 | } | | 56 | } |
57 | | | 57 | |
58 | #conflicts /usr/pkgsrc/math/scilab | | 58 | #conflicts /usr/pkgsrc/math/scilab |
59 | #depends /usr/pkgsrc/math/scilab xless-[0-9]*:../../x11/xless pvm-3.4.3:../../parallel/pvm3 | | 59 | #depends /usr/pkgsrc/math/scilab xless-[0-9]*:../../x11/xless pvm-3.4.3:../../parallel/pvm3 |
60 | # | | 60 | # |
61 | | | 61 | |
62 | /^(build_|tool_)?depends / { | | 62 | /^(build_|tool_)?depends / { |
63 | # | | 63 | # |
64 | # Read in the entire depends tree | | 64 | # Read in the entire depends tree |
65 | # These lines look like: | | 65 | # These lines look like: |
66 | # | | 66 | # |
67 | #depends /usr/pkgsrc/math/scilab xless-[0-9]*:../../x11/xless pvm-3.4.3:../../parallel/pvm3 | | 67 | #depends /usr/pkgsrc/math/scilab xless-[0-9]*:../../x11/xless pvm-3.4.3:../../parallel/pvm3 |
68 | #build_depends /usr/pkgsrc/math/scilab libtool-base>=1.4.20010614nb9:../../devel/libtool-base | | 68 | #build_depends /usr/pkgsrc/math/scilab libtool-base>=1.4.20010614nb9:../../devel/libtool-base |
69 | # | | 69 | # |
70 | deptype=$1; | | 70 | deptype=$1; |
71 | # pkg=fulldir2pkgdir($2); | | 71 | # pkg=fulldir2pkgdir($2); |
72 | pkg = $2; | | 72 | pkg = $2; |
73 | if (pkg in depends) {} | | 73 | if (pkg in depends) {} |
74 | else {depends[pkg] = "";} | | 74 | else {depends[pkg] = "";} |
75 | if (pkg in builddepends) {} | | 75 | if (pkg in builddepends) {} |
76 | else {builddepends[pkg] = "";} | | 76 | else {builddepends[pkg] = "";} |
77 | | | 77 | |
78 | for (i = 3; i <= NF; i++) { | | 78 | for (i = 3; i <= NF; i++) { |
79 | split($i, a,":"); | | 79 | split($i, a,":"); |
80 | pkgpat = a[1]; | | 80 | pkgpat = a[1]; |
81 | pkgdir = a[2]; | | 81 | pkgdir = a[2]; |
82 | sub(/[\.\/]*/, "", pkgdir); | | 82 | sub(/[\.\/]*/, "", pkgdir); |
83 | if (pkgdir !~ /\//) { | | 83 | if (pkgdir !~ /\//) { |
84 | pkgcat = pkg; | | 84 | pkgcat = pkg; |
85 | gsub(/\/.*/, "", pkgcat); | | 85 | gsub(/\/.*/, "", pkgcat); |
86 | pkgdir=pkgcat "/" pkgdir; | | 86 | pkgdir=pkgcat "/" pkgdir; |
87 | if (debug) | | 87 | if (debug) |
88 | printf("Corrected missing category directory to get \"%s\"\n", | | 88 | printf("Corrected missing category directory to get \"%s\"\n", |
89 | pkgdir); | | 89 | pkgdir); |
90 | } | | 90 | } |
91 | if (debug){ | | 91 | if (debug){ |
92 | printf("package in directory %s %s on:\n", | | 92 | printf("package in directory %s %s on:\n", |
93 | pkg, deptype); | | 93 | pkg, deptype); |
94 | printf("\tpkgpat = %s\n", pkgpat); | | 94 | printf("\tpkgpat = %s\n", pkgpat); |
95 | printf("\tpkgdir = %s\n", pkgdir); | | 95 | printf("\tpkgdir = %s\n", pkgdir); |
96 | } | | 96 | } |
97 | | | 97 | |
98 | | | 98 | |
99 | # | | 99 | # |
100 | # store the package directory in a associative array with the wildcard | | 100 | # store the package directory in a associative array with the wildcard |
101 | # pattern as the index since we will need to be able to look this up later | | 101 | # pattern as the index since we will need to be able to look this up later |
102 | # | | 102 | # |
103 | pat2dir[pkgpat] = pkgdir; | | 103 | pat2dir[pkgpat] = pkgdir; |
104 | | | 104 | |
105 | if (deptype == "depends") { | | 105 | if (deptype == "depends") { |
106 | depends[pkg] = depends[pkg] " " pkgpat " " ; | | 106 | depends[pkg] = depends[pkg] " " pkgpat " " ; |
107 | if (debug) { | | 107 | if (debug) { |
108 | printf("Appending %s to depends[%s] (%s)\n", | | 108 | printf("Appending %s to depends[%s] (%s)\n", |
109 | pkgpat, pkg, depends[pkg]); | | 109 | pkgpat, pkg, depends[pkg]); |
110 | } | | 110 | } |
111 | } | | 111 | } |
112 | else { | | 112 | else { |
113 | if (debug) { | | 113 | if (debug) { |
114 | printf("Appending %s to builddepends[%s] (%s)\n", | | 114 | printf("Appending %s to builddepends[%s] (%s)\n", |
115 | pkgpat, pkg, builddepends[pkg]); | | 115 | pkgpat, pkg, builddepends[pkg]); |
116 | } | | 116 | } |
117 | builddepends[pkg] = builddepends[pkg] " " pkgpat " " ; | | 117 | builddepends[pkg] = builddepends[pkg] " " pkgpat " " ; |
118 | } | | 118 | } |
119 | } | | 119 | } |
120 | | | 120 | |
121 | next; | | 121 | next; |
122 | } | | 122 | } |
123 | | | 123 | |
124 | /^maintainer /{ | | 124 | /^maintainer /{ |
125 | maintainer[$2] = $3; | | 125 | maintainer[$2] = $3; |
126 | gsub(/@/, " AT ", maintainer[$2]); | | 126 | gsub(/@/, " AT ", maintainer[$2]); |
127 | next; | | 127 | next; |
128 | } | | 128 | } |
129 | | | 129 | |
130 | /^comment /{ | | 130 | /^comment /{ |
131 | dir = $2; | | 131 | dir = $2; |
132 | gsub(/^comment[ \t]*/, ""); | | 132 | gsub(/^comment[ \t]*/, ""); |
133 | tmp = substr($0, length($1) + 1); | | 133 | tmp = substr($0, length($1) + 1); |
134 | gsub(/^[ \t]*/, "", tmp); | | 134 | gsub(/^[ \t]*/, "", tmp); |
135 | gsub(/&/, "\\\\\\&", tmp); | | 135 | gsub(/&/, "\\\\\\&", tmp); |
136 | comment[dir] = tmp; | | 136 | comment[dir] = tmp; |
137 | next; | | 137 | next; |
138 | } | | 138 | } |
139 | | | 139 | |
140 | /^homepage /{ | | 140 | /^homepage /{ |
141 | homepage[$2] = $3; | | 141 | homepage[$2] = $3; |
142 | gsub(/&/, "\\\\&", homepage[$2]); | | 142 | gsub(/&/, "\\\\&", homepage[$2]); |
143 | next; | | 143 | next; |
144 | } | | 144 | } |
145 | | | 145 | |
146 | | | 146 | |
147 | /^htmlname / { | | 147 | /^htmlname / { |
148 | # | | 148 | # |
149 | # read lines like: | | 149 | # read lines like: |
150 | # htmlname /usr/pkgsrc/archivers/arc <a href=../../archivers/arc/README.html>arc-5.21e</A> | | 150 | # htmlname /usr/pkgsrc/archivers/arc <a href=../../archivers/arc/README.html>arc-5.21e</A> |
151 | # | | 151 | # |
152 | # dir=fulldir2pkgdir($2); | | 152 | # dir=fulldir2pkgdir($2); |
153 | dir = $2; | | 153 | dir = $2; |
154 | htmlname = $3; | | 154 | htmlname = $3; |
155 | for (i = 4; i <= NF; i++){ | | 155 | for (i = 4; i <= NF; i++){ |
156 | htmlname = htmlname " " $i; | | 156 | htmlname = htmlname " " $i; |
157 | } | | 157 | } |
158 | # If we are using a name other than README.html, change it | | 158 | # If we are using a name other than README.html, change it |
159 | # here. This avoids having to process a huge line later which | | 159 | # here. This avoids having to process a huge line later which |
160 | # makes lesser awks puke. | | 160 | # makes lesser awks puke. |
161 | gsub(/README.html/, readme_name, htmlname); | | 161 | gsub(/README.html/, readme_name, htmlname); |
162 | dir2htmlname[dir] = htmlname; | | 162 | dir2htmlname[dir] = htmlname; |
163 | if (debug) printf("added dir2htmlname[%s]=%s\n", dir, htmlname); | | 163 | if (debug) printf("added dir2htmlname[%s]=%s\n", dir, htmlname); |
164 | next; | | 164 | next; |
165 | } | | 165 | } |
166 | | | 166 | |
167 | /^htmloptions / { | | 167 | /^htmloptions / { |
168 | htmloptions = $3; | | 168 | htmloptions = $3; |
169 | origfs = FS; | | 169 | origfs = FS; |
170 | FS = "\t"; | | 170 | FS = "\t"; |
171 | for (i = 4; i <= NF; i++){ | | 171 | for (i = 4; i <= NF; i++){ |
172 | htmloptions = htmloptions " " $i; | | 172 | htmloptions = htmloptions " " $i; |
173 | } | | 173 | } |
174 | FS = origfs; | | 174 | FS = origfs; |
175 | options[$2] = htmloptions; | | 175 | options[$2] = htmloptions; |
176 | next; | | 176 | next; |
177 | } | | 177 | } |
178 | | | 178 | |
179 | /^index / { | | 179 | /^index / { |
180 | # | | 180 | # |
181 | # read lines like: | | 181 | # read lines like: |
182 | #index /usr/pkgsrc/math/scilab scilab-2.6nb3 | | 182 | #index /usr/pkgsrc/math/scilab scilab-2.6nb3 |
183 | # and store the directory name in a associative array where the index | | 183 | # and store the directory name in a associative array where the index |
184 | # is the package name and in a associative array that lets us lookup | | 184 | # is the package name and in a associative array that lets us lookup |
185 | # name from directory. We use fuldir2pkgdir to get "math/scilab" | | 185 | # name from directory. We use fuldir2pkgdir to get "math/scilab" |
186 | # and drop the /usr/pkgsrc part. | | 186 | # and drop the /usr/pkgsrc part. |
187 | # | | 187 | # |
188 | # pkgname2dir[$3] = fulldir2pkgdir($2); | | 188 | # pkgname2dir[$3] = fulldir2pkgdir($2); |
189 | # pkgdir2name[fulldir2pkgdir($2)] = $3; | | 189 | # pkgdir2name[fulldir2pkgdir($2)] = $3; |
190 | pkgname2dir[$3] = $2; | | 190 | pkgname2dir[$3] = $2; |
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 | END { | | 204 | END { |
205 | readme = TMPDIR "/" readme_name; | | 205 | readme = TMPDIR "/" readme_name; |
206 | | | 206 | |
207 | 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"); |
208 | if ( quiet == "yes" ){ | | 208 | if ( quiet == "yes" ){ |
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", | | 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", |
210 | 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); |
211 | } else { | | 211 | } else { |
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", | | 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", |
213 | 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); |
214 | } | | 214 | } |
215 | if (debug) printf("\nExecute: %s\n",cmd); | | 215 | if (debug) printf("\nExecute: %s\n",cmd); |
216 | rc = system(cmd); | | 216 | rc = system(cmd); |
217 | | | 217 | |
218 | if (rc != 0 && rc != 2) { | | 218 | if (rc != 0 && rc != 2) { |
219 | printf("\n**** WARNING ****\n") > "/dev/stderr"; | | 219 | printf("\n**** WARNING ****\n") > "/dev/stderr"; |
220 | printf("Command: %s\nfailed.", cmd) > "/dev/stderr"; | | 220 | printf("Command: %s\nfailed.", cmd) > "/dev/stderr"; |
221 | printf("**** ------- ****\n") > "/dev/stderr"; | | 221 | printf("**** ------- ****\n") > "/dev/stderr"; |
222 | exit(1); | | 222 | exit(1); |
223 | } | | 223 | } |
224 | | | 224 | |
225 | if (rc == 2) { | | 225 | if (rc == 2) { |
226 | printf("\n**** WARNING ****\n") > "/dev/stderr"; | | 226 | printf("\n**** WARNING ****\n") > "/dev/stderr"; |
227 | printf("* No binary packages directory found\n") > "/dev/stderr"; | | 227 | printf("* No binary packages directory found\n") > "/dev/stderr"; |
228 | 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"; |
229 | printf("**** ------- ****\n") > "/dev/stderr"; | | 229 | printf("**** ------- ****\n") > "/dev/stderr"; |
230 | } else { | | 230 | } else { |
231 | | | 231 | |
232 | printf("Loading binary package cache file...\n"); | | 232 | printf("Loading binary package cache file...\n"); |
233 | load_cache_file( PACKAGES "/.pkgcache" ); | | 233 | load_cache_file( PACKAGES "/.pkgcache" ); |
234 | if(pkg_count["unknown"] > 0 ) { | | 234 | if(pkg_count["unknown"] > 0 ) { |
235 | 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"]); |
236 | } | | 236 | } |
237 | } | | 237 | } |
238 | | | 238 | |
239 | # extract date for vulnerabilities file | | 239 | # extract date for vulnerabilities file |
240 | if (SCAN_VULNERABILITIES == 0) | | 240 | if (SCAN_VULNERABILITIES == 0) |
241 | vuldate="<li><em>(no vulnerabilities list, update pkg_install)</em></li>"; | | 241 | vuldate="<li><em>(no vulnerabilities list, update pkg_install)</em></li>"; |
242 | else if (SCAN_VULNERABILITIES == 1) | | 242 | else if (SCAN_VULNERABILITIES == 1) |
243 | vuldate="<li><em>(no vulnerabilities list available)</em></li>"; | | 243 | vuldate="<li><em>(no vulnerabilities list available)</em></li>"; |
244 | | | 244 | |
245 | if (SINGLEPKG != "" ) { | | 245 | if (SINGLEPKG != "" ) { |
246 | printf("Only creating README for %s\n",SINGLEPKG); | | 246 | printf("Only creating README for %s\n",SINGLEPKG); |
247 | for( key in depends ) { | | 247 | for( key in depends ) { |
248 | delete depends[key]; | | 248 | delete depends[key]; |
249 | } | | 249 | } |
250 | depends[SINGLEPKG] = "yes"; | | 250 | depends[SINGLEPKG] = "yes"; |
251 | } | | 251 | } |
252 | | | 252 | |
253 | printf("Generating README.html files\n"); | | 253 | printf("Generating README.html files\n"); |
254 | pkgcnt = 0; | | 254 | pkgcnt = 0; |
255 | if (do_pkg_readme) { | | 255 | if (do_pkg_readme) { |
256 | templatefile = PKGSRCDIR "/templates/README.pkg"; | | 256 | templatefile = PKGSRCDIR "/templates/README.pkg"; |
257 | fatal_check_file(templatefile); | | 257 | fatal_check_file(templatefile); |
258 | for (toppkg in depends){ | | 258 | for (toppkg in depends){ |
259 | pkgcnt++; | | 259 | pkgcnt++; |
260 | pkgdir = PKGSRCDIR "/" toppkg; | | 260 | pkgdir = PKGSRCDIR "/" toppkg; |
261 | readmenew=pkgdir "/" readme_name; | | 261 | readmenew=pkgdir "/" readme_name; |
262 | | | 262 | |
263 | if (debug) printf("Creating %s for %s\n", | | 263 | if (debug) printf("Creating %s for %s\n", |
264 | readme, readmenew); | | 264 | readme, readmenew); |
265 | if (quiet != "yes") { | | 265 | if (quiet != "yes") { |
266 | printf("."); | | 266 | printf("."); |
267 | if ((pkgcnt % 100) == 0) { | | 267 | if ((pkgcnt % 100) == 0) { |
268 | printf("\n%d\n", pkgcnt); | | 268 | printf("\n%d\n", pkgcnt); |
269 | } | | 269 | } |
270 | } | | 270 | } |
271 | printf("") > readme; | | 271 | printf("") > readme; |
272 | | | 272 | |
273 | run_deps = create_htmldeps(uniq(depends[toppkg])); | | 273 | run_deps = create_htmldeps(uniq(depends[toppkg])); |
274 | build_deps = create_htmldeps(uniq(builddepends[toppkg])); | | 274 | build_deps = create_htmldeps(uniq(builddepends[toppkg])); |
275 | | | 275 | |
276 | vul = ""; | | 276 | vul = ""; |
277 | | | 277 | |
278 | if (SCAN_VULNERABILITIES == 2) { | | 278 | if (SCAN_VULNERABILITIES == 2) { |
279 | pkgbase = pkgdir2name[toppkg]; | | 279 | pkgbase = pkgdir2name[toppkg]; |
280 | sub("-[^-]*$", "", pkgbase); | | 280 | sub("-[^-]*$", "", pkgbase); |
281 | cmd = sprintf("%s audit-history %s", PKG_ADMIN, pkgbase); | | 281 | cmd = sprintf("%s audit-history %s", PKG_ADMIN, pkgbase); |
282 | while (cmd | getline vuln_entry) { | | 282 | while (cmd | getline vuln_entry) { |
283 | split(vuln_entry, entry, " "); | | 283 | split(vuln_entry, entry, " "); |
284 | 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", |
285 | PKG_ADMIN, entry[1], pkgdir2name[toppkg]); | | 285 | PKG_ADMIN, entry[1], pkgdir2name[toppkg]); |
286 | status_cmd | getline status | | 286 | status_cmd | getline status |
287 | close(status_cmd) | | 287 | close(status_cmd) |
288 | if (status == "fixed") | | 288 | if (status == "fixed") |
289 | continue | | 289 | continue |
290 | status = "a " status; | | 290 | status = "a " status; |
291 | 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", |
292 | vul, status, entry[3], entry[2]); | | 292 | vul, status, entry[3], entry[2]); |
293 | } | | 293 | } |
294 | close(cmd); | | 294 | close(cmd); |
295 | | | 295 | |
296 | if ( vul == "" ) { | | 296 | if ( vul == "" ) { |
297 | vul="<em>(no vulnerabilities known)</em>"; | | 297 | vul="<em>(no vulnerabilities known)</em>"; |
298 | } | | 298 | } |
299 | } | | 299 | } |
300 | | | 300 | |
301 | if (debug) { | | 301 | if (debug) { |
302 | printf("Checking for binary package with lookup_cache( %s)\n", | | 302 | printf("Checking for binary package with lookup_cache( %s)\n", |
303 | toppkg); | | 303 | toppkg); |
304 | } | | 304 | } |
305 | # 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 |
306 | lookup_cache( toppkg ); | | 306 | lookup_cache( toppkg ); |
307 | | | 307 | |
308 | while((getline < templatefile) > 0){ | | 308 | while((getline < templatefile) > 0){ |
309 | gsub(/%%PORT%%/, toppkg); | | 309 | gsub(/%%PORT%%/, toppkg); |
310 | gsub(/%%PKG%%/, pkgdir2name[toppkg]); | | 310 | gsub(/%%PKG%%/, pkgdir2name[toppkg]); |
311 | gsub(/%%MAINTAINER%%/, maintainer[toppkg]); | | 311 | gsub(/%%MAINTAINER%%/, maintainer[toppkg]); |
312 | gsub(/%%COMMENT%%/, comment[toppkg]); | | 312 | gsub(/%%COMMENT%%/, comment[toppkg]); |
313 | if (homepage[toppkg] == "") { | | 313 | if (homepage[toppkg] == "") { |
314 | gsub(/%%HOMEPAGE%%/, "<em>none stated</em>"); | | 314 | gsub(/%%HOMEPAGE%%/, "<em>none stated</em>"); |
315 | } else { | | 315 | } else { |
316 | gsub(/%%HOMEPAGE%%/, "<a href=\"" \ | | 316 | gsub(/%%HOMEPAGE%%/, "<a href=\"" \ |
317 | homepage[toppkg] "\">" homepage[toppkg] "</a>"); | | 317 | homepage[toppkg] "\">" homepage[toppkg] "</a>"); |
318 | } | | 318 | } |
319 | if (license[toppkg] == "") { | | 319 | if (license[toppkg] == "") { |
320 | gsub(/%%LICENSE%%/, "<em>none stated</em>"); | | 320 | gsub(/%%LICENSE%%/, "<em>none stated</em>"); |
321 | } else { | | 321 | } else { |
322 | gsub(/%%LICENSE%%/, "<a href=\"../../licenses/" \ | | 322 | gsub(/%%LICENSE%%/, "<a href=\"../../licenses/" \ |
323 | license[toppkg] "\">" license[toppkg] "</a>"); | | 323 | license[toppkg] "\">" license[toppkg] "</a>"); |
324 | } | | 324 | } |
325 | gsub(/%%VULNERABILITIES%%/, ""vul""); | | 325 | gsub(/%%VULNERABILITIES%%/, ""vul""); |
326 | gsub(/%%VULDATE%%/, ""vuldate""); | | 326 | gsub(/%%VULDATE%%/, ""vuldate""); |
327 | gsub(/%%OPTIONS%%/, escape_re_replacement(""options[toppkg]"")); | | 327 | gsub(/%%OPTIONS%%/, escape_re_replacement(""options[toppkg]"")); |
328 | | | 328 | |
329 | gsub(/%%BUILD_DEPENDS%%/, ""build_deps""); | | 329 | gsub(/%%BUILD_DEPENDS%%/, ""build_deps""); |
330 | gsub(/%%RUN_DEPENDS%%/, ""run_deps""); | | 330 | gsub(/%%RUN_DEPENDS%%/, ""run_deps""); |
331 | | | 331 | |
332 | line = $0; | | 332 | line = $0; |
333 | | | 333 | |
334 | if( line ~/%%BIN_PKGS%%/ ) { | | 334 | if( line ~/%%BIN_PKGS%%/ ) { |
335 | gsub(/%%BIN_PKGS%%/, "", line); | | 335 | gsub(/%%BIN_PKGS%%/, "", line); |
336 | while((getline < binpkgs_file) > 0) { | | 336 | while((getline < binpkgs_file) > 0) { |
337 | print >> readme; | | 337 | print >> readme; |
338 | } | | 338 | } |
339 | close( binpkgs_file ); | | 339 | close( binpkgs_file ); |
340 | } | | 340 | } |
341 | | | 341 | |
342 | descr_file = pkgdir "/DESCR" | | 342 | descr_file = pkgdir "/DESCR" |
343 | | | 343 | |
344 | if( line ~/%%DESCR%%/ ) { | | 344 | if( line ~/%%DESCR%%/ ) { |
345 | gsub(/%%DESCR%%/, "", line); | | 345 | gsub(/%%DESCR%%/, "", line); |
346 | while((getline < descr_file ) > 0) { | | 346 | while((getline < descr_file ) > 0) { |
347 | print >> readme; | | 347 | print >> readme; |
348 | } | | 348 | } |
349 | close( descr_file ); | | 349 | close( descr_file ); |
350 | } | | 350 | } |
351 | | | 351 | |
352 | print line >> readme; | | 352 | print line >> readme; |
353 | } | | 353 | } |
354 | close(readme); | | 354 | close(readme); |
355 | close(templatefile); | | 355 | close(templatefile); |
356 | cmd = "if [ ! -d " pkgdir " ]; then exit 1 ; fi"; | | 356 | cmd = "if [ ! -d " pkgdir " ]; then exit 1 ; fi"; |
357 | if (debug) printf("Execute: %s\n",cmd); | | 357 | if (debug) printf("Execute: %s\n",cmd); |
358 | rc = system(cmd); | | 358 | rc = system(cmd); |
359 | if (rc != 0) { | | 359 | if (rc != 0) { |
360 | printf("\n**** WARNING ****\nPackage directory %s\n", | | 360 | printf("\n**** WARNING ****\nPackage directory %s\n", |
361 | pkgdir) > "/dev/stderr"; | | 361 | pkgdir) > "/dev/stderr"; |
362 | printf("Does not exist. This is probably ") > "/dev/stderr"; | | 362 | printf("Does not exist. This is probably ") > "/dev/stderr"; |
363 | printf("due to an incorrect DEPENDS line.\n") > "/dev/stderr"; | | 363 | printf("due to an incorrect DEPENDS line.\n") > "/dev/stderr"; |
364 | printf("Try running: grep %s */*/Makefile\n", fulldir2pkgdir(pkgdir)) > "/dev/stderr"; | | 364 | printf("Try running: grep %s */*/Makefile\n", fulldir2pkgdir(pkgdir)) > "/dev/stderr"; |
365 | printf("or: grep %s */*/buildlink3.mk\n", fulldir2pkgdir(pkgdir)) > "/dev/stderr"; | | 365 | printf("or: grep %s */*/buildlink3.mk\n", fulldir2pkgdir(pkgdir)) > "/dev/stderr"; |
366 | printf("to find the problem\n", pkgdir) > "/dev/stderr"; | | 366 | printf("to find the problem\n", pkgdir) > "/dev/stderr"; |
367 | printf("**** ------- ****\n") > "/dev/stderr"; | | 367 | printf("**** ------- ****\n") > "/dev/stderr"; |
368 | } else { | | 368 | } else { |
369 | copy_readme(readmenew, readme); | | 369 | copy_readme(readmenew, readme); |
370 | } | | 370 | } |
371 | } | | 371 | } |
372 | printf("\n"); | | 372 | printf("\n"); |
373 | } # if (do_pkg_readme) | | 373 | } # if (do_pkg_readme) |
374 | printf("\n"); | | 374 | printf("\n"); |
375 | if (SINGLEPKG != "" ) { | | 375 | if (SINGLEPKG != "" ) { |
376 | close("/dev/stderr"); | | 376 | close("/dev/stderr"); |
377 | exit 0; | | 377 | exit 0; |
378 | } | | 378 | } |
379 | printf("Generating category readmes\n"); | | 379 | printf("Generating category readmes\n"); |
380 | templatefile = PKGSRCDIR "/templates/README.category"; | | 380 | templatefile = PKGSRCDIR "/templates/README.category"; |
381 | fatal_check_file(templatefile); | | 381 | fatal_check_file(templatefile); |
382 | | | 382 | |
383 | # string with URLs for all categories (used by the top README.html) | | 383 | # string with URLs for all categories (used by the top README.html) |
384 | allcat = ""; | | 384 | allcat = ""; |
385 | # string with URLs for all pkgs (used by the top README-all.html) | | 385 | # string with URLs for all pkgs (used by the top README-all.html) |
386 | tot_numpkg = 0; | | 386 | tot_numpkg = 0; |
387 | top_make = PKGSRCDIR"/Makefile"; | | 387 | top_make = PKGSRCDIR"/Makefile"; |
388 | while((getline < top_make) > 0){ | | 388 | while((getline < top_make) > 0){ |
389 | if ($0 ~ /^[ \t]*SUBDIR.*=[^\$]*$/) { | | 389 | if ($0 ~ /^[ \t]*SUBDIR.*=[^\$]*$/) { |
390 | category = $0; | | 390 | category = $0; |
391 | gsub(/^[ \t]*SUBDIR.*=[ \t]*/, "", category); | | 391 | gsub(/^[ \t]*SUBDIR.*=[ \t]*/, "", category); |
392 | catdir = PKGSRCDIR"/"category; | | 392 | catdir = PKGSRCDIR"/"category; |
393 | readmenew = catdir"/"readme_name; | | 393 | readmenew = catdir"/"readme_name; |
394 | if (quiet != "yes") { | | 394 | if (quiet != "yes") { |
395 | printf("Category = %s\n", category); | | 395 | printf("Category = %s\n", category); |
396 | } | | 396 | } |
397 | cat_make = catdir"/Makefile"; | | 397 | cat_make = catdir"/Makefile"; |
398 | pkgs = ""; | | 398 | pkgs = ""; |
399 | numpkg = 0; | | 399 | numpkg = 0; |
400 | print "" > readme; | | 400 | print "" > readme; |
401 | while((getline < cat_make) > 0){ | | 401 | while((getline < cat_make) > 0){ |
402 | if ($0 ~ /^[ \t]*SUBDIR.*=[^\$]*$/) { | | 402 | if ($0 ~ /^[ \t]*SUBDIR.*=[^\$]*$/) { |
403 | pkg = $0; | | 403 | pkg = $0; |
404 | gsub(/^[ \t]*SUBDIR.*=[ \t]*/, "", | | 404 | gsub(/^[ \t]*SUBDIR.*=[ \t]*/, "", |
405 | pkg); | | 405 | pkg); |
406 | dir = category"/"pkg; | | 406 | dir = category"/"pkg; |
407 | numpkg++; | | 407 | numpkg++; |
408 | tot_numpkg++; | | 408 | tot_numpkg++; |
409 | if (debug) { | | 409 | if (debug) { |
410 | printf("\tAdding %s (%s : %s)\n", | | 410 | printf("\tAdding %s (%s : %s)\n", |
411 | dir, | | 411 | dir, |
412 | pkgdir2name[dir], | | 412 | pkgdir2name[dir], |
413 | comment[dir]); | | 413 | comment[dir]); |
414 | } | | 414 | } |
415 | pkgs = sprintf("%s<dt><a href=\"%s/%s\">%s</a></dt><dd>%s</dd>\n", | | 415 | pkgs = sprintf("%s<dt><a href=\"%s/%s\">%s</a></dt><dd>%s</dd>\n", |
416 | pkgs, | | 416 | pkgs, |
417 | pkg, readme_name, | | 417 | pkg, readme_name, |
418 | pkgdir2name[dir], | | 418 | pkgdir2name[dir], |
419 | comment[dir]); | | 419 | comment[dir]); |
420 | # Prefix with the package name in a comment for sorting. | | 420 | # Prefix with the package name in a comment for sorting. |
421 | allpkg[tot_numpkg] = sprintf("<!-- %s --><dt><a href=\"%s/%s/%s\">%s</a></dt><dd>%s</dd>\n", | | 421 | allpkg[tot_numpkg] = sprintf("<!-- %s --><dt><a href=\"%s/%s/%s\">%s</a></dt><dd>%s</dd>\n", |
422 | pkgdir2name[dir], | | 422 | pkgdir2name[dir], |
423 | category, pkg, | | 423 | category, pkg, |
424 | readme_name, | | 424 | readme_name, |
425 | pkgdir2name[dir], | | 425 | pkgdir2name[dir], |
426 | comment[dir]); | | 426 | comment[dir]); |
427 | # we need slightly fewer escapes here since we are not gsub()-ing | | 427 | # we need slightly fewer escapes here since we are not gsub()-ing |
428 | # allpkg[] into the output files but just printf()-ing it. | | 428 | # allpkg[] into the output files but just printf()-ing it. |
429 | gsub(/\\&/, "\\&", allpkg[tot_numpkg]); | | 429 | gsub(/\\&/, "\\&", allpkg[tot_numpkg]); |
430 | } else if ($0 ~ /^[ \t]*COMMENT/) { | | 430 | } else if ($0 ~ /^[ \t]*COMMENT/) { |
431 | descr = $0; | | 431 | descr = $0; |
432 | gsub(/^[ \t]*COMMENT.*=[ \t]*/, "", | | 432 | gsub(/^[ \t]*COMMENT.*=[ \t]*/, "", |
433 | descr); | | 433 | descr); |
434 | } | | 434 | } |
435 | } | | 435 | } |
436 | while ((getline < templatefile) > 0){ | | 436 | while ((getline < templatefile) > 0){ |
437 | gsub(/%%CATEGORY%%/, category); | | 437 | gsub(/%%CATEGORY%%/, category); |
438 | gsub(/%%NUMITEMS%%/, numpkg); | | 438 | gsub(/%%NUMITEMS%%/, numpkg); |
439 | gsub(/%%DESCR%%/, descr); | | 439 | gsub(/%%DESCR%%/, descr); |
440 | gsub(/%%SUBDIR%%/, ""pkgs""); | | 440 | gsub(/%%SUBDIR%%/, ""pkgs""); |
441 | | | 441 | |
442 | print $0 >> readme; | | 442 | print $0 >> readme; |
443 | } | | 443 | } |
444 | close(readme); | | 444 | close(readme); |
445 | close(templatefile); | | 445 | close(templatefile); |
446 | copy_readme(readmenew, readme); | | 446 | copy_readme(readmenew, readme); |
447 | | | 447 | |
448 | gsub(/href=\"/, "href=\""category"/", pkgs); | | 448 | gsub(/href=\"/, "href=\""category"/", pkgs); |
449 | allcat = sprintf("%s<dt><a href=\"%s/%s\">%s</a></dt><dd>%s</dd>\n", | | 449 | allcat = sprintf("%s<dt><a href=\"%s/%s\">%s</a></dt><dd>%s</dd>\n", |
450 | allcat, category, readme_name, | | 450 | allcat, category, readme_name, |
451 | category, descr); | | 451 | category, descr); |
452 | close(cat_make); | | 452 | close(cat_make); |
453 | } | | 453 | } |
454 | } | | 454 | } |
455 | close(top_make); | | 455 | close(top_make); |
456 | | | 456 | |
457 | printf("Generating toplevel readmes:\n"); | | 457 | printf("Generating toplevel readmes:\n"); |
458 | templatefile = PKGSRCDIR "/templates/README.top"; | | 458 | templatefile = PKGSRCDIR "/templates/README.top"; |
459 | fatal_check_file(templatefile); | | 459 | fatal_check_file(templatefile); |
460 | readmenew = PKGSRCDIR "/"readme_name; | | 460 | readmenew = PKGSRCDIR "/"readme_name; |
461 | printf("\t%s\n", readmenew); | | 461 | printf("\t%s\n", readmenew); |
462 | print "" > readme; | | 462 | print "" > readme; |
463 | while((getline < templatefile) > 0){ | | 463 | while((getline < templatefile) > 0){ |
464 | gsub(/%%DESCR%%/, ""); | | 464 | gsub(/%%DESCR%%/, ""); |
465 | gsub(/%%SUBDIR%%/, allcat); | | 465 | gsub(/%%SUBDIR%%/, allcat); |
466 | gsub(/README.html/, readme_name); | | 466 | gsub(/README.html/, readme_name); |
467 | print >> readme; | | 467 | print >> readme; |
468 | } | | 468 | } |
469 | close(readme); | | 469 | close(readme); |
470 | close(templatefile); | | 470 | close(templatefile); |
471 | copy_readme(readmenew, readme); | | 471 | copy_readme(readmenew, readme); |
472 | | | 472 | |
473 | templatefile = PKGSRCDIR "/templates/README.all"; | | 473 | templatefile = PKGSRCDIR "/templates/README.all"; |
474 | fatal_check_file(templatefile); | | 474 | fatal_check_file(templatefile); |
475 | readmenew = PKGSRCDIR "/README-all.html"; | | 475 | readmenew = PKGSRCDIR "/README-all.html"; |
476 | printf("\t%s\n", readmenew); | | 476 | printf("\t%s\n", readmenew); |
477 | # sort the pkgs | | 477 | # sort the pkgs |
478 | sfile = TMPDIR"/unsorted"; | | 478 | sfile = TMPDIR"/unsorted"; |
479 | spipe = "sort " sfile; | | 479 | spipe = "sort " sfile; |
480 | i = 1; | | 480 | i = 1; |
481 | print "" >sfile; | | 481 | print "" >sfile; |
482 | while(i in allpkg) { | | 482 | while(i in allpkg) { |
483 | printf("%s",allpkg[i]) >> sfile; | | 483 | printf("%s",allpkg[i]) >> sfile; |
484 | i++; | | 484 | i++; |
485 | } | | 485 | } |
486 | close(sfile); | | 486 | close(sfile); |
487 | | | 487 | |
488 | print "" > readme; | | 488 | print "" > readme; |
489 | while((getline < templatefile) > 0){ | | 489 | while((getline < templatefile) > 0){ |
490 | line = $0; | | 490 | line = $0; |
491 | if ($0 ~ /%%PKGS%%/) { | | 491 | if ($0 ~ /%%PKGS%%/) { |
492 | while((spipe | getline) > 0) { | | 492 | while((spipe | getline) > 0) { |
493 | print >> readme; | | 493 | print >> readme; |
494 | } | | 494 | } |
495 | close(spipe); | | 495 | close(spipe); |
496 | } else { | | 496 | } else { |
497 | gsub(/%%DESCR%%/, "", line); | | 497 | gsub(/%%DESCR%%/, "", line); |
498 | gsub(/%%NPKGS%%/, tot_numpkg, line); | | 498 | gsub(/%%NPKGS%%/, tot_numpkg, line); |
499 | gsub(/README.html/, readme_name, line); | | 499 | gsub(/README.html/, readme_name, line); |
500 | print line >> readme; | | 500 | print line >> readme; |
501 | } | | 501 | } |
502 | } | | 502 | } |
503 | close(readme); | | 503 | close(readme); |
504 | close(templatefile); | | 504 | close(templatefile); |
505 | copy_readme(readmenew, readme); | | 505 | copy_readme(readmenew, readme); |
506 | | | 506 | |
507 | close("/dev/stderr"); | | 507 | close("/dev/stderr"); |
508 | exit 0; | | 508 | exit 0; |
509 | } | | 509 | } |
510 | | | 510 | |
511 | function create_htmldeps(dependslist){ | | 511 | function create_htmldeps(dependslist){ |
512 | htmldeps = ""; | | 512 | htmldeps = ""; |
513 | for( key in dpkgs ) { | | 513 | for( key in dpkgs ) { |
514 | delete dpkgs[key]; | | 514 | delete dpkgs[key]; |
515 | } | | 515 | } |
516 | split(dependslist, dpkgs); | | 516 | split(dependslist, dpkgs); |
517 | i = 1; | | 517 | i = 1; |
518 | while(i in dpkgs){ | | 518 | while(i in dpkgs){ |
519 | if (debug) { | | 519 | if (debug) { |
520 | printf("\tdpkg=%s, pat2dir[%s] = %s\n", | | 520 | printf("\tdpkg=%s, pat2dir[%s] = %s\n", |
521 | dpkgs[i], | | 521 | dpkgs[i], |
522 | dpkgs[i], | | 522 | dpkgs[i], |
523 | pat2dir[dpkgs[i]]); | | 523 | pat2dir[dpkgs[i]]); |
524 | } | | 524 | } |
525 | htmldeps = sprintf("%s<a href=\"../../%s/%s\">%s</a>\n", | | 525 | htmldeps = sprintf("%s<a href=\"../../%s/%s\">%s</a>\n", |
526 | htmldeps, | | 526 | htmldeps, |
527 | pat2dir[dpkgs[i]], | | 527 | pat2dir[dpkgs[i]], |
528 | readme_name, | | 528 | readme_name, |
529 | pat2dir[dpkgs[i]]); | | 529 | pat2dir[dpkgs[i]]); |
530 | i = i + 1; | | 530 | i = i + 1; |
531 | } | | 531 | } |
532 | if ( i == 1 ) { | | 532 | if ( i == 1 ) { |
533 | htmldeps = "<em>(none)</em>"; | | 533 | htmldeps = "<em>(none)</em>"; |
534 | } | | 534 | } |
535 | return htmldeps; | | 535 | return htmldeps; |
536 | } | | 536 | } |
537 | | | 537 | |
538 | # | | 538 | # |
539 | # take a string which has special characters like '+' in it and | | 539 | # take a string which has special characters like '+' in it and |
540 | # escape them. Also put a space before and after since that's how | | 540 | # escape them. Also put a space before and after since that's how |
541 | # we'll distinguish things like gnome from gnome-libs | | 541 | # we'll distinguish things like gnome from gnome-libs |
542 | # | | 542 | # |
543 | function reg2str(reg){ | | 543 | function reg2str(reg){ |
544 | gsub(/\./, "\\.", reg); | | 544 | gsub(/\./, "\\.", reg); |
545 | gsub(/\+/, "\\+", reg); | | 545 | gsub(/\+/, "\\+", reg); |
546 | gsub(/\*/, "\\*", reg); | | 546 | gsub(/\*/, "\\*", reg); |
547 | gsub(/\?/, "\\?", reg); | | 547 | gsub(/\?/, "\\?", reg); |
548 | gsub(/\[/, "\\[", reg); | | 548 | gsub(/\[/, "\\[", reg); |
549 | gsub(/\]/, "\\]", reg); | | 549 | gsub(/\]/, "\\]", reg); |
550 | reg = " "reg" "; | | 550 | reg = " "reg" "; |
551 | return(reg); | | 551 | return(reg); |
552 | } | | 552 | } |
553 | | | 553 | |
554 | function escape_re_replacement(s) { | | 554 | function escape_re_replacement(s) { |
555 | gsub(/&/, "\\\\\\&", s); | | 555 | gsub(/&/, "\\\\\\&", s); |
556 | return s; | | 556 | return s; |
557 | } | | 557 | } |
558 | | | 558 | |
559 | # | | 559 | # |
560 | # take a string which has a shell glob pattern and turn it into | | 560 | # take a string which has a shell glob pattern and turn it into |
561 | # an awk regular expression. | | 561 | # an awk regular expression. |
562 | # | | 562 | # |
563 | function glob2reg(reg){ | | 563 | function glob2reg(reg){ |
564 | | | 564 | |
565 | # escape some characters which are special in regular expressions | | 565 | # escape some characters which are special in regular expressions |
566 | gsub(/\./, "\\.", reg); | | 566 | gsub(/\./, "\\.", reg); |
567 | gsub(/\+/, "\\+", reg); | | 567 | gsub(/\+/, "\\+", reg); |
568 | | | 568 | |
569 | # and reformat some others | | 569 | # and reformat some others |
570 | gsub(/\*/, ".*", reg); | | 570 | gsub(/\*/, ".*", reg); |
571 | gsub(/\?/, ".?", reg); | | 571 | gsub(/\?/, ".?", reg); |
572 | | | 572 | |
573 | # finally, expand {a,b,c} type patterns | | 573 | # finally, expand {a,b,c} type patterns |
574 | | | 574 | |
575 | return(reg); | | 575 | return(reg); |
576 | } | | 576 | } |
577 | | | 577 | |
578 | # | | 578 | # |
579 | # accepts a full path to a package directory, like "/usr/pkgsrc/math/scilab" | | 579 | # accepts a full path to a package directory, like "/usr/pkgsrc/math/scilab" |
580 | # and returns just the last 2 directories, like "math/scilab" | | 580 | # and returns just the last 2 directories, like "math/scilab" |
581 | # | | 581 | # |
582 | function fulldir2pkgdir(d, i){ | | 582 | function fulldir2pkgdir(d, i){ |
583 | i = match(d, /\/[^\/]+\/[^\/]+$/); | | 583 | i = match(d, /\/[^\/]+\/[^\/]+$/); |
584 | return substr(d, i + 1); | | 584 | return substr(d, i + 1); |
585 | } | | 585 | } |
586 | | | 586 | |
587 | # | | 587 | # |
588 | # take the depends lists and uniq them. | | 588 | # take the depends lists and uniq them. |
589 | # | | 589 | # |
590 | function uniq(list, deps, i, ulist){ | | 590 | function uniq(list, deps, i, ulist){ |
591 | | | 591 | |
592 | # split out the depends | | 592 | # split out the depends |
593 | split(list, deps); | | 593 | split(list, deps); |
594 | | | 594 | |
595 | i = 1; | | 595 | i = 1; |
596 | ulist = " "; | | 596 | ulist = " "; |
597 | while (i in deps){ | | 597 | while (i in deps){ |
598 | # printf("uniq(): Checking \"%s\"\n", ulist); | | 598 | # printf("uniq(): Checking \"%s\"\n", ulist); |
599 | # printf(" for \"%s\"\n", reg2str(deps[i])); | | 599 | # printf(" for \"%s\"\n", reg2str(deps[i])); |
600 | if (ulist !~reg2str(deps[i])){ | | 600 | if (ulist !~reg2str(deps[i])){ |
601 | ulist = ulist deps[i]" "; | | 601 | ulist = ulist deps[i]" "; |
602 | } | | 602 | } |
603 | i++; | | 603 | i++; |
604 | } | | 604 | } |
605 | return(ulist); | | 605 | return(ulist); |
606 | } | | 606 | } |
607 | | | 607 | |
608 | function fatal_check_file(file, cmd){ | | 608 | function fatal_check_file(file, cmd){ |
609 | cmd="test -f " file ; | | 609 | cmd="test -f " file ; |
610 | if (debug) printf("Execute: %s\n",cmd); | | 610 | if (debug) printf("Execute: %s\n",cmd); |
611 | if (system(cmd) != 0) { | | 611 | if (system(cmd) != 0) { |
612 | printf("**** FATAL ****\nRequired file %s does not exist\n", | | 612 | printf("**** FATAL ****\nRequired file %s does not exist\n", |
613 | file) > "/dev/stderr"; | | 613 | file) > "/dev/stderr"; |
614 | printf("**** ------- ****\n") > "/dev/stderr"; | | 614 | printf("**** ------- ****\n") > "/dev/stderr"; |
615 | close("/dev/stderr"); | | 615 | close("/dev/stderr"); |
616 | exit(1); | | 616 | exit(1); |
617 | } | | 617 | } |
618 | } | | 618 | } |
619 | | | 619 | |
620 | # 'new' is the newly created README.html file | | 620 | # 'new' is the newly created README.html file |
621 | # 'old' is the existing (possibly not present) README.html file | | 621 | # 'old' is the existing (possibly not present) README.html file |
622 | # | | 622 | # |
623 | # This function copies over the 'new' file if the 'old' one does | | 623 | # This function copies over the 'new' file if the 'old' one does |
624 | # not exist or if they are different. In addition, the 'new' one | | 624 | # not exist or if they are different. In addition, the 'new' one |
625 | # which is a temporary file is removed at the end | | 625 | # which is a temporary file is removed at the end |
626 | | | 626 | |
627 | function copy_readme(old, new, cmd, rc) { | | 627 | function copy_readme(old, new, cmd, rc) { |
628 | | | 628 | |
629 | # if the README.html file does not exist at all then copy over | | 629 | # if the README.html file does not exist at all then copy over |
630 | # the one we created | | 630 | # the one we created |
631 | | | 631 | |
632 | cmd = "if [ ! -f "old" ]; then cp " new " " old " ; fi"; | | 632 | cmd = "if [ ! -f "old" ]; then cp " new " " old " ; fi"; |
633 | if (debug) printf("copy_readme() execute: %s\n",cmd); | | 633 | if (debug) printf("copy_readme() execute: %s\n",cmd); |
634 | rc = system(cmd); | | 634 | rc = system(cmd); |
635 | if (rc != 0) { | | 635 | if (rc != 0) { |
636 | printf("**** WARNING ****\nThe command\n %s\n", cmd) > "/dev/stderr"; | | 636 | printf("**** WARNING ****\nThe command\n %s\n", cmd) > "/dev/stderr"; |
637 | printf("failed with result code %d\n", rc) > "/dev/stderr"; | | 637 | printf("failed with result code %d\n", rc) > "/dev/stderr"; |
638 | printf("**** ------- ****\n") > "/dev/stderr"; | | 638 | printf("**** ------- ****\n") > "/dev/stderr"; |
639 | } | | 639 | } |
640 | | | 640 | |
641 | # Compare the existing README.html file to the one we created. If they are | | 641 | # Compare the existing README.html file to the one we created. If they are |
642 | # not the same, then copy over the one we created | | 642 | # not the same, then copy over the one we created |
643 | | | 643 | |
644 | cmd = sprintf("%s -s %s %s ; if test $? -ne 0 ; then mv -f %s %s ; fi", | | 644 | cmd = sprintf("%s -s %s %s ; if test $? -ne 0 ; then mv -f %s %s ; fi", |
645 | CMP, new, old, new, old); | | 645 | CMP, new, old, new, old); |
646 | if (debug) printf("copy_readme() execute: %s\n",cmd); | | 646 | if (debug) printf("copy_readme() execute: %s\n",cmd); |
647 | rc = system(cmd); | | 647 | rc = system(cmd); |
648 | if (rc != 0) { | | 648 | if (rc != 0) { |
649 | printf("**** WARNING ****\nThe command\n %s\n", cmd) > "/dev/stderr"; | | 649 | printf("**** WARNING ****\nThe command\n %s\n", cmd) > "/dev/stderr"; |
650 | printf("failed with result code %d\n", rc) > "/dev/stderr"; | | 650 | printf("failed with result code %d\n", rc) > "/dev/stderr"; |
651 | printf("**** ------- ****\n") > "/dev/stderr"; | | 651 | printf("**** ------- ****\n") > "/dev/stderr"; |
652 | } | | 652 | } |
653 | | | 653 | |
654 | # If the temp file still exists, then delete it | | 654 | # If the temp file still exists, then delete it |
655 | cmd = " if [ -f "new" ]; then rm -f "new" ; fi"; | | 655 | cmd = " if [ -f "new" ]; then rm -f "new" ; fi"; |
656 | if (debug) printf("copy_readme() execute: %s\n",cmd); | | 656 | if (debug) printf("copy_readme() execute: %s\n",cmd); |
657 | rc = system(cmd); | | 657 | rc = system(cmd); |
658 | if (rc != 0) { | | 658 | if (rc != 0) { |
659 | printf("**** WARNING ****\nThe command\n %s\n", cmd) > "/dev/stderr"; | | 659 | printf("**** WARNING ****\nThe command\n %s\n", cmd) > "/dev/stderr"; |
660 | printf("failed with result code %d\n", rc) > "/dev/stderr"; | | 660 | printf("failed with result code %d\n", rc) > "/dev/stderr"; |
661 | printf("**** ------- ****\n") > "/dev/stderr"; | | 661 | printf("**** ------- ****\n") > "/dev/stderr"; |
662 | } | | 662 | } |
663 | | | 663 | |
664 | } | | 664 | } |
665 | | | 665 | |
666 | | | 666 | |
667 | function load_cache_file( file, pkgfile, opsys, osver, march, wk, rx ) { | | 667 | function load_cache_file( file, pkgfile, opsys, osver, march, wk, rx ) { |
668 | if ( quiet != "yes" ) printf(" * %s\n", file); | | 668 | if ( quiet != "yes" ) printf(" * %s\n", file); |
669 | fatal_check_file( file ); | | 669 | fatal_check_file( file ); |
670 | | | 670 | |
671 | # read the cache file | | 671 | # read the cache file |
672 | while( getline < file ) { | | 672 | while( getline < file ) { |
673 | | | 673 | |
674 | # if this line points to another cache file, then recursively | | 674 | # if this line points to another cache file, then recursively |
675 | # load it | | 675 | # load it |
676 | if( $0 ~ /^pkgcache_cachefile/ ) { | | 676 | if( $0 ~ /^pkgcache_cachefile/ ) { |
677 | if( debug ) printf("\tFound pkgcache_cachefile line.\n"); | | 677 | if( debug ) printf("\tFound pkgcache_cachefile line.\n"); |
678 | load_cache_file( $2 ); | | 678 | load_cache_file( $2 ); |
679 | } else if( $0 ~/^pkgcache_begin /) { | | 679 | } else if( $0 ~/^pkgcache_begin /) { |
680 | pkgfile = $2; | | 680 | pkgfile = $2; |
681 | if( debug ) printf("\tStarting %s\n", pkgfile); | | 681 | if( debug ) printf("\tStarting %s\n", pkgfile); |
682 | opsys = "unknown"; | | 682 | opsys = "unknown"; |
683 | osver = "unknown"; | | 683 | osver = "unknown"; |
684 | march = "unknown"; | | 684 | march = "unknown"; |
685 | pkgpath = "unknown"; | | 685 | pkgpath = "unknown"; |
686 | } else if( $0 ~/^PKGPATH=/ ) { | | 686 | } else if( $0 ~/^PKGPATH=/ ) { |
687 | pkgpath = $0; | | 687 | pkgpath = $0; |
688 | gsub(/PKGPATH=[ \t]*/, "", pkgpath); | | 688 | gsub(/PKGPATH=[ \t]*/, "", pkgpath); |
689 | } else if( $0 ~/^OPSYS=/ ) { | | 689 | } else if( $0 ~/^OPSYS=/ ) { |
690 | opsys = $0; | | 690 | opsys = $0; |
691 | gsub(/OPSYS=[ \t]*/, "", opsys); | | 691 | gsub(/OPSYS=[ \t]*/, "", opsys); |
692 | } else if( $0 ~/^OS_VERSION=/ ) { | | 692 | } else if( $0 ~/^OS_VERSION=/ ) { |
693 | osver = $0; | | 693 | osver = $0; |
694 | gsub(/OS_VERSION=[ \t]*/, "", osver); | | 694 | gsub(/OS_VERSION=[ \t]*/, "", osver); |
695 | } else if( $0 ~/^MACHINE_ARCH=/ ) { | | 695 | } else if( $0 ~/^MACHINE_ARCH=/ ) { |
696 | march = $0; | | 696 | march = $0; |
697 | gsub(/MACHINE_ARCH=[ \t]*/, "", march); | | 697 | gsub(/MACHINE_ARCH=[ \t]*/, "", march); |
698 | } else if( $0 ~/^pkgcache_end /) { | | 698 | } else if( $0 ~/^pkgcache_end /) { |
699 | if( debug ) printf("\t%s, OPSYS=%s, OS_VERSION=%s, MACHINE_ARCH=%s, PKGPATH=%s\n", | | 699 | if( debug ) printf("\t%s, OPSYS=%s, OS_VERSION=%s, MACHINE_ARCH=%s, PKGPATH=%s\n", |
700 | pkgfile, opsys, osver, march, pkpath); | | 700 | pkgfile, opsys, osver, march, pkpath); |
701 | | | 701 | |
702 | pkg_count[pkgpath] = pkg_count[pkgpath] + 1; | | 702 | pkg_count[pkgpath] = pkg_count[pkgpath] + 1; |
703 | | | 703 | |
704 | opsys_list[pkgpath, pkg_count[pkgpath]] = opsys; | | 704 | opsys_list[pkgpath, pkg_count[pkgpath]] = opsys; |
705 | osver_list[pkgpath, pkg_count[pkgpath]] = osver; | | 705 | osver_list[pkgpath, pkg_count[pkgpath]] = osver; |
706 | march_list[pkgpath, pkg_count[pkgpath]] = march; | | 706 | march_list[pkgpath, pkg_count[pkgpath]] = march; |
707 | pkgfile_list[pkgpath, pkg_count[pkgpath]] = pkgfile; | | 707 | pkgfile_list[pkgpath, pkg_count[pkgpath]] = pkgfile; |
708 | gsub(/.*\//, "", pkgfile); | | 708 | gsub(/.*\//, "", pkgfile); |
709 | pkgnm_list[pkgpath, pkg_count[pkgpath]] = pkgfile; | | 709 | pkgnm_list[pkgpath, pkg_count[pkgpath]] = pkgfile; |
710 | | | 710 | |
711 | } else { | | 711 | } else { |
712 | # skip this line | | 712 | # skip this line |
713 | } | | 713 | } |
714 | } | | 714 | } |
715 | | | 715 | |
716 | # close the cache file | | 716 | # close the cache file |
717 | close( file ); | | 717 | close( file ); |
718 | } | | 718 | } |
719 | | | 719 | |
720 | function lookup_cache( d, binpkgs) { | | 720 | function lookup_cache( d, binpkgs) { |
721 | if( debug ) printf("lookup_cache( %s ): pkg_count = %d\n", | | 721 | if( debug ) printf("lookup_cache( %s ): pkg_count = %d\n", |
722 | d, pkg_count[d]); | | 722 | d, pkg_count[d]); |
723 | | | 723 | |
724 | binpkgs_file = TMPDIR "/binpkgs"; | | 724 | binpkgs_file = TMPDIR "/binpkgs"; |
725 | spipe = SORT " > " binpkgs_file; | | 725 | spipe = SORT " > " binpkgs_file; |
726 | for(i=1 ; i<=pkg_count[d]; i=i+1) { | | 726 | for(i=1 ; i<=pkg_count[d]; i=i+1) { |
727 | printf("<tr><td>%s:<td><a href=\"%s/%s\">%s</a><td>(%s %s)\n", | | 727 | printf("<tr><td>%s %s</td><td>%s</td><td><a href=\"%s/%s\">%s</a></td></tr>\n", |
728 | march_list[d, i], PKG_URL, pkgfile_list[d, i], pkgnm_list[d, i], | | 728 | opsys_list[d, i], osver_list[d, i], march_list[d, i], |
729 | opsys_list[d, i], osver_list[d, i]) | spipe; | | 729 | PKG_URL, pkgfile_list[d, i], pkgnm_list[d, i]) | spipe; |
730 | } | | 730 | } |
731 | if( pkg_count[d] == 0 ) { | | 731 | if( pkg_count[d] == 0 ) { |
732 | printf("<tr><td><em>(none)</em></td></tr>\n") | spipe; | | 732 | printf("<tr><td><em>(none)</em></td></tr>\n") | spipe; |
733 | } | | 733 | } |
734 | | | 734 | |
735 | close( spipe ); | | 735 | close( spipe ); |
736 | } | | 736 | } |
737 | | | 737 | |
738 | | | 738 | |