11BEGIN {
22 nrepos = split (repo_paths, repos, " " )
3+ if (min_catalog_major !~ /^ [0 -9 ]+ $ /) {
4+ print " ERROR: min_catalog_major must be a nonnegative integer: " min_catalog_major > " /dev/stderr"
5+ exit 1
6+ }
7+ min_catalog_major = min_catalog_major + 0
38}
49
510function is_version (v ) {
611 return v ~ /^ [0 -9 ]+ \. [0 -9 ]+ (\. [0 -9 ]+ )* $ /
712}
813
14+ function version_major (v , parts ) {
15+ split (v, parts, " ." )
16+ return parts[ 1 ] + 0
17+ }
18+
19+ function version_in_catalog (v ) {
20+ if (! is_version(v)) {
21+ return 0
22+ }
23+ if (min_catalog_major == 0 ) {
24+ return 1
25+ }
26+ return version_major(v) >= min_catalog_major
27+ }
28+
29+ function path_in_catalog (path , n , name , v , parts ) {
30+ n = split (path, parts, " /" )
31+ name = parts[ n]
32+ v = extract_version(name)
33+ if (v == " " ) {
34+ return 1
35+ }
36+ return version_in_catalog(v)
37+ }
38+
939function schema_version (name ) {
1040 if (name !~ /^ fluent-bit-schema-[0 -9 ]+ \. [0 -9 ]+ (\. [0 -9 ]+ )* \. json$ /) {
1141 return " "
@@ -49,10 +79,6 @@ function extract_version(name, rest, i, c, following) {
4979 return rest
5080}
5181
52- function version_includes_linux (v ) {
53- return v ~ /^ [45 ]\. /
54- }
55-
5682function repo_prefix (path , i , p ) {
5783 for (i = 1 ; i <= nrepos; i++ ) {
5884 p = repos[ i]
@@ -117,7 +143,7 @@ function json_url(path) {
117143}
118144
119145function note_linux (v , path , name , repo , key , label , idx ) {
120- if (! version_includes_linux (v)) {
146+ if (! version_in_catalog (v)) {
121147 return
122148 }
123149 key = v SUBSEP path
@@ -212,12 +238,20 @@ function emit_version(v, out, i, repo_key, repo, repos_out, repos_n) {
212238
213239 path = $0
214240 sub (/\r $ /, " " , path)
241+
242+ if (emit_mode == " filter" ) {
243+ if (path_in_catalog(path)) {
244+ print path
245+ }
246+ next
247+ }
248+
215249 n = split (path, parts, " /" )
216250 name = parts[ n]
217251
218252 if (name ~ /^ fluent-bit-schema-[0 -9 ]+ \. [0 -9 ]+ (\. [0 -9 ]+ )* \. json$ /) {
219253 v = schema_version(name)
220- if (is_version (v)) {
254+ if (version_in_catalog (v)) {
221255 versions[ v] = 1
222256 schema[ v] = path
223257 }
@@ -227,7 +261,7 @@ function emit_version(v, out, i, repo_key, repo, repos_out, repos_n) {
227261 if (path ~ /^ windows\/ /) {
228262 v = extract_version(name)
229263 key = windows_key(name, v)
230- if (key != " " ) {
264+ if (key != " " && version_in_catalog(v) ) {
231265 versions[ v] = 1
232266 windows[ v, key] = path
233267 }
@@ -236,7 +270,7 @@ function emit_version(v, out, i, repo_key, repo, repos_out, repos_n) {
236270
237271 if (path ~ /^ macos\/ /) {
238272 v = extract_version(name)
239- if (v == " " ) {
273+ if (v == " " || ! version_in_catalog(v) ) {
240274 next
241275 }
242276 versions[ v] = 1
@@ -254,7 +288,7 @@ function emit_version(v, out, i, repo_key, repo, repos_out, repos_n) {
254288 next
255289 }
256290 v = extract_version(name)
257- if (! is_version (v)) {
291+ if (! version_in_catalog (v)) {
258292 next
259293 }
260294 versions[ v] = 1
@@ -264,8 +298,11 @@ function emit_version(v, out, i, repo_key, repo, repos_out, repos_n) {
264298
265299END {
266300 mode = emit_mode
301+ if (mode == " filter" ) {
302+ exit 0
303+ }
267304 for (v in versions) {
268- if (! is_version (v)) {
305+ if (! version_in_catalog (v)) {
269306 continue
270307 }
271308 if (mode == " versions" ) {
0 commit comments