From 0c1433e007207c5e5b32de724e403847cde2ce61 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 6 Apr 2016 00:33:39 +0200 Subject: [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. --- scripts/mkimport | 52 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 20 deletions(-) (limited to 'scripts/mkimport') 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) -- cgit v1.2.3 From 1b031eb27c3b5e2e45ed97e5be8c8d951f283462 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 7 Apr 2016 22:45:08 +0200 Subject: [import] adapt to grand upstream restructuring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two not quite unrelated changes have to be accounted for: * Finally, the source for Context MkII and MkIV are being kept in separate trees, at least as far as the format is concerned. All out scripts that pull code from upstream had to be adapted. * New fontloader. This has been cooking for half a year maybe: Some of our troubles with 2.6 were caused by separating out the revised but highly experimental code from the self-contained fontloader, despite Hans’ great efforts to make it seamless. Now that the new fontloader is deemed mature enough, we have to accomodate the switchover. The fallout exceeds the bounds of Luaotfload proper: The Lualibs package had to be extended as well, adding a rather tiny library from the ``util-*`` namespace. With the latest setup, a fontloader can indeed be assembled automatically again. No testing has taken place yet, so it might not even run. --- scripts/mkimport | 138 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 89 insertions(+), 49 deletions(-) (limited to 'scripts/mkimport') diff --git a/scripts/mkimport b/scripts/mkimport index 4b628ae..dfc7a5d 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/mkiv", + context = { "tex/context/base/mkiv", "tex/context/base", }, fontloader = "tex/generic/context/luatex", } @@ -201,18 +201,13 @@ local imports = { { name = "basics-gen" , ours = nil , kind = kind_essential }, { name = "basics-nod" , ours = nil , kind = kind_merged }, { name = "basics" , ours = nil , kind = kind_tex }, - { name = "fonts-cbk" , ours = nil , kind = kind_merged }, - { name = "fonts-def" , ours = nil , kind = kind_merged }, { name = "fonts-demo-vf-1" , ours = nil , kind = kind_ignored }, { name = "fonts-enc" , ours = nil , kind = kind_merged }, { name = "fonts-ext" , ours = nil , kind = kind_merged }, - { name = "fonts-lua" , ours = nil , kind = kind_merged }, { name = "fonts-merged" , ours = "reference" , kind = kind_essential }, - { name = "fonts-ota" , ours = nil , kind = kind_merged }, { name = "fonts" , ours = nil , kind = kind_merged }, { name = "fonts" , ours = nil , kind = kind_tex }, { name = "fonts-syn" , ours = nil , kind = kind_ignored }, - { name = "fonts-tfm" , ours = nil , kind = kind_merged }, { name = "languages" , ours = nil , kind = kind_ignored }, { name = "languages" , ours = nil , kind = kind_tex }, { name = "math" , ours = nil , kind = kind_ignored }, @@ -234,18 +229,31 @@ local imports = { { name = "data-con" , ours = "data-con" , kind = kind_merged }, { name = "font-afk" , ours = "font-afk" , kind = kind_merged }, { name = "font-afm" , ours = "font-afm" , kind = kind_merged }, + { name = "font-cff" , ours = "font-cff" , kind = kind_merged }, { name = "font-cid" , ours = "font-cid" , kind = kind_merged }, { name = "font-con" , ours = "font-con" , kind = kind_merged }, { name = "font-def" , ours = "font-def" , kind = kind_merged }, + { name = "font-dsp" , ours = "font-dsp" , kind = kind_merged }, + { name = "font-gbn" , ours = "font-gbn" , kind = kind_merged }, { name = "font-ini" , ours = "font-ini" , kind = kind_merged }, { name = "font-inj" , ours = "font-inj" , kind = kind_merged }, + { name = "font-lua" , ours = "font-lua" , kind = kind_merged }, { name = "font-map" , ours = "font-map" , kind = kind_merged }, + { name = "font-osd" , ours = "font-osd" , kind = kind_merged }, + { name = "font-ota" , ours = "font-ota" , kind = kind_merged }, { name = "font-otb" , ours = "font-otb" , kind = kind_merged }, + { name = "font-otd" , ours = "font-otd" , kind = kind_merged }, { name = "font-otf" , ours = "font-otf" , kind = kind_merged }, { name = "font-oti" , ours = "font-oti" , kind = kind_merged }, - { name = "font-otn" , ours = "font-otn" , kind = kind_merged }, - { name = "font-otp" , ours = "font-otp" , kind = kind_merged }, + { name = "font-otj" , ours = "font-otj" , kind = kind_merged }, + { name = "font-otl" , ours = "font-otl" , kind = kind_merged }, + { name = "font-oto" , ours = "font-oto" , kind = kind_merged }, + { name = "font-otr" , ours = "font-otr" , kind = kind_merged }, + { name = "font-ots" , ours = "font-ots" , kind = kind_merged }, + { name = "font-oup" , ours = "font-oup" , kind = kind_merged }, { name = "font-tfm" , ours = "font-tfm" , kind = kind_merged }, + { name = "font-ttf" , ours = "font-ttf" , kind = kind_merged }, + { name = "l-boolean" , ours = "l-boolean" , kind = kind_lualibs }, { name = "l-file" , ours = "l-file" , kind = kind_lualibs }, { name = "l-function" , ours = "l-function" , kind = kind_lualibs }, @@ -256,6 +264,7 @@ local imports = { { name = "l-string" , ours = "l-string" , kind = kind_lualibs }, { name = "l-table" , ours = "l-table" , kind = kind_lualibs }, { name = "util-str" , ours = "util-str" , kind = kind_lualibs }, + { name = "util-fil" , ours = "util-fil" , kind = kind_lualibs }, }, --[[ [context] ]] } --[[ [imports] ]] @@ -276,33 +285,39 @@ local package = { --- [08] l-boolean.lua --- [09] l-math.lua --- [10] util-str.lua ---- [11] luatex-basics-gen.lua ---- [12] data-con.lua ---- [13] luatex-basics-nod.lua ---- [14] font-ini.lua ---- [15] font-con.lua ---- [16] luatex-fonts-enc.lua ---- [17] font-cid.lua ---- [18] font-map.lua ---- [19] luatex-fonts-syn.lua ---- [20] font-tfm.lua ---- [21] font-afm.lua ---- [22] font-afk.lua ---- [23] luatex-fonts-tfm.lua ---- [24] font-oti.lua ---- [25] font-otf.lua ---- [26] font-otb.lua ---- [27] font-inj.lua ---- [28] luatex-fonts-ota.lua ---- [30] font-otn.lua ---- [30] font-otp.lua ---- [31] luatex-fonts-lua.lua ---- [32] font-def.lua ---- [33] luatex-fonts-def.lua ---- [34] luatex-fonts-ext.lua ---- [35] luatex-fonts-cbk.lua +--- [11] util-fil.lua +--- [12] luatex-basics-gen.lua +--- [13] data-con.lua +--- [14] luatex-basics-nod.lua +--- [15] luatex-basics-chr.lua +--- [16] font-ini.lua +--- [17] font-con.lua +--- [18] luatex-fonts-enc.lua +--- [19] font-cid.lua +--- [20] font-map.lua +--- [21] luatex-fonts-syn.lua +--- [22] font-tfm.lua +--- [23] font-afm.lua +--- [24] font-afk.lua +--- [25] font-oti.lua +--- [26] font-otr.lua +--- [27] font-cff.lua +--- [28] font-ttf.lua +--- [29] font-dsp.lua +--- [30] font-oup.lua +--- [31] font-otl.lua +--- [32] font-oto.lua +--- [33] font-otj.lua +--- [34] font-ota.lua +--- [35] font-ots.lua +--- [36] font-osd.lua +--- [37] font-lua.lua +--- [38] font-def.lua +--- [39] font-xtx.lua +--- [40] luatex-fonts-ext.lua +--- [41] font-gbn.lua --- ---- Of these, nos. 01--10 are provided by the Lualibs. Keeping them +--- Of these, nos. 01--11 are provided by the Lualibs. Keeping them --- around in the Luaotfload fontloader is therefore unnecessary. --- Packaging needs to account for this difference. @@ -316,12 +331,18 @@ local package = { "l-boolean", "l-math", "util-str", + "util-fil", --- Another file containing auxiliary definitions must be present --- prior to initialization of the configuration. "luatex-basics-gen", +--- We have a custom script for autogenerating data so we don’t use the +--- definitions from upstream. + + "basics-chr", + }, --[[ [package.optional] ]] --- The files below constitute the “fontloader proper”. Some of the @@ -342,19 +363,23 @@ local package = { "font-tfm", "font-afm", "font-afk", - "fonts-tfm", + "font-tfm", "font-oti", - "font-otf", - "font-otb", - "font-inj", - "fonts-ota", - "font-otn", - "font-otp", - "fonts-lua", + "font-otr", + "font-cff", + "font-ttf", + "font-dsp", + "font-oup", + "font-otl", + "font-oto", + "font-otj", + "font-ota", + "font-ots", + "font-osd", + "font-lua", "font-def", - "fonts-def", "fonts-ext", - "fonts-cbk", + "font-gbn", }, --[[ [package.required] ]] @@ -372,12 +397,27 @@ local hash_file = function (fname) return md5sumhexa (raw) end +local first_existing_subpath = function (pfx, subs) + if not subs then return nil end + local t_subs = type (subs) + if t_subs == "table" then + for i = 1, #subs do + local sub = subs[i] + local pth = file.join (pfx, sub) + if lfsisdir (pth) then return pth end + end + elseif t_subs == "string" then + local pth = file.join (pfx, subs) + if lfsisdir (pth) then return pth end + end + return nil +end + local derive_category_path = function (cat) - local subpath = origin_paths[cat] or die ("category " .. cat .. " unknown") - local location = file.join (parms.context_root, subpath) - if not lfsisdir (location) then - die ("invalid base path defined for category " - .. cat .. " at " .. location) + local location = first_existing_subpath (parms.context_root, + origin_paths[cat]) + if not location then + die ("invalid base path defined for category " .. cat) end return location end -- cgit v1.2.3 From 185effb3e8241ea1737f0768a69c56430e0291c7 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 7 Apr 2016 23:27:33 +0200 Subject: [import] addremove oversights --- scripts/mkimport | 3 --- 1 file changed, 3 deletions(-) (limited to 'scripts/mkimport') diff --git a/scripts/mkimport b/scripts/mkimport index dfc7a5d..be7ec18 100755 --- a/scripts/mkimport +++ b/scripts/mkimport @@ -236,14 +236,11 @@ local imports = { { name = "font-dsp" , ours = "font-dsp" , kind = kind_merged }, { name = "font-gbn" , ours = "font-gbn" , kind = kind_merged }, { name = "font-ini" , ours = "font-ini" , kind = kind_merged }, - { name = "font-inj" , ours = "font-inj" , kind = kind_merged }, { name = "font-lua" , ours = "font-lua" , kind = kind_merged }, { name = "font-map" , ours = "font-map" , kind = kind_merged }, { name = "font-osd" , ours = "font-osd" , kind = kind_merged }, { name = "font-ota" , ours = "font-ota" , kind = kind_merged }, - { name = "font-otb" , ours = "font-otb" , kind = kind_merged }, { name = "font-otd" , ours = "font-otd" , kind = kind_merged }, - { name = "font-otf" , ours = "font-otf" , kind = kind_merged }, { name = "font-oti" , ours = "font-oti" , kind = kind_merged }, { name = "font-otj" , ours = "font-otj" , kind = kind_merged }, { name = "font-otl" , ours = "font-otl" , kind = kind_merged }, -- cgit v1.2.3 From 8c18221431598bf3c7c9c0cb22dd80dd6638a213 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 8 Apr 2016 00:01:19 +0200 Subject: [import] fix dupe --- scripts/mkimport | 1 - 1 file changed, 1 deletion(-) (limited to 'scripts/mkimport') diff --git a/scripts/mkimport b/scripts/mkimport index be7ec18..25d7560 100755 --- a/scripts/mkimport +++ b/scripts/mkimport @@ -360,7 +360,6 @@ local package = { "font-tfm", "font-afm", "font-afk", - "font-tfm", "font-oti", "font-otr", "font-cff", -- cgit v1.2.3