| 1 | ; Run through vpac --recipe-run so the target recipe uses makepkg's real evaluator. |
| 2 | ; Only the declared metadata is read. Its build and package closures stay in the VM. |
| 3 | emit-field := fn(key, value) { |
| 4 | display(key) |
| 5 | display("\t") |
| 6 | display(value) |
| 7 | newline() |
| 8 | } |
| 9 | |
| 10 | defpkgbuild(metadata-reader, |
| 11 | #:pkgname, "metadata-reader", |
| 12 | #:pkgdesc, "Read the dependency fields from a trusted native recipe", |
| 13 | #:pkgver, "1", |
| 14 | #:pkgrel, 1, |
| 15 | #:arch, [#:any], |
| 16 | #:check, fn() { |
| 17 | path := get-environment-variable("VINIX_RECIPE") |
| 18 | recipe := eval(list(string->symbol("include"), path), interaction-environment()) |
| 19 | fields := list("pkgname", "pkgver", "pkgrel", "epoch", "arch", "depends", "makedepends", "checkdepends", "provides") |
| 20 | for-each(fn(key, value) { |
| 21 | if member(key, fields) { |
| 22 | if procedure?(value) { error("the source version must be resolved by a build", path) } |
| 23 | if list?(value) { |
| 24 | for-each(fn(item) { emit-field(key, item) }, value) |
| 25 | } else { |
| 26 | emit-field(key, value) |
| 27 | } |
| 28 | } |
| 29 | }, vector->list(vpac-pkgbuild-keys(recipe)), vector->list(vpac-pkgbuild-values(recipe))) |
| 30 | }, |
| 31 | #:package, fn() { true }) |
| 32 | |