summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pkg/tz/gen.lua7
-rw-r--r--pkg/tz/tzdata.awk26
-rw-r--r--pkg/tz/tzdata.lua18
3 files changed, 22 insertions, 29 deletions
diff --git a/pkg/tz/gen.lua b/pkg/tz/gen.lua
index 80c4dd5f..38a78ffb 100644
--- 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
deleted file mode 100644
index e7b48085..00000000
--- a/pkg/tz/tzdata.awk
+++ /dev/null
@@ -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
new file mode 100644
index 00000000..4de07e82
--- /dev/null
+++ 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