From 95238ca682eadca3dd1b839b69e375d61e16af24 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Wed, 10 Jul 2019 00:52:58 -0700 Subject: tz: Specify zic outputs explicitly --- pkg/tz/data.awk | 17 ++ pkg/tz/data.lua | 497 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ pkg/tz/gen.lua | 26 ++- pkg/tz/tzdata.lua | 24 --- 4 files changed, 532 insertions(+), 32 deletions(-) create mode 100644 pkg/tz/data.awk create mode 100644 pkg/tz/data.lua delete mode 100644 pkg/tz/tzdata.lua (limited to 'pkg') diff --git a/pkg/tz/data.awk b/pkg/tz/data.awk new file mode 100644 index 00000000..88a9397f --- /dev/null +++ b/pkg/tz/data.awk @@ -0,0 +1,17 @@ +BEGIN { print "return {" } + +FNR == 1 { + if (n) + print "\t}," + n = split(FILENAME, src, "/") + printf "\t%s={\n", src[n] +} + +$1 == "Link" { printf "\t\t[\"%s\"]=\"%s\",\n", $3, $2 } +$1 == "Zone" { printf "\t\t[\"%s\"]=false,\n", $2 } + +END { + if (n) + print "\t}," + print "}" +} diff --git a/pkg/tz/data.lua b/pkg/tz/data.lua new file mode 100644 index 00000000..6279e3ec --- /dev/null +++ b/pkg/tz/data.lua @@ -0,0 +1,497 @@ +-- 2,$out.tmp && mv $out.tmp $out') -build('tzdata', '$outdir/tzdata.index', { - expand{'$srcdir/', tzdata}, - '|', '$dir/tzdata.lua', 'scripts/hash.sh', - '||', '$builddir/root.stamp', -}) -table.insert(pkg.inputs.index, '$outdir/tzdata.index') + +local zones = {} +local data = load 'data.lua' +for _, src in ipairs(srcs) do + for name, target in pairs(data[src]) do + if target then + target = name:gsub('[^/]+', '..'):sub(1, -3)..target + sym('share/zoneinfo/'..name, target) + else + file('share/zoneinfo/'..name, '644', '$outdir/zoneinfo/'..name) + table.insert(zones, name) + end + end +end + +rule('zic', 'zic -d $outdir/zoneinfo $in') +build('zic', expand{'$outdir/zoneinfo/', zones}, expand{'$srcdir/', srcs}) fetch 'git' diff --git a/pkg/tz/tzdata.lua b/pkg/tz/tzdata.lua deleted file mode 100644 index 903af2cf..00000000 --- a/pkg/tz/tzdata.lua +++ /dev/null @@ -1,24 +0,0 @@ -local function execute(cmd) - if not os.execute(cmd) then - error('command failed: '..cmd) - end -end - -local hash = 'sh ./scripts/hash.sh %s %s share/zoneinfo/%s %s' -local repo = arg[1] -local outdir = arg[2] -for i = 3, #arg do - execute(string.format('zic -d %s %s', outdir, arg[i])) - 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 - execute(hash:format(repo, 120000, name, target)) - else - name = line:match('^Zone%s+(%g+)') - if name then - execute(hash:format(repo, 100644, name, outdir..'/'..name)) - end - end - end -end -- cgit v1.2.3