logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git
commit: 86595977d761baa67c1462efd59a6404b56205ad
parent ba94a8513d9a0aadb3f2c834c74b64aa644c61e8
Author: Michael Forney <mforney@mforney.org>
Date:   Sun, 24 Sep 2017 12:04:42 -0700

tz: Write tzdata hash script in lua

This should make it easier to support the users `config.fs`.

Diffstat:

Mpkg/tz/gen.lua7++++---
Dpkg/tz/tzdata.awk26--------------------------
Apkg/tz/tzdata.lua18++++++++++++++++++
3 files changed, 22 insertions(+), 29 deletions(-)

diff --git a/pkg/tz/gen.lua b/pkg/tz/gen.lua @@ -19,11 +19,12 @@ local tzdata = { 'systemv', 'factory', } -build('awk', '$outdir/tzdata.index', { +rule('tzdata', 'lua $dir/tzdata.lua $repo $outdir/zoneinfo $in >$out.tmp && mv $out.tmp $out') +build('tzdata', '$outdir/tzdata.index', { expand{'$srcdir/', tzdata}, - '|', 'scripts/hash.rc', '$dir/tzdata.awk', + '|', '$dir/tzdata.lua', 'scripts/hash.rc', '||', '$builddir/root.stamp', -}, {expr='-f $dir/tzdata.awk out=$outdir/zoneinfo repo=$repo'}) +}) table.insert(pkg.inputs.index, '$outdir/tzdata.index') fetch 'git' diff --git a/pkg/tz/tzdata.awk b/pkg/tz/tzdata.awk @@ -1,26 +0,0 @@ -# usage: awk -f tzdata.awk repo=out/root.git out=out/pkg/tz/zoneinfo [file...] - -function run(cmd) { - status = system(cmd) - if (status != 0) - exit status -} - -BEGIN { - cmdfmt = "rc ./scripts/hash.rc %s %s share/zoneinfo/%s %s" -} - -FNR == 1 { - run(sprintf("zic -d %s %s", out, FILENAME)) -} - -$1 == "Link" { - s = $3 - gsub(/[^\/]+/, "..", s) - s = substr(s, 1, length(s) - 2) $2 - run(sprintf(cmdfmt, repo, 120000, $3, s)) -} - -$1 == "Zone" { - run(sprintf(cmdfmt, repo, 100644, $2, out "/" $2)) -} diff --git a/pkg/tz/tzdata.lua b/pkg/tz/tzdata.lua @@ -0,0 +1,18 @@ +local cmd = 'rc ./scripts/hash.rc %s %s share/zoneinfo/%s %s' + +repo = arg[1] +outdir = arg[2] +for i = 3, #arg do + for line in io.lines(arg[i]) do + local target, name = line:match('^Link%s+(%g+)%s+(%g+)') + if target then + target = name:gsub('[^/]+', '..'):sub(1, -3)..target + os.execute(cmd:format(repo, 120000, name, target)) + else + name = line:match('^Zone%s+(%g+)') + if name then + os.execute(cmd:format(repo, 100644, name, outdir..'/'..name)) + end + end + end +end