summaryrefslogtreecommitdiff
path: root/scripts/mkimport
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2016-04-06 00:33:39 +0200
committerPhilipp Gesang <phg@phi-gamma.net>2016-04-06 00:33:44 +0200
commit0c1433e007207c5e5b32de724e403847cde2ce61 (patch)
tree94e8c823b53de810ad17c48364dd4a2c983ae1d9 /scripts/mkimport
parent15753d8bc80596a89ae0dd57e0d6132bf0731035 (diff)
downloadluaotfload-0c1433e007207c5e5b32de724e403847cde2ce61.tar.gz
[import] do not abort immediately upon encountering missing file
Larger changes by upstream are easier to comprehend if errors during import are counted instead. The script will exit non-zero regardless if such an error occurred, but otherwise attempt to import all the files.
Diffstat (limited to 'scripts/mkimport')
-rwxr-xr-xscripts/mkimport52
1 files changed, 32 insertions, 20 deletions
diff --git a/scripts/mkimport b/scripts/mkimport
index 08537d7..4b628ae 100755
--- a/scripts/mkimport
+++ b/scripts/mkimport
@@ -63,7 +63,7 @@ local luatex_fonts_prefix = "luatex"
local fontloader_subdir = "src/fontloader"
local origin_paths = {
- context = "tex/context/base",
+ context = "tex/context/base/mkiv",
fontloader = "tex/generic/context/luatex",
}
@@ -105,12 +105,22 @@ local loader_target_dir = "/build/"
-------------------------------------------------------------------------------
local die = function (...)
- io.stderr:write "[\x1b[1;30;41mfatal error\x1b[0m]: "
+ io.stderr:write "[\x1b[1;30;41mfatal error\x1b[0m] "
io.stderr:write (stringformat (...))
io.stderr:write "\naborting.\n"
os.exit (1)
end
+local uncertain = 0
+
+local hmm = function (...)
+ uncertain = uncertain + 1
+ --[[ sorta like an error but non-fatal ]]
+ io.stderr:write "[\x1b[1;31merror\x1b[0m] "
+ io.stderr:write (stringformat (...))
+ io.stderr:write "; continuing nontheless.\n"
+end
+
local emphasis = function (txt)
return stringformat("\x1b[1m%s\x1b[0m", txt)
end
@@ -352,7 +362,8 @@ local package = {
local hash_file = function (fname)
if not lfsisfile (fname) then
- die ("cannot find %s.", fname)
+ hmm ("cannot find %s", fname)
+ return nil
end
local raw = ioloaddata (fname)
if not raw then
@@ -476,20 +487,21 @@ local news = function ()
end
if is_readable (ourpath) then imported = true end
local src_hash = hash_file (fullpath)
- local dst_hash = imported and hash_file (ourpath)
- local same = src_hash == dst_hash -- same!
-
- if same then
- good ("file %s unchanged", emphasis (ourname))
- status.good[#status.good + 1] = ourname
- elseif not dst_hash then
- attention ("new file %s requires import from %s",
- emphasis (ourname),
- emphasis (fullpath))
- status.create[#status.create + 1] = ourname
- else --- src and dst exist but differ
- attention ("file %s requires import", emphasis (ourname))
- status.import[#status.import + 1] = ourname
+ if src_hash then
+ local dst_hash = imported and hash_file (ourpath)
+ local same = src_hash == dst_hash -- same!
+ if same then
+ good ("file %s unchanged", emphasis (ourname))
+ status.good[#status.good + 1] = ourname
+ elseif not dst_hash then
+ attention ("new file %s requires import from %s",
+ emphasis (ourname),
+ emphasis (fullpath))
+ status.create[#status.create + 1] = ourname
+ else --- src and dst exist but differ
+ attention ("file %s requires import", emphasis (ourname))
+ status.import[#status.import + 1] = ourname
+ end
end
end
@@ -541,7 +553,7 @@ local summarize_status = function (counters)
local sum = imported + skipped + created + failed
if sum < 1 then die ("garbage total of imported files: %s", sum) end
separator ()
- status (" RESULT: %d files processed", sum)
+ status (" RESULT: %d files processed, %d errors", sum, uncertain)
separator ()
if created > 0 then status ("created: %d (%d %%)", created , created * 100 / sum) end
if imported > 0 then status ("imported: %d (%d %%)", imported, imported * 100 / sum) end
@@ -593,7 +605,7 @@ local import = function (arg)
local def = defs[i]
local stat = import_file (def.name, def.kind, def, cat)
if stat == import_failed then
- die (stringformat ("import failed at file %d of %d (%s)",
+ hmm (stringformat ("import failed at file %d of %d (%s)",
i, ndefs, def.name))
end
statcount[stat] = statcount[stat] or 0
@@ -601,7 +613,7 @@ local import = function (arg)
end
end
summarize_status (statcount)
- return 0
+ return uncertain == 0 and 0 or -42
end --[[ [local import = function (arg)] ]]
local find_in_path = function (root, subdir, target)