From f09597aaf6cb7b70eacc2b7399ee743736c0893a Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 5 Jul 2013 23:34:13 +0200 Subject: fix duplication in log output --- luaotfload-override.lua | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/luaotfload-override.lua b/luaotfload-override.lua index 39cc172..adc0426 100644 --- a/luaotfload-override.lua +++ b/luaotfload-override.lua @@ -32,6 +32,12 @@ local texio_write = texio.write local texiowrite = texio.write local type = type +local texjob = false +if tex and (tex.jobname or tex.formatname) then + --- TeX + texjob = true +end + --[[doc-- We recreate the verbosity levels previously implemented in font-nms: @@ -136,10 +142,9 @@ end logs.set_logout = set_logout local log = function (category, fmt, ...) - local res = { module_name, " |" } - if category then res[#res+1] = " " .. category end - if fmt then res[#res+1] = ": " .. stringformat(fmt, ...) end - texiowrite_nl(logout, tableconcat(res)) + local res = { module_name, "|", category, ":" } + if fmt then res[#res+1] = stringformat(fmt, ...) end + texiowrite_nl(logout, tableconcat(res, " ")) end --- with faux db update with maximum verbosity: @@ -156,11 +161,11 @@ end io.stdout:setvbuf "no" io.stderr:setvbuf "no" -if tex and (tex.jobname or tex.formatname) then - --- TeX - writeln = texiowrite_nl +if texjob == true then + writeln = function (str) + texiowrite_nl ("term", str) + end else - --- Lua interpreter writeln = function (str) iowrite(str) iowrite "\n" @@ -171,7 +176,8 @@ stdout = function (category, ...) local res = { module_name, "|", category, ":" } local nargs = select("#", ...) if nargs == 0 then - writeln (tableconcat ({...})) + --writeln tableconcat(res, " ") + --return elseif nargs == 1 then res[#res+1] = select(1, ...) -- around 30% faster than unpack() else -- cgit v1.2.3 From 63dff173d9a4d201890b0afa9f3168b45cc5f681 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 5 Jul 2013 23:56:29 +0200 Subject: prefer getwritablepath() to manual path building --- luaotfload-database.lua | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index c0aadaf..30ebb47 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -54,6 +54,7 @@ local utf8gsub = unicode.utf8.gsub local utf8lower = unicode.utf8.lower --- these come from Lualibs/Context +local getwritablepath = caches.getwritablepath local filebasename = file.basename local filecollapsepath = file.collapsepath or file.collapse_path local filedirname = file.dirname @@ -99,9 +100,9 @@ names.path = { dir = "", --- db and cache directory basename = config.luaotfload.names_file or "luaotfload-names.lua", - path = "", --- full path to db file + index = "", --- full path to db file lookup_basename = "luaotfload-lookup-cache.lua", --- cache file name - lookup_path = "", --- cache full path + lookups = "", --- cache full path } -- We use the cache.* of ConTeXt (see luat-basics-gen), we can @@ -109,13 +110,15 @@ names.path = { -- uses TEXMFCACHE or TEXMFVAR as starting points. local writable_path if caches then - writable_path = caches.getwritablepath "names" + writable_path = getwritablepath ("names", "") if not writable_path then - luaotfload.error("Impossible to find a suitable writeable cache...") + luaotfload.error + ("Impossible to find a suitable writeable cache...") end - names.path.dir = writable_path - names.path.path = filejoin(writable_path, names.path.basename) - names.path.lookup_path = filejoin(writable_path, names.path.lookup_basename) + names.path.dir = writable_path + names.path.index = getwritablepath ("names", names.path.basename) + names.path.lookups = getwritablepath ("names", + names.path.lookup_basename) else --- running as script, inject some dummies caches = { } logs = { report = function () end } @@ -330,7 +333,7 @@ local fuzzy_limit = 1 --- display closest only --- bool? -> dbobj load_names = function (dry_run) local starttime = os.gettimeofday() - local foundname, data = load_lua_file(names.path.path) + local foundname, data = load_lua_file(names.path.index) if data then report("both", 2, "db", @@ -352,7 +355,7 @@ load_names = function (dry_run) report("both", 0, "db", [[Font names database not found, generating new one.]]) report("both", 0, "db", - [[This can take several minutes; please be patient.]]) + [[This can take several minutes; please be patient.]]) data = update_names(fontnames_init(false), nil, dry_run) local success = save_names(data) if not success then @@ -365,7 +368,7 @@ end --- unit -> dbobj load_lookups = function ( ) - local foundname, data = load_lua_file(names.path.lookup_path) + local foundname, data = load_lua_file(names.path.lookups) if data then report("both", 3, "cache", "Lookup cache loaded (%s)", foundname) @@ -1930,12 +1933,12 @@ save_lookups = function ( ) local lookups = names.lookups local path = ensure_names_path() if fileiswritable(path) then - local luaname, lucname = make_savenames(names.path.lookup_path) + local luaname, lucname = make_savenames(names.path.lookups) if luaname then tabletofile(luaname, lookups, true) if lucname and type(caches.compile) == "function" then os.remove(lucname) - caches.compile(lookups, luaname, lucname) + print("\ncompile>", caches.compile(lookups, luaname, lucname)) report("both", 3, "cache", "Lookup cache saved") return true end @@ -1950,8 +1953,8 @@ end save_names = function (fontnames) if not fontnames then fontnames = names.data end local path = ensure_names_path() - if fileiswritable(path) then - local luaname, lucname = make_savenames(names.path.path) + if fileiswritable (path) then + local luaname, lucname = make_savenames(names.path.index) if luaname then --tabletofile(luaname, fontnames, true, { reduce=true }) tabletofile(luaname, fontnames, true) @@ -1964,6 +1967,8 @@ save_names = function (fontnames) return true end end + --else + --report("both", 0, "db", "Failed to save names database") end report("both", 0, "db", "Failed to save names database") return false @@ -2048,8 +2053,7 @@ end local getwritablecachepath = function ( ) --- fonts.handlers.otf doesn’t exist outside a Luatex run, --- so we have to improvise - local writable = caches.getwritablepath - (config.luaotfload.cache_dir) + local writable = getwritablepath (config.luaotfload.cache_dir) if writable then return writable end -- cgit v1.2.3 From c917abdd4c6032b1e715555bc626a987b014e4ab Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 6 Jul 2013 01:37:49 +0200 Subject: systemize path handling ; improve cache write errors --- luaotfload-database.lua | 161 +++++++++++++++++++++++++++--------------------- luaotfload-tool.lua | 10 ++- luaotfload.dtx | 4 +- 3 files changed, 96 insertions(+), 79 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 30ebb47..f09c348 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -27,6 +27,7 @@ local require = require local tonumber = tonumber local unpack = table.unpack + local fontloaderinfo = fontloader.info local fontloaderopen = fontloader.open local iolines = io.lines @@ -40,6 +41,7 @@ local lfsattributes = lfs.attributes local lfsdir = lfs.dir local mathabs = math.abs local mathmin = math.min +local osremove = os.remove local stringfind = string.find local stringformat = string.format local stringgmatch = string.gmatch @@ -52,7 +54,6 @@ local tablesort = table.sort local texiowrite_nl = texio.write_nl local utf8gsub = unicode.utf8.gsub local utf8lower = unicode.utf8.lower - --- these come from Lualibs/Context local getwritablepath = caches.getwritablepath local filebasename = file.basename @@ -96,29 +97,57 @@ end names.version = 2.207 names.data = nil --- contains the loaded database names.lookups = nil --- contains the lookup cache -names.path = { - dir = "", --- db and cache directory - basename = config.luaotfload.names_file + +names.path = { index = { }, lookups = { } } +names.path.globals = { + prefix = "", --- writable_path/names_dir + names_dir = config.luaotfload.names_dir or "names", + index_file = config.luaotfload.index_file or "luaotfload-names.lua", - index = "", --- full path to db file - lookup_basename = "luaotfload-lookup-cache.lua", --- cache file name - lookups = "", --- cache full path + lookups_file = "luaotfload-lookup-cache.lua", } --- We use the cache.* of ConTeXt (see luat-basics-gen), we can --- use it safely (all checks and directory creations are already done). It --- uses TEXMFCACHE or TEXMFVAR as starting points. -local writable_path +--- string -> (string * string) +local make_luanames = function (path) + return filereplacesuffix(path, "lua"), + filereplacesuffix(path, "luc") +end + +local report = logs.names_report + +--[[doc-- + We use the functions in the cache.* namespace that come with the + fontloader (see luat-basics-gen). it’s safe to use for the most part + since most checks and directory creations are already done. It + uses TEXMFCACHE or TEXMFVAR as starting points. + + There is one quirk, though: ``getwritablepath()`` will always + assume that files in subdirectories of the cache tree are writable. + It gives no feedback at all if it fails to open a file in write + mode. This may cause trouble when the index or lookup cache were + created by different user. +--doc]]-- + if caches then - writable_path = getwritablepath ("names", "") - if not writable_path then + local globals = names.path.globals + local names_dir = globals.names_dir + + prefix = getwritablepath (names_dir, "") + if not prefix then luaotfload.error ("Impossible to find a suitable writeable cache...") + else + report ("log", 0, "db", + "root cache directory is " .. prefix) end - names.path.dir = writable_path - names.path.index = getwritablepath ("names", names.path.basename) - names.path.lookups = getwritablepath ("names", - names.path.lookup_basename) + + globals.prefix = prefix + local lookups = names.path.lookups + local index = names.path.index + local lookups_file = filejoin (prefix, globals.lookups_file) + local index_file = filejoin (prefix, globals.index_file) + lookups.lua, lookups.luc = make_luanames (lookups_file) + index.lua, index.luc = make_luanames (index_file) else --- running as script, inject some dummies caches = { } logs = { report = function () end } @@ -129,9 +158,6 @@ end Auxiliary functions --doc]]-- - -local report = logs.names_report - --- string -> string local sanitize_string = function (str) if str ~= nil then @@ -270,12 +296,6 @@ local fontnames_init = function (keep_cache) --- returns dbobj } end ---- string -> (string * string) -local make_savenames = function (path) - return filereplacesuffix(path, "lua"), - filereplacesuffix(path, "luc") -end - --- When loading a lua file we try its binary complement first, which --- is assumed to be located at an identical path, carrying the suffix --- .luc. @@ -333,7 +353,7 @@ local fuzzy_limit = 1 --- display closest only --- bool? -> dbobj load_names = function (dry_run) local starttime = os.gettimeofday() - local foundname, data = load_lua_file(names.path.index) + local foundname, data = load_lua_file(names.path.index.lua) if data then report("both", 2, "db", @@ -368,7 +388,7 @@ end --- unit -> dbobj load_lookups = function ( ) - local foundname, data = load_lua_file(names.path.lookups) + local foundname, data = load_lua_file(names.path.lookups.lua) if data then report("both", 3, "cache", "Lookup cache loaded (%s)", foundname) @@ -1912,15 +1932,6 @@ update_names = function (fontnames, force, dry_run) return newfontnames end ---- unit -> string -local ensure_names_path = function ( ) - local path = names.path.dir - if not lfsisdir(path) then - lfsmkdirs(path) - end - return path -end - --- The lookup cache is an experimental feature of version 2.2; --- instead of incorporating it into the database it gets its own --- file. As we update it after every single addition this saves us @@ -1928,23 +1939,28 @@ end --- unit -> bool save_lookups = function ( ) - ---- this is boilerplate and should be refactored into something - ---- usable by both the db and the cache writers - local lookups = names.lookups - local path = ensure_names_path() - if fileiswritable(path) then - local luaname, lucname = make_savenames(names.path.lookups) - if luaname then - tabletofile(luaname, lookups, true) - if lucname and type(caches.compile) == "function" then - os.remove(lucname) - print("\ncompile>", caches.compile(lookups, luaname, lucname)) - report("both", 3, "cache", "Lookup cache saved") - return true - end + local lookups = names.lookups + local path = names.path.lookups + local luaname, lucname = path.lua, path.luc + if fileiswritable (luaname) and fileiswritable (lucname) then + tabletofile (luaname, lookups, true) + osremove (lucname) + caches.compile (lookups, luaname, lucname) + --- double check ... + if lfsisfile (luaname) and lfsisfile (luaname) then + report ("both", 3, "cache", "Lookup cache saved") + return true end + report ("info", 0, "cache", "Could not compile lookup cache") + return false + end + report ("info", 0, "cache", "Lookup cache file not writable") + if not fileiswritable (luaname) then + report ("info", 0, "cache", "failed to write %s", luaname) + end + if not fileiswritable (lucname) then + report ("info", 0, "cache", "failed to write %s", lucname) end - report("info", 0, "cache", "Could not write lookup cache") return false end @@ -1952,25 +1968,28 @@ end --- dbobj? -> bool save_names = function (fontnames) if not fontnames then fontnames = names.data end - local path = ensure_names_path() - if fileiswritable (path) then - local luaname, lucname = make_savenames(names.path.index) - if luaname then - --tabletofile(luaname, fontnames, true, { reduce=true }) - tabletofile(luaname, fontnames, true) - if lucname and type(caches.compile) == "function" then - os.remove(lucname) - caches.compile(fontnames, luaname, lucname) - report("info", 1, "db", "Font names database saved") - report("info", 3, "db", "Text: " .. luaname) - report("info", 3, "db", "Byte: " .. lucname) - return true - end + local path = names.path.index + local luaname, lucname = path.lua, path.luc + if fileiswritable (luaname) and fileiswritable (lucname) then + tabletofile (luaname, fontnames, true) + osremove (lucname) + caches.compile (fontnames, luaname, lucname) + if lfsisfile (luaname) and lfsisfile (luaname) then + report ("info", 1, "db", "Font index saved") + report ("info", 3, "db", "Text: " .. luaname) + report ("info", 3, "db", "Byte: " .. lucname) + return true end - --else - --report("both", 0, "db", "Failed to save names database") + report ("info", 0, "db", "Could not compile font index") + return false + end + report ("info", 0, "db", "Index file not writable") + if not fileiswritable (luaname) then + report ("info", 0, "db", "failed to write %s", luaname) + end + if not fileiswritable (lucname) then + report ("info", 0, "db", "failed to write %s", lucname) end - report("both", 0, "db", "Failed to save names database") return false end @@ -2004,7 +2023,7 @@ local purge_from_cache = function (category, path, list, all) if string.find(filename,"luatex%-cache") then -- safeguard if all then report("info", 5, "cache", "removing %s", filename) - os.remove(filename) + osremove(filename) n = n + 1 else local suffix = file.suffix(filename) @@ -2013,7 +2032,7 @@ local purge_from_cache = function (category, path, list, all) filename, "lua", "luc") if lfs.isfile(checkname) then report("info", 5, "cache", "Removing %s", filename) - os.remove(filename) + osremove(filename) n = n + 1 end end diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 4d25d53..d618992 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -93,7 +93,7 @@ local config = config config.luaotfload = config.luaotfload or { } config.luaotfload.names_dir = config.luaotfload.names_dir or "names" config.luaotfload.cache_dir = config.luaotfload.cache_dir or "fonts" -config.luaotfload.names_file = config.luaotfload.names_file +config.luaotfload.index_file = config.luaotfload.index_file or "luaotfload-names.lua" do -- we don’t have file.basename and the likes yet, so inline parser ftw @@ -143,11 +143,9 @@ local names = fonts.names local sanitize_string = names.sanitize_string ---local db_src_out = names.path.dir.."/"..names.path.basename -local names_plain = file.join ( - caches.getwritablepath (config.luaotfload.names_dir), - config.luaotfload.names_file) -local names_bin = file.replacesuffix (names_plain, "luc") +local pathdata = names.path +local names_plain = pathdata.lookups.lua +local names_bin = pathdata.lookups.luc local help_messages = { ["luaotfload-tool"] = [[ diff --git a/luaotfload.dtx b/luaotfload.dtx index b8bee75..5133c1d 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -1474,12 +1474,12 @@ config.luaotfload.color_callback = config.luaotfload.color_callback or "pre_l config.luaotfload.prioritize = config.luaotfload.prioritize or "sys" config.luaotfload.names_dir = config.luaotfload.names_dir or "names" config.luaotfload.cache_dir = config.luaotfload.cache_dir or "fonts" -config.luaotfload.names_file = config.luaotfload.names_file or "luaotfload-names.lua" +config.luaotfload.index_file = config.luaotfload.index_file or "luaotfload-names.lua" luaotfload.module = { name = "luaotfload", version = 2.3, - date = "2013/06/02", + date = "2013/07/06", description = "OpenType layout system.", author = "Elie Roux & Hans Hagen", copyright = "Elie Roux", -- cgit v1.2.3 From 0df29d1d2f8c6c3a9e11959207912197a43d456f Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 6 Jul 2013 02:18:35 +0200 Subject: fix names of bytecode compiled files --- luaotfload-database.lua | 12 ++++++------ luaotfload-tool.lua | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index f09c348..f939e83 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -1947,7 +1947,7 @@ save_lookups = function ( ) osremove (lucname) caches.compile (lookups, luaname, lucname) --- double check ... - if lfsisfile (luaname) and lfsisfile (luaname) then + if lfsisfile (luaname) and lfsisfile (lucname) then report ("both", 3, "cache", "Lookup cache saved") return true end @@ -1956,10 +1956,10 @@ save_lookups = function ( ) end report ("info", 0, "cache", "Lookup cache file not writable") if not fileiswritable (luaname) then - report ("info", 0, "cache", "failed to write %s", luaname) + report ("info", 0, "cache", "Failed to write %s", luaname) end if not fileiswritable (lucname) then - report ("info", 0, "cache", "failed to write %s", lucname) + report ("info", 0, "cache", "Failed to write %s", lucname) end return false end @@ -1974,7 +1974,7 @@ save_names = function (fontnames) tabletofile (luaname, fontnames, true) osremove (lucname) caches.compile (fontnames, luaname, lucname) - if lfsisfile (luaname) and lfsisfile (luaname) then + if lfsisfile (luaname) and lfsisfile (lucname) then report ("info", 1, "db", "Font index saved") report ("info", 3, "db", "Text: " .. luaname) report ("info", 3, "db", "Byte: " .. lucname) @@ -1985,10 +1985,10 @@ save_names = function (fontnames) end report ("info", 0, "db", "Index file not writable") if not fileiswritable (luaname) then - report ("info", 0, "db", "failed to write %s", luaname) + report ("info", 0, "db", "Failed to write %s", luaname) end if not fileiswritable (lucname) then - report ("info", 0, "db", "failed to write %s", lucname) + report ("info", 0, "db", "Failed to write %s", lucname) end return false end diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index d618992..0752cca 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -143,9 +143,9 @@ local names = fonts.names local sanitize_string = names.sanitize_string -local pathdata = names.path -local names_plain = pathdata.lookups.lua -local names_bin = pathdata.lookups.luc +local pathdata = names.path +local names_plain = pathdata.index.lua +local names_bin = pathdata.index.luc local help_messages = { ["luaotfload-tool"] = [[ -- cgit v1.2.3 From 0ab9e98a0255b6cc3f70205644c506b4a7a5a627 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 7 Jul 2013 11:48:27 +0200 Subject: update NEWS --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 8615d90..d4170a7 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,9 @@ Change History -------------- +2013/??/??, git tip + * Detect LuaJIT interpreter (LuaJITTeX) + 2013/07/03, luaotfload v2.3: * New experimental lookups: ``kpse`` (kpathsea), ``my`` (callback) * Precedence of texmf over system fonts can be requested -- cgit v1.2.3 From 06fbc4ffd0432f9f44bd4d8aa50b92f02917fcba Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 7 Jul 2013 14:37:13 +0200 Subject: add mkfilelist (batch file hashing) --- mkfilelist | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 mkfilelist diff --git a/mkfilelist b/mkfilelist new file mode 100644 index 0000000..756bfe0 --- /dev/null +++ b/mkfilelist @@ -0,0 +1,115 @@ +#!/usr/bin/env texlua +----------------------------------------------------------------------- +-- FILE: mkfilelist.lua +-- USAGE: ./mkfilelist.lua +-- DESCRIPTION: part of the luaotfload package +-- REQUIREMENTS: luatex, the lualibs package +-- AUTHOR: Philipp Gesang (Phg), +-- VERSION: 1.0 +-- CREATED: 2013-07-07 14:01:12+0200 +----------------------------------------------------------------------- +-- +-- This script generates a list of hashes that serves as the input +-- for the file integrity check (option --diagnose). md5 is all we can +-- assume in Luatex, so it’s really only a superficial test. + +kpse.set_program_name "luatex" + +local md5 = require "md5" + +require "lualibs" + +local stringformat = string.format +local md5sumhexa = md5.sumhexa +local ioloaddata = io.loaddata +local iosavedata = io.savedata + +----------------------------------------------------------------------- +-- settings +----------------------------------------------------------------------- + +local filelist = "luaotfload-files.lua" --- result + +local names = { + --- only the runtime files and scripts + "luaotfload-auxiliary.lua", + "luaotfload-basics-gen.lua", + "luaotfload-basics-nod.lua", + "luaotfload-characters.lua", + "luaotfload-colors.lua", + "luaotfload-database.lua", + "luaotfload-extralibs.lua", + "luaotfload-features.lua", + "luaotfload-fonts-cbk.lua", + "luaotfload-fonts-def.lua", + "luaotfload-fonts-enc.lua", + "luaotfload-fonts-ext.lua", + "luaotfload-fonts-lua.lua", + "luaotfload-fonts-tfm.lua", + "luaotfload-glyphlist.lua", + "luaotfload-letterspace.lua", + "luaotfload-loaders.lua", + "luaotfload.lua", + "luaotfload-merged.lua", + "luaotfload-override.lua", + "luaotfload-tool.lua", + "luaotfload-typo-krn.lua", + "mkcharacters", + "mkfilelist", + "mkglyphlist", +} + +----------------------------------------------------------------------- +-- helpers +----------------------------------------------------------------------- + +local die = function (...) + io.stderr:write "[fatal error]: " + io.stderr:write (stringformat (...)) + io.stderr:write "\naborting.\n" + os.exit (1) +end + +----------------------------------------------------------------------- +-- functionality +----------------------------------------------------------------------- + +local hash_file = function (fname) + if not lfs.isfile (fname) then + die ("cannot find %s.", fname) + end + local raw = ioloaddata (fname) + if not raw then + die ("cannot read from %s.", fname) + end + return md5sumhexa (raw) +end + +local hash_all +hash_all = function (list, acc) + if list == nil then + return hash_all (table.fastcopy (names), { }) + end + + local fname = list[#list] + list[#list] = nil + if fname then + local sum = hash_file (fname) + acc[#acc+1] = { fname, sum } + return hash_all (list, acc) + end + return acc +end + +local main = function () + local hashes = hash_all () + local serialized = table.serialize (hashes, true) + local success = io.savedata (filelist, serialized) + if success == false then + die ("could not write to %s.", filelist) + end + return 0 +end + +return main () + -- cgit v1.2.3 From c98639119e56fe562edcabc493225a50af331737 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 7 Jul 2013 14:40:58 +0200 Subject: add filelist to makefile --- Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3807ec5..351d51f 100644 --- a/Makefile +++ b/Makefile @@ -8,8 +8,9 @@ OTFL = $(wildcard luaotfload-*.lua) luaotfload-blacklist.cnf GLYPHSCRIPT = mkglyphlist GLYPHSOURCE = glyphlist.txt CHARSCRIPT = mkcharacters +FILESCRIPT = mkfilelist -RESOURCESCRIPTS = $(GLYPHSCRIPT) $(CHARSCRIPT) +RESOURCESCRIPTS = $(GLYPHSCRIPT) $(CHARSCRIPT) $(FILESCRIPT) SCRIPTNAME = luaotfload-tool SCRIPT = $(SCRIPTNAME).lua @@ -24,7 +25,8 @@ DOT = $(GRAPH).dot # Files grouped by generation mode GLYPHS = luaotfload-glyphlist.lua CHARS = luaotfload-characters.lua -RESOURCES = $(GLYPHS) $(CHARS) +FILES = luaotfload-files.lua +RESOURCES = $(GLYPHS) $(CHARS) $(FILES) GRAPHED = $(DOTPDF) MAN = $(MANPAGE) COMPILED = $(DOC) @@ -70,6 +72,7 @@ DO_LATEX = latexmk -pdf -e '$$pdflatex = q(lualatex %O %S)' -silent $< >/dev DO_GRAPHVIZ = dot -Tpdf -o $@ $< > /dev/null DO_GLYPHS = $(LUA) $(GLYPHSCRIPT) > /dev/null DO_CHARS = $(LUA) $(CHARSCRIPT) > /dev/null +DO_FILES = $(LUA) $(FILESCRIPT) > /dev/null DO_DOCUTILS = rst2man $< >$@ 2>/dev/null all: $(GENERATED) @@ -79,6 +82,7 @@ manual: $(MAN) unpack: $(UNPACKED) resources: $(RESOURCES) chars: $(CHARS) +filelist: $(FILES) ctan: $(CTAN_ZIP) tds: $(TDS_ZIP) world: all ctan @@ -89,6 +93,9 @@ $(GLYPHS): /dev/null $(CHARS): /dev/null $(DO_CHARS) +$(FILES): /dev/null + $(DO_FILES) + $(GRAPHED): $(DOT) $(DO_GRAPHVIZ) -- cgit v1.2.3 From 9504cd2bf2c83d1c8b2326967836ad2c9f03178c Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 7 Jul 2013 15:46:56 +0200 Subject: add self test (--diagnose) to luaotfload-tool.lua --- luaotfload-tool.lua | 116 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 103 insertions(+), 13 deletions(-) diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 0752cca..5a9e08d 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -26,6 +26,8 @@ see the luaotfload documentation for more info. Report bugs to --doc]]-- +kpse.set_program_name "luatex" + --[[doc-- We test for Lua 5.1 by means of capability detection to see if @@ -36,7 +38,15 @@ see the luaotfload documentation for more info. Report bugs to --doc]]-- -kpse.set_program_name "luatex" +local md5sumhexa = md5.sumhexa +local stringexplode = string.explode +local stringformat = string.format +local stringlower = string.lower +local stringrep = string.rep +local tableconcat = table.concat +local texiowrite_nl = texio.write_nl +local texiowrite = texio.write +local kpsefind_file = kpse.find_file local runtime if _G.getfenv ~= nil then -- 5.1 or LJ @@ -44,26 +54,19 @@ if _G.getfenv ~= nil then -- 5.1 or LJ runtime = { "jit", jit.version } else runtime = { "stock", _VERSION } - local oldscript = kpse.find_file "luaotfload-legacy-tool.lua" + local oldscript = kpsefind_file "luaotfload-legacy-tool.lua" return require (oldscript) end else -- 5.2 runtime = { "stock", _VERSION } end -local stringexplode = string.explode -local stringformat = string.format -local stringlower = string.lower -local stringrep = string.rep -local tableconcat = table.concat -local texiowrite_nl = texio.write_nl -local texiowrite = texio.write local C, Ct, P, S = lpeg.C, lpeg.Ct, lpeg.P, lpeg.S local lpegmatch = lpeg.match local loader_file = "luatexbase.loader.lua" -local loader_path = assert(kpse.find_file(loader_file, "lua"), +local loader_path = assert(kpsefind_file(loader_file, "lua"), "File '"..loader_file.."' not found") @@ -121,6 +124,8 @@ config.lualibs.load_extended = false require "lualibs" +local ioloaddata = io.loaddata + --[[doc-- \fileent{luatex-basics-gen.lua} calls functions from the \luafunction{texio.*} library; too much for our taste. @@ -646,8 +651,9 @@ set. --]]-- local action_sequence = { - "loglevel", "help", "version", "blacklist", "cache", - "flush", "generate", "list", "query", + "loglevel", "help", "version", "diagnose", + "blacklist", "cache", "flush", "generate", + "list", "query", } local action_pending = table.tohash(action_sequence, false) @@ -913,6 +919,87 @@ actions.list = function (job) return true, true end +do + local hash_list = "luaotfload-files" + + local out = function (...) + logs.names_report (false, 0, "diagnose", ...) + end + + local verify_files = function (errcnt) + out ("Loading file hashes.") + local hashes = require (hash_list) + if not hashes then + out ("Testing %d files for integrity.", nhashes) + return 1/0 + end + local nhashes = #hashes + out ("Testing %d files for integrity.", nhashes) + for i = 1, nhashes do + local fname, canonicalsum = unpack (hashes[i]) + local location = kpsefind_file (fname) + if not location then + errcnt = errcnt + 1 + out ("FAILED: file %d missing.", fname) + else + out ("File: %s.", location) + local raw = ioloaddata (location) + if not raw then + errcnt = errcnt + 1 + out ("FAILED: file %d not readable.", fname) + else + local sum = md5sumhexa (raw) + if sum ~= canonicalsum then + errcnt = errcnt + 1 + out ("FAILED: checksum mismatch for file %s.", + fname) + out ("Expected %s, got %s.", canonicalsum, sum) + else + out ("Ok, %s passed.", fname) + end + end + end + end + return errcnt + end + + actions.diagnose = function (job) + local errcnt = 0 + errcnt = verify_files (errcnt) + + if errcnt == 0 then --> success + out ("Everything appears to be in order, \z + you may sleep well.") + return true, false + else + out ( [[=============================================== + WARNING + =============================================== + + The diagnostic detected %d errors. + + This version of luaotfload may have been + tampered with. Modified versions of the + luaotfload source are unsupported. Read the log + carefully and get a clean version from CTAN or + github: + + × http://ctan.org/tex-archive/macros/luatex/generic/luaotfload + × https://github.com/lualatex/luaotfload/releases + + If you are uncertain as to how to proceed, then + ask on the lualatex mailing list: + + http://www.tug.org/mailman/listinfo/lualatex-dev + + =============================================== +]], + errcnt) + end + return false, false + end +end + --- stuff to be carried out prior to exit local finalizers = { } @@ -952,6 +1039,7 @@ local process_cmdline = function ( ) -- unit -> jobspec local long_options = { alias = 1, cache = 1, + diagnose = "d", ["dry-run"] = "D", ["flush-lookups"] = "l", fields = 1, @@ -973,7 +1061,7 @@ local process_cmdline = function ( ) -- unit -> jobspec warnings = "w", } - local short_options = "bDfFiIlpquvVhw" + local short_options = "bdDfFiIlpquvVhw" local options, _, optarg = alt_getopt.get_ordered_opts (arg, short_options, long_options) @@ -1047,6 +1135,8 @@ local process_cmdline = function ( ) -- unit -> jobspec config.luaotfload.prioritize = "texmf" elseif v == "b" then action_pending["blacklist"] = true + elseif v == "d" then + action_pending["diagnose"] = true end end -- cgit v1.2.3 From 6b3ed4455d943fca0606a5e2a18e629c6e56a111 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 7 Jul 2013 17:42:54 +0200 Subject: add git metadata to diagnostic info in luaotfload-tool.lua --- luaotfload-tool.lua | 22 +++++++++++++++++----- mkfilelist | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 5a9e08d..3010653 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -928,11 +928,22 @@ do local verify_files = function (errcnt) out ("Loading file hashes.") - local hashes = require (hash_list) - if not hashes then - out ("Testing %d files for integrity.", nhashes) + local info = require (hash_list) + local hashes = info.hashes + local notes = info.notes + if not hashes or #hashes == 0 then + out ("FAILED: cannot read checksums from %s.", hash_list) + return 1/0 + elseif not notes then + out ("FAILED: cannot read commit metadata from %s.", + hash_list) return 1/0 end + + out ("Luaotfload revision %s.", notes.revision) + out ("Committed by %s.", notes.committer) + out ("Timestamp %s.", notes.timestamp) + local nhashes = #hashes out ("Testing %d files for integrity.", nhashes) for i = 1, nhashes do @@ -953,14 +964,15 @@ do errcnt = errcnt + 1 out ("FAILED: checksum mismatch for file %s.", fname) - out ("Expected %s, got %s.", canonicalsum, sum) + out ("Expected %s.", canonicalsum) + out ("Got %s.", sum) else out ("Ok, %s passed.", fname) end end end end - return errcnt + return errcnt, notes end actions.diagnose = function (job) diff --git a/mkfilelist b/mkfilelist index 756bfe0..72dd59f 100644 --- a/mkfilelist +++ b/mkfilelist @@ -23,6 +23,7 @@ local stringformat = string.format local md5sumhexa = md5.sumhexa local ioloaddata = io.loaddata local iosavedata = io.savedata +local iopopen = io.popen ----------------------------------------------------------------------- -- settings @@ -70,6 +71,35 @@ local die = function (...) os.exit (1) end +local gitcmd = "git log -1 \z + --format=\"return {\z + %n revision = [[%H]],\z + %n timestamp = [[%cd]],\z + %n committer = [[%cn <%ce>]],\z + %n}\" \z + --date=iso" + +local git_info = function () + --io.write (gitcmd) + --io.write "\n" + local chan = iopopen (gitcmd) + if not chan then + die ("this script needs to be run inside \z + the luaotfload git repository") + end + + local data = chan:read "*all" + chan:close () + if data and type (data) == "string" and data ~= "" then + data = load (data) + if not data then + die "cannot parse git information" + end + return data () + end + die "cannot read from pipe" +end + ----------------------------------------------------------------------- -- functionality ----------------------------------------------------------------------- @@ -103,7 +133,9 @@ end local main = function () local hashes = hash_all () - local serialized = table.serialize (hashes, true) + local notes = git_info () + local serialized = table.serialize ({ notes = notes, + hashes = hashes }, true) local success = io.savedata (filelist, serialized) if success == false then die ("could not write to %s.", filelist) -- cgit v1.2.3 From 23ae4869772666fc7433ae878159277152cc3c33 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 7 Jul 2013 22:06:16 +0200 Subject: rename mkfilelist to mkstatus --- Makefile | 58 ++++++++++----------- luaotfload-tool.lua | 8 +-- mkfilelist | 147 ---------------------------------------------------- mkstatus | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 180 insertions(+), 180 deletions(-) delete mode 100644 mkfilelist create mode 100644 mkstatus diff --git a/Makefile b/Makefile index 351d51f..4768d75 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,9 @@ OTFL = $(wildcard luaotfload-*.lua) luaotfload-blacklist.cnf GLYPHSCRIPT = mkglyphlist GLYPHSOURCE = glyphlist.txt CHARSCRIPT = mkcharacters -FILESCRIPT = mkfilelist +STATUSSCRIPT = mkstatus -RESOURCESCRIPTS = $(GLYPHSCRIPT) $(CHARSCRIPT) $(FILESCRIPT) +RESOURCESCRIPTS = $(GLYPHSCRIPT) $(CHARSCRIPT) $(STATUSSCRIPT) SCRIPTNAME = luaotfload-tool SCRIPT = $(SCRIPTNAME).lua @@ -25,8 +25,8 @@ DOT = $(GRAPH).dot # Files grouped by generation mode GLYPHS = luaotfload-glyphlist.lua CHARS = luaotfload-characters.lua -FILES = luaotfload-files.lua -RESOURCES = $(GLYPHS) $(CHARS) $(FILES) +STATUS = luaotfload-status.lua +RESOURCES = $(GLYPHS) $(CHARS) $(STATUS) GRAPHED = $(DOTPDF) MAN = $(MANPAGE) COMPILED = $(DOC) @@ -36,20 +36,20 @@ SOURCE = $(DTX) $(MANSOURCE) $(OTFL) README Makefile NEWS $(RESOURCESCRIPTS) # test files TESTDIR = tests -TESTFILES = $(wildcard $(TESTDIR)/*.tex $(TESTDIR)/*.ltx) -TESTFILES_SYS = $(TESTDIR)/systemfonts.tex $(TESTDIR)/fontconfig_conf_reading.tex -TESTFILES_TL = $(filter-out $(TESTFILES_SYS), $(TESTFILES)) +TESTSTATUS = $(wildcard $(TESTDIR)/*.tex $(TESTDIR)/*.ltx) +TESTSTATUS_SYS = $(TESTDIR)/systemfonts.tex $(TESTDIR)/fontconfig_conf_reading.tex +TESTSTATUS_TL = $(filter-out $(TESTSTATUS_SYS), $(TESTSTATUS)) # Files grouped by installation location -SCRIPTFILES = $(SCRIPT) $(OLDSCRIPT) $(RESOURCESCRIPTS) -RUNFILES = $(UNPACKED) $(filter-out $(SCRIPTFILES),$(OTFL)) -DOCFILES = $(DOC) $(DOTPDF) README NEWS -MANFILES = $(MANPAGE) -SRCFILES = $(DTX) Makefile +SCRIPTSTATUS = $(SCRIPT) $(OLDSCRIPT) $(RESOURCESCRIPTS) +RUNSTATUS = $(UNPACKED) $(filter-out $(SCRIPTSTATUS),$(OTFL)) +DOCSTATUS = $(DOC) $(DOTPDF) README NEWS +MANSTATUS = $(MANPAGE) +SRCSTATUS = $(DTX) Makefile # The following definitions should be equivalent -# ALL_FILES = $(RUNFILES) $(DOCFILES) $(SRCFILES) -ALL_FILES = $(GENERATED) $(SOURCE) +# ALL_STATUS = $(RUNSTATUS) $(DOCSTATUS) $(SRCSTATUS) +ALL_STATUS = $(GENERATED) $(SOURCE) # Installation locations FORMAT = luatex @@ -72,7 +72,7 @@ DO_LATEX = latexmk -pdf -e '$$pdflatex = q(lualatex %O %S)' -silent $< >/dev DO_GRAPHVIZ = dot -Tpdf -o $@ $< > /dev/null DO_GLYPHS = $(LUA) $(GLYPHSCRIPT) > /dev/null DO_CHARS = $(LUA) $(CHARSCRIPT) > /dev/null -DO_FILES = $(LUA) $(FILESCRIPT) > /dev/null +DO_STATUS = $(LUA) $(STATUSSCRIPT) > /dev/null DO_DOCUTILS = rst2man $< >$@ 2>/dev/null all: $(GENERATED) @@ -82,7 +82,7 @@ manual: $(MAN) unpack: $(UNPACKED) resources: $(RESOURCES) chars: $(CHARS) -filelist: $(FILES) +status: $(STATUS) ctan: $(CTAN_ZIP) tds: $(TDS_ZIP) world: all ctan @@ -93,8 +93,8 @@ $(GLYPHS): /dev/null $(CHARS): /dev/null $(DO_CHARS) -$(FILES): /dev/null - $(DO_FILES) +$(STATUS): /dev/null + $(DO_STATUS) $(GRAPHED): $(DOT) $(DO_GRAPHVIZ) @@ -114,15 +114,15 @@ $(CTAN_ZIP): $(SOURCE) $(COMPILED) $(TDS_ZIP) @zip -9 $@ $^ >/dev/null define run-install -@mkdir -p $(SCRIPTDIR) && cp $(SCRIPTFILES) $(SCRIPTDIR) -@mkdir -p $(RUNDIR) && cp $(RUNFILES) $(RUNDIR) -@mkdir -p $(DOCDIR) && cp $(DOCFILES) $(DOCDIR) -@mkdir -p $(SRCDIR) && cp $(SRCFILES) $(SRCDIR) -@mkdir -p $(MANDIR) && cp $(MANFILES) $(MANDIR) +@mkdir -p $(SCRIPTDIR) && cp $(SCRIPTSTATUS) $(SCRIPTDIR) +@mkdir -p $(RUNDIR) && cp $(RUNSTATUS) $(RUNDIR) +@mkdir -p $(DOCDIR) && cp $(DOCSTATUS) $(DOCDIR) +@mkdir -p $(SRCDIR) && cp $(SRCSTATUS) $(SRCDIR) +@mkdir -p $(MANDIR) && cp $(MANSTATUS) $(MANDIR) endef $(TDS_ZIP): TEXMFROOT=./tmp-texmf -$(TDS_ZIP): $(ALL_FILES) +$(TDS_ZIP): $(ALL_STATUS) @echo "Making TDS-ready archive $@." @$(RM) -- $@ $(run-install) @@ -131,20 +131,20 @@ $(TDS_ZIP): $(ALL_FILES) .PHONY: install manifest clean mrproper -install: $(ALL_FILES) +install: $(ALL_STATUS) @echo "Installing in '$(TEXMFROOT)'." $(run-install) -check: $(RUNFILES) $(TESTFILES_TL) +check: $(RUNSTATUS) $(TESTSTATUS_TL) @rm -rf var - @for f in $(TESTFILES_TL); do \ + @for f in $(TESTSTATUS_TL); do \ echo "check: luatex $$f"; \ luatex --interaction=batchmode $$f \ > /dev/null || exit $$?; \ done -check-all: $(TESTFILES_SYS) check - @cd $(TESTDIR); for f in $(TESTFILES_SYS); do \ +check-all: $(TESTSTATUS_SYS) check + @cd $(TESTDIR); for f in $(TESTSTATUS_SYS); do \ echo "check: luatex $$f"; \ $(TESTENV) luatex --interaction=batchmode ../$$f \ > /dev/null || exit $$?; \ diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 3010653..79f1c26 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -920,7 +920,7 @@ actions.list = function (job) end do - local hash_list = "luaotfload-files" + local status_file = "luaotfload-status" local out = function (...) logs.names_report (false, 0, "diagnose", ...) @@ -928,15 +928,15 @@ do local verify_files = function (errcnt) out ("Loading file hashes.") - local info = require (hash_list) + local info = require (status_file) local hashes = info.hashes local notes = info.notes if not hashes or #hashes == 0 then - out ("FAILED: cannot read checksums from %s.", hash_list) + out ("FAILED: cannot read checksums from %s.", status_file) return 1/0 elseif not notes then out ("FAILED: cannot read commit metadata from %s.", - hash_list) + status_file) return 1/0 end diff --git a/mkfilelist b/mkfilelist deleted file mode 100644 index 72dd59f..0000000 --- a/mkfilelist +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/env texlua ------------------------------------------------------------------------ --- FILE: mkfilelist.lua --- USAGE: ./mkfilelist.lua --- DESCRIPTION: part of the luaotfload package --- REQUIREMENTS: luatex, the lualibs package --- AUTHOR: Philipp Gesang (Phg), --- VERSION: 1.0 --- CREATED: 2013-07-07 14:01:12+0200 ------------------------------------------------------------------------ --- --- This script generates a list of hashes that serves as the input --- for the file integrity check (option --diagnose). md5 is all we can --- assume in Luatex, so it’s really only a superficial test. - -kpse.set_program_name "luatex" - -local md5 = require "md5" - -require "lualibs" - -local stringformat = string.format -local md5sumhexa = md5.sumhexa -local ioloaddata = io.loaddata -local iosavedata = io.savedata -local iopopen = io.popen - ------------------------------------------------------------------------ --- settings ------------------------------------------------------------------------ - -local filelist = "luaotfload-files.lua" --- result - -local names = { - --- only the runtime files and scripts - "luaotfload-auxiliary.lua", - "luaotfload-basics-gen.lua", - "luaotfload-basics-nod.lua", - "luaotfload-characters.lua", - "luaotfload-colors.lua", - "luaotfload-database.lua", - "luaotfload-extralibs.lua", - "luaotfload-features.lua", - "luaotfload-fonts-cbk.lua", - "luaotfload-fonts-def.lua", - "luaotfload-fonts-enc.lua", - "luaotfload-fonts-ext.lua", - "luaotfload-fonts-lua.lua", - "luaotfload-fonts-tfm.lua", - "luaotfload-glyphlist.lua", - "luaotfload-letterspace.lua", - "luaotfload-loaders.lua", - "luaotfload.lua", - "luaotfload-merged.lua", - "luaotfload-override.lua", - "luaotfload-tool.lua", - "luaotfload-typo-krn.lua", - "mkcharacters", - "mkfilelist", - "mkglyphlist", -} - ------------------------------------------------------------------------ --- helpers ------------------------------------------------------------------------ - -local die = function (...) - io.stderr:write "[fatal error]: " - io.stderr:write (stringformat (...)) - io.stderr:write "\naborting.\n" - os.exit (1) -end - -local gitcmd = "git log -1 \z - --format=\"return {\z - %n revision = [[%H]],\z - %n timestamp = [[%cd]],\z - %n committer = [[%cn <%ce>]],\z - %n}\" \z - --date=iso" - -local git_info = function () - --io.write (gitcmd) - --io.write "\n" - local chan = iopopen (gitcmd) - if not chan then - die ("this script needs to be run inside \z - the luaotfload git repository") - end - - local data = chan:read "*all" - chan:close () - if data and type (data) == "string" and data ~= "" then - data = load (data) - if not data then - die "cannot parse git information" - end - return data () - end - die "cannot read from pipe" -end - ------------------------------------------------------------------------ --- functionality ------------------------------------------------------------------------ - -local hash_file = function (fname) - if not lfs.isfile (fname) then - die ("cannot find %s.", fname) - end - local raw = ioloaddata (fname) - if not raw then - die ("cannot read from %s.", fname) - end - return md5sumhexa (raw) -end - -local hash_all -hash_all = function (list, acc) - if list == nil then - return hash_all (table.fastcopy (names), { }) - end - - local fname = list[#list] - list[#list] = nil - if fname then - local sum = hash_file (fname) - acc[#acc+1] = { fname, sum } - return hash_all (list, acc) - end - return acc -end - -local main = function () - local hashes = hash_all () - local notes = git_info () - local serialized = table.serialize ({ notes = notes, - hashes = hashes }, true) - local success = io.savedata (filelist, serialized) - if success == false then - die ("could not write to %s.", filelist) - end - return 0 -end - -return main () - diff --git a/mkstatus b/mkstatus new file mode 100644 index 0000000..97d9f04 --- /dev/null +++ b/mkstatus @@ -0,0 +1,147 @@ +#!/usr/bin/env texlua +----------------------------------------------------------------------- +-- FILE: mkstatus.lua +-- USAGE: ./mkstatus.lua +-- DESCRIPTION: writes the repository state +-- REQUIREMENTS: luatex, the lualibs package +-- AUTHOR: Philipp Gesang (Phg), +-- VERSION: 1.0 +-- CREATED: 2013-07-07 14:01:12+0200 +----------------------------------------------------------------------- +-- +-- This script generates a list of hashes that serves as the input +-- for the file integrity check (option --diagnose). md5 is all we can +-- assume in Luatex, so it’s really only a superficial test. + +kpse.set_program_name "luatex" + +local md5 = require "md5" + +require "lualibs" + +local stringformat = string.format +local md5sumhexa = md5.sumhexa +local ioloaddata = io.loaddata +local iosavedata = io.savedata +local iopopen = io.popen + +----------------------------------------------------------------------- +-- settings +----------------------------------------------------------------------- + +local filelist = "luaotfload-status.lua" --- result + +local names = { + --- only the runtime files and scripts + "luaotfload-auxiliary.lua", + "luaotfload-basics-gen.lua", + "luaotfload-basics-nod.lua", + "luaotfload-characters.lua", + "luaotfload-colors.lua", + "luaotfload-database.lua", + "luaotfload-extralibs.lua", + "luaotfload-features.lua", + "luaotfload-fonts-cbk.lua", + "luaotfload-fonts-def.lua", + "luaotfload-fonts-enc.lua", + "luaotfload-fonts-ext.lua", + "luaotfload-fonts-lua.lua", + "luaotfload-fonts-tfm.lua", + "luaotfload-glyphlist.lua", + "luaotfload-letterspace.lua", + "luaotfload-loaders.lua", + "luaotfload.lua", + "luaotfload-merged.lua", + "luaotfload-override.lua", + "luaotfload-tool.lua", + "luaotfload-typo-krn.lua", + "mkcharacters", + "mkglyphlist", + "mkstatus", +} + +----------------------------------------------------------------------- +-- helpers +----------------------------------------------------------------------- + +local die = function (...) + io.stderr:write "[fatal error]: " + io.stderr:write (stringformat (...)) + io.stderr:write "\naborting.\n" + os.exit (1) +end + +local gitcmd = "git log -1 \z + --format=\"return {\z + %n revision = [[%H]],\z + %n timestamp = [[%cd]],\z + %n committer = [[%cn <%ce>]],\z + %n}\" \z + --date=iso" + +local git_info = function () + --io.write (gitcmd) + --io.write "\n" + local chan = iopopen (gitcmd) + if not chan then + die ("this script needs to be run inside \z + the luaotfload git repository") + end + + local data = chan:read "*all" + chan:close () + if data and type (data) == "string" and data ~= "" then + data = load (data) + if not data then + die "cannot parse git information" + end + return data () + end + die "cannot read from pipe" +end + +----------------------------------------------------------------------- +-- functionality +----------------------------------------------------------------------- + +local hash_file = function (fname) + if not lfs.isfile (fname) then + die ("cannot find %s.", fname) + end + local raw = ioloaddata (fname) + if not raw then + die ("cannot read from %s.", fname) + end + return md5sumhexa (raw) +end + +local hash_all +hash_all = function (list, acc) + if list == nil then + return hash_all (table.fastcopy (names), { }) + end + + local fname = list[#list] + list[#list] = nil + if fname then + local sum = hash_file (fname) + acc[#acc+1] = { fname, sum } + return hash_all (list, acc) + end + return acc +end + +local main = function () + local hashes = hash_all () + local notes = git_info () + local serialized = table.serialize ({ notes = notes, + hashes = hashes }, true) + local success = io.savedata (filelist, serialized) + if success == false then + die ("could not write to %s.", filelist) + end + return 0 +end + +return main () + -- cgit v1.2.3 From 5aed3af2d85eb52557d41619e39b4389932beda5 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 8 Jul 2013 01:17:16 +0200 Subject: add github repo info to diagnostics in ``luaotfload-tool.lua`` this is still **experimental**. what to expect: * the JSON parser in ``util-jsn`` needs fixing. currently it will fail if an API response contains escaped double quotes. see: ; * requires the ``luasec`` module for https requests; * may break in unexpected ways with connectivity problems, e.g. timeouts; * errors not (yet) cumulative with the other diagnostics; * not yet skippable with ``--diagnose``; * for the time being API requests are unauthorized. acquiring a security token is a TODO. --- luaotfload-tool.lua | 232 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 217 insertions(+), 15 deletions(-) diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 79f1c26..825f888 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -38,16 +38,21 @@ kpse.set_program_name "luatex" --doc]]-- + +local kpsefind_file = kpse.find_file local md5sumhexa = md5.sumhexa +local next = next +local osdate = os.date local stringexplode = string.explode local stringformat = string.format local stringlower = string.lower local stringrep = string.rep +local stringsub = string.sub local tableconcat = table.concat local texiowrite_nl = texio.write_nl local texiowrite = texio.write -local kpsefind_file = kpse.find_file - +local tonumber = tonumber +local type = type local runtime if _G.getfenv ~= nil then -- 5.1 or LJ if _G.jit ~= nil then @@ -120,11 +125,13 @@ end config.lualibs = config.lualibs or { } config.lualibs.verbose = false config.lualibs.prefer_merged = true -config.lualibs.load_extended = false +config.lualibs.load_extended = true require "lualibs" +--- dofile "util-jsn.lua" --- awaiting fix -local ioloaddata = io.loaddata +local lua_of_json = utilities.json.tolua +local ioloaddata = io.loaddata --[[doc-- \fileent{luatex-basics-gen.lua} calls functions from the @@ -156,7 +163,7 @@ local help_messages = { ["luaotfload-tool"] = [[ Usage: %s [OPTION]... - + Operations on the LuaTeX font database. This tool is part of the luaotfload package. Valid options are: @@ -217,7 +224,7 @@ The font cache will be written to mkluatexfontdb = [[ Usage: %s [OPTION]... - + Rebuild or update the LuaTeX font database. Valid options: @@ -470,7 +477,7 @@ local display_general = function (fullinfo) val = #fullinfo[key] end elseif mode == "d" then - val = os.date("%F %T", fullinfo[key]) + val = osdate("%F %T", fullinfo[key]) end if not val then val = "" @@ -927,7 +934,7 @@ do end local verify_files = function (errcnt) - out ("Loading file hashes.") + out "Loading file hashes." local info = require (status_file) local hashes = info.hashes local notes = info.notes @@ -975,16 +982,213 @@ do return errcnt, notes end + local check_upstream + + if kpsefind_file ("https.lua", "lua") == nil then + check_upstream = function () + out [[Github API access requires the luasec library. + WARNING: Cannot retrieve repository data. + Grab it from + and retry.]] + end + else + --- github api stuff begin + local https = require "ssl.https" + + local gh_api_root = [[https://api.github.com]] + local release_url = [[https://github.com/lualatex/luaotfload/releases]] + local luaotfload_repo = [[lualatex/luaotfload]] + local user_agent = [[lualatex/luaotfload integrity check]] + local shortbytes = 8 + + local gh_shortrevision = function (rev) + return stringsub (rev, 1, shortbytes) + end + + local gh_encode_parameters = function (parameters) + local acc = {} + for field, value in next, parameters do + --- unsafe, non-urlencoded coz it’s all ascii chars + acc[#acc+1] = field .. "=" .. value + end + return "?" .. tableconcat (acc, "&") + end + + local gh_make_url = function (components, parameters) + local url = tableconcat ({ gh_api_root, + unpack (components) }, + "/") + if parameters then + url = url .. gh_encode_parameters (parameters) + end + return url + end + + local alright = [[HTTP/1.1 200 OK]] + + local gh_api_request = function (...) + local args = {...} + local nargs = #args + local final = args[nargs] + local request = { + url = "", + headers = { ["user-agent"] = user_agent }, + } + if type (final) == "table" then + args[nargs] = nil + request = gh_make_url (args, final) + else + request = gh_make_url (args) + end + + out ("Requesting <%s>.", request) + local response, code, headers, status + = https.request (request) + if status ~= alright then + out "Request failed!" + return false + end + return response + end + + local gh_api_checklimit = function (headers) + local rawlimit = gh_api_request "rate_limit" + local limitdata = lua_of_json (rawlimit) + if not limitdata and limitdata.rate then + out "Cannot parse API rate limit." + return false + end + limitdata = limitdata.rate + + local limit = tonumber (limitdata.limit) + local left = tonumber (limitdata.remaining) + local reset = tonumber (limitdata.reset) + + out ("%d of %d Github API requests left.", left, limit) + if left == 0 then + out ("Cannot make any more API requests.") + out ("Try again later at %s.", osdate ("%F %T", reset)) + end + return true + end + + local gh_tags = function () + out "Fetching tags from repository, please stand by." + local rawtags = gh_api_request ("repos", + luaotfload_repo, + "tags") + local taglist = lua_of_json (rawtags) + if not taglist or #taglist == 0 then + out "Cannot parse response." + return false + end + + local ntags = #taglist + out ("Repository contains %d tags.", ntags) + local _idx, latest = next (taglist) + out ("The most recent release is %s (revision %s).", + latest.name, + gh_shortrevision (latest.commit.sha)) + return latest + end + + local gh_compare = function (head, base) + if base == nil then + base = "HEAD" + end + out ("Fetching comparison between %s and %s, \z + please stand by.", + gh_shortrevision (head), + gh_shortrevision (base)) + local comparison = base .. "..." .. head + local rawstatus = gh_api_request ("repos", + luaotfload_repo, + "compare", + comparison) + local status = lua_of_json (rawstatus) + if not status then + out "Cannot parse response for status request." + return false + end + return status + end + + local gh_news = function (since) + local compared = gh_compare (since) + if not compared then + return false + end + local behind_by = compared.behind_by + local ahead_by = compared.ahead_by + local status = compared.status + out ("Comparison state: %s.", status) + if behind_by > 0 then + out ("Your Luaotfload is %d \z + revisions behind upstream.", + behind_by) + return behind_by + elseif status == "ahead" then + out "Since you are obviously from the future \z + I assume you already know the repository state." + else + out "Everything up to date. \z + Luaotfload is in sync with upstream." + end + return false + end + + local gh_catchup = function (current, latest) + local compared = gh_compare (latest, current) + local ahead_by = tonumber (compared.ahead_by) + if ahead_by > 0 then + local permalink_url = compared.permalink_url + out ("Your Luaotfload is %d revisions \z + behind the most recent release.", + ahead_by) + out ("To view the commit log, visit <%s>.", + permalink_url) + out ("You can grab an up to date tarball at <%s>.", + release_url) + return true + else + out "There weren’t any new releases in the meantime." + out "Luaotfload is up to date." + end + return false + end + + check_upstream = function (current) + local _succ = gh_api_checklimit () + local behind = gh_news (current) + if behind then + local latest = gh_tags () + local _behind = gh_catchup (current, + latest.commit.sha, + latest.name) + end + end + + --- trivium: diff since the first revision as pushed by Élie + --- in 2009 + --- local firstrevision = "c3ccb3ee07e0a67171c24960966ae974e0dd8e98" + --- check_upstream (firstrevision) + end + --- github api stuff end + + actions.diagnose = function (job) local errcnt = 0 - errcnt = verify_files (errcnt) + errcnt, notes = verify_files (errcnt) + --errcnt = check_upstream (notes.revision) + + check_upstream (notes.revision) if errcnt == 0 then --> success out ("Everything appears to be in order, \z you may sleep well.") return true, false - else - out ( [[=============================================== + end + out ( [[=============================================== WARNING =============================================== @@ -1005,10 +1209,8 @@ do http://www.tug.org/mailman/listinfo/lualatex-dev =============================================== -]], - errcnt) - end - return false, false +]], errcnt) + return true, false end end -- cgit v1.2.3 From cfcc97762b232c9cbdb569aa8b3c5c2d82179e2f Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 8 Jul 2013 10:49:09 +0200 Subject: make individual diagnostics selectable in luaotfload-tool.lua --- luaotfload-tool.lua | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 825f888..add8c16 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -132,6 +132,7 @@ require "lualibs" local lua_of_json = utilities.json.tolua local ioloaddata = io.loaddata +local tabletohash = table.tohash --[[doc-- \fileent{luatex-basics-gen.lua} calls functions from the @@ -662,7 +663,7 @@ local action_sequence = { "blacklist", "cache", "flush", "generate", "list", "query", } -local action_pending = table.tohash(action_sequence, false) +local action_pending = tabletohash(action_sequence, false) action_pending.loglevel = true --- always set the loglevel action_pending.generate = false --- this is the default action @@ -927,15 +928,11 @@ actions.list = function (job) end do - local status_file = "luaotfload-status" - local out = function (...) logs.names_report (false, 0, "diagnose", ...) end - local verify_files = function (errcnt) - out "Loading file hashes." - local info = require (status_file) + local verify_files = function (errcnt, info) local hashes = info.hashes local notes = info.notes if not hashes or #hashes == 0 then @@ -979,7 +976,7 @@ do end end end - return errcnt, notes + return errcnt end local check_upstream @@ -1175,13 +1172,33 @@ do end --- github api stuff end + local anamneses = { "verify", "repository", } + local status_file = "luaotfload-status" actions.diagnose = function (job) local errcnt = 0 - errcnt, notes = verify_files (errcnt) - --errcnt = check_upstream (notes.revision) + local asked = job.asked_diagnostics + if asked == "all" or asked == "thorough" then + asked = tabletohash (anamneses, true) + else + asked = lpegmatch(split_comma, asked) + asked = tabletohash (asked, true) + end + + out "Loading file hashes." + local info = require (status_file) + + if asked.verify == true then + errcnt = verify_files (errcnt, info) + end +-- if asked.xxx == true then +-- errcnt = xxx (errcnt) +-- end + if asked.repository == true then + --errcnt = check_upstream (info.notes.revision) + check_upstream (info.notes.revision) + end - check_upstream (notes.revision) if errcnt == 0 then --> success out ("Everything appears to be in order, \z @@ -1253,7 +1270,7 @@ local process_cmdline = function ( ) -- unit -> jobspec local long_options = { alias = 1, cache = 1, - diagnose = "d", + diagnose = 1, ["dry-run"] = "D", ["flush-lookups"] = "l", fields = 1, @@ -1275,7 +1292,7 @@ local process_cmdline = function ( ) -- unit -> jobspec warnings = "w", } - local short_options = "bdDfFiIlpquvVhw" + local short_options = "bDfFiIlpquvVhw" local options, _, optarg = alt_getopt.get_ordered_opts (arg, short_options, long_options) @@ -1349,8 +1366,9 @@ local process_cmdline = function ( ) -- unit -> jobspec config.luaotfload.prioritize = "texmf" elseif v == "b" then action_pending["blacklist"] = true - elseif v == "d" then + elseif v == "diagnose" then action_pending["diagnose"] = true + result.asked_diagnostics = optarg[n] end end -- cgit v1.2.3 From 981c1d5781048d292e222b5a2e934a67218dbb9c Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 8 Jul 2013 14:32:46 +0200 Subject: add file permissions check to --diagnose option in luaotfload-tool.lua --- luaotfload-tool.lua | 151 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 143 insertions(+), 8 deletions(-) diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index add8c16..e1905f3 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -39,10 +39,16 @@ kpse.set_program_name "luatex" --doc]]-- +local ioopen = io.open local kpsefind_file = kpse.find_file +local lfsattributes = lfs.attributes +local lfsisfile = lfs.isfile +local lfsreadlink = lfs.readlink local md5sumhexa = md5.sumhexa local next = next local osdate = os.date +local osremove = os.remove +local ostype = os.type local stringexplode = string.explode local stringformat = string.format local stringlower = string.lower @@ -53,6 +59,7 @@ local texiowrite_nl = texio.write_nl local texiowrite = texio.write local tonumber = tonumber local type = type + local runtime if _G.getfenv ~= nil then -- 5.1 or LJ if _G.jit ~= nil then @@ -67,7 +74,7 @@ else -- 5.2 end -local C, Ct, P, S = lpeg.C, lpeg.Ct, lpeg.P, lpeg.S +local C, Cg, Ct, P, S = lpeg.C, lpeg.Cg, lpeg.Ct, lpeg.P, lpeg.S local lpegmatch = lpeg.match local loader_file = "luatexbase.loader.lua" @@ -133,6 +140,8 @@ require "lualibs" local lua_of_json = utilities.json.tolua local ioloaddata = io.loaddata local tabletohash = table.tohash +local fileiswritable = file.iswritable +local fileisreadable = file.isreadable --[[doc-- \fileent{luatex-basics-gen.lua} calls functions from the @@ -933,6 +942,7 @@ do end local verify_files = function (errcnt, info) + out "================ verify files =================" local hashes = info.hashes local notes = info.notes if not hashes or #hashes == 0 then @@ -979,14 +989,138 @@ do return errcnt end + local get_tentative_attributes = function (file) + if not lfsisfile (file) then + local chan = ioopen (file, "w") + if chan then + chan:close () + local attributes = lfsattributes (file) + os.remove (file) + return attributes + end + end + end + + local p_permissions = Ct(Cg(Ct(C(1) * C(1) * C(1)), "u") + * Cg(Ct(C(1) * C(1) * C(1)), "g") + * Cg(Ct(C(1) * C(1) * C(1)), "o")) + + local analyze_permissions = function (raw) + return lpegmatch (p_permissions, raw) + end + + local get_permissions = function (t, location) + local attributes = lfsattributes (location) + if not attributes and t == "f" then + attributes = get_tentative_attributes (location) + if not attributes then + return false + end + end + + local permissions + + if fileisreadable (location) then + --- link handling appears to be unnecessary because + --- lfs.attributes() will return the information on + --- the link target. + if mode == "link" then --follow and repeat + location = lfsreadlink (location) + attributes = lfsattributes (location) + end + end + + permissions = analyze_permissions (attributes.permissions) + + return { + location = location, + mode = attributes.mode, + owner = attributes.uid, --- useless on windows + permissions = permissions, + attributes = attributes, + } + end + + local check_conformance = function (spec, permissions, errcnt) + local uid = permissions.attributes.uid + local gid = permissions.attributes.gid + local raw = permissions.attributes.permissions + + out ("Owner: %d, group %d, permissions %s.", uid, gid, raw) + if ostype == "unix" then + if uid == 0 or gid == 0 then + out "Owned by the superuser, permission conflict likely." + errcnt = errcnt + 1 + end + end + + local user = permissions.permissions.u + if spec.r == true then + if user[1] == "r" then + out "Readable: ok." + else + out "Not readable: permissions need fixing." + errcnt = errcnt + 1 + end + end + + if spec.w == true then + if user[2] == "w" + or fileiswritable (permissions.location) then + out "Writable: ok." + else + out "Not writable: permissions need fixing." + errcnt = errcnt + 1 + end + end + + return errcnt + end + + local path = names.path + + local desired_permissions = { + { "d", {"r","w"}, function () return caches.getwritablepath () end }, + { "d", {"r","w"}, path.globals.prefix }, + { "f", {"r","w"}, path.index.lua }, + { "f", {"r","w"}, path.index.luc }, + { "f", {"r","w"}, path.lookups.lua }, + { "f", {"r","w"}, path.lookups.luc }, + } + + local check_permissions = function (errcnt) + out [[=============== file permissions ==============]] + for i = 1, #desired_permissions do + local t, spec, path = unpack (desired_permissions[i]) + if type (path) == "function" then + path = path () + end + + spec = tabletohash (spec) + + out ("Checking permissions of %s.", path) + + local permissions = get_permissions (t, path) + if permissions then + --inspect (permissions) + errcnt = check_conformance (spec, permissions, errcnt) + else + errcnt = errcnt + 1 + end + end + return errcnt + end + local check_upstream if kpsefind_file ("https.lua", "lua") == nil then - check_upstream = function () - out [[Github API access requires the luasec library. + check_upstream = function (errcnt) + out [[============= upstream repository ============= + Github API access requires the luasec library. WARNING: Cannot retrieve repository data. Grab it from and retry.]] + return errcnt end else --- github api stuff begin @@ -1155,6 +1289,7 @@ do end check_upstream = function (current) + out "============= upstream repository =============" local _succ = gh_api_checklimit () local behind = gh_news (current) if behind then @@ -1172,7 +1307,7 @@ do end --- github api stuff end - local anamneses = { "verify", "repository", } + local anamneses = { "files", "repository", "permissions" } local status_file = "luaotfload-status" actions.diagnose = function (job) @@ -1188,12 +1323,12 @@ do out "Loading file hashes." local info = require (status_file) - if asked.verify == true then + if asked.files == true then errcnt = verify_files (errcnt, info) end --- if asked.xxx == true then --- errcnt = xxx (errcnt) --- end + if asked.permissions == true then + errcnt = check_permissions (errcnt) + end if asked.repository == true then --errcnt = check_upstream (info.notes.revision) check_upstream (info.notes.revision) -- cgit v1.2.3 From d27de7dd32590f32cc5f746c0e9f5bb22fa50c9e Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 8 Jul 2013 14:45:36 +0200 Subject: [doc] describe --diagnose in manpage --- luaotfload-tool.rst | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/luaotfload-tool.rst b/luaotfload-tool.rst index 31a1010..05daa6a 100644 --- a/luaotfload-tool.rst +++ b/luaotfload-tool.rst @@ -33,6 +33,8 @@ SYNOPSIS **luaotfload** --show-blacklist +**luaotfload** --diagnose=CHECK + DESCRIPTION ======================================================================= @@ -43,8 +45,6 @@ the *Luaotfload* package. There are two general modes: **update** and + **update**: update the database or rebuild it entirely; + **query**: resolve a font name or display close matches. -A third mode for clearing the lookup cache is currently experimental. - Note that if the script is named ``mkluatexfontdb`` it will behave like earlier versions (<=1.3) and always update the database first. Also, the verbosity level will be set to 2. @@ -128,6 +128,17 @@ miscellaneous --version, -V Show version number and exit. --help, -h Show help message and exit. +--diagnose=CHECK Run the diagnostic procedure *CHECK*. Available + procedures are: + + 1) ``files`` -> check *Luaotfload* files for + modifications; + 2) ``permissions`` -> check permissions of + cache directories and files; + 3) ``repository`` -> check the git repository + for new releases. + + Specify ``thorough`` to run all checks. FILES ======================================================================= -- cgit v1.2.3 From 3e35c3298e7b712c81704df74145754baf1a32df Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 8 Jul 2013 14:49:42 +0200 Subject: add --diagnose to usage info of luaotfload-tool.lua --- luaotfload-tool.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index e1905f3..a5ed717 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -189,6 +189,8 @@ This tool is part of the luaotfload package. Valid options are: -V --version print version and exit -h --help print this message + --diagnose=CHECK run a self test procedure; one of “files”, + “permissions”, or “repository” --alias= force behavior of “luaotfload-tool” or legacy “mkluatexfontdb” -- cgit v1.2.3 From d1b62959c82872f3570f2335628a71363fd1e337 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 9 Jul 2013 22:16:50 +0200 Subject: fix script name in manpage --- luaotfload-tool.rst | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/luaotfload-tool.rst b/luaotfload-tool.rst index 05daa6a..27e0069 100644 --- a/luaotfload-tool.rst +++ b/luaotfload-tool.rst @@ -15,25 +15,25 @@ SYNOPSIS ======================================================================= -**luaotfload** [ -bDcfFiIpquvVwh ] +**luaotfload-tool** [ -bDcfFiIpquvVwh ] -**luaotfload** --update [ --force ] [ --quiet ] [ --verbose ] [ --prefer-texmf ] [ --dry-run ] +**luaotfload-tool** --update [ --force ] [ --quiet ] [ --verbose ] [ --prefer-texmf ] [ --dry-run ] -**luaotfload** --find=FONTNAME [ --fuzzy ] [ --info ] [ --inspect ] +**luaotfload-tool** --find=FONTNAME [ --fuzzy ] [ --info ] [ --inspect ] -**luaotfload** --flush-lookups +**luaotfload-tool** --flush-lookups -**luaotfload** --cache=DIRECTIVE +**luaotfload-tool** --cache=DIRECTIVE -**luaotfload** --list=CRITERION[:VALUE] [ --fields=F1,F2,...,Fn ] +**luaotfload-tool** --list=CRITERION[:VALUE] [ --fields=F1,F2,...,Fn ] -**luaotfload** --help +**luaotfload-tool** --help -**luaotfload** --version +**luaotfload-tool** --version -**luaotfload** --show-blacklist +**luaotfload-tool** --show-blacklist -**luaotfload** --diagnose=CHECK +**luaotfload-tool** --diagnose=CHECK DESCRIPTION ======================================================================= -- cgit v1.2.3 From 4ae202183fb9e6cfadb81aefd6a8d26feb3de212 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 9 Jul 2013 22:36:01 +0200 Subject: add short usage message to luaotfload-tool --- luaotfload-tool.lua | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index a5ed717..c3c0f72 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -40,6 +40,7 @@ kpse.set_program_name "luatex" local ioopen = io.open +local iowrite = io.write local kpsefind_file = kpse.find_file local lfsattributes = lfs.attributes local lfsisfile = lfs.isfile @@ -172,7 +173,7 @@ local names_bin = pathdata.index.luc local help_messages = { ["luaotfload-tool"] = [[ -Usage: %s [OPTION]... +Usage: %s [OPTIONS...] Operations on the LuaTeX font database. @@ -255,17 +256,26 @@ The font database will be saved to %s ]], + short = [[ +Usage: luaotfload-tool [--help] [--version] [--verbose=] + [--update] [--force] [--prefer-texmf] + [--find=] [--fuzzy] [--info] [--inspect] + [--list=] [--fields=] + [--cache=] [--flush-lookups] + [--show-blacklist] [--diagnose=] + +Enter 'luaotfload-tool --help' for a larger list of options. +]] } -local help_msg = function ( ) - local template = help_messages[config.luaotfload.self] - or help_messages["luaotfload-tool"] - texiowrite_nl(stringformat(template, - config.luaotfload.self, - names_plain, - names_bin, - caches.getwritablepath ( - config.luaotfload.cache_dir))) +local help_msg = function (version) + local template = help_messages[version] + iowrite(stringformat(template, + config.luaotfload.self, + names_plain, + names_bin, + caches.getwritablepath ( + config.luaotfload.cache_dir))) end local version_msg = function ( ) @@ -685,7 +695,7 @@ actions.loglevel = function (job) logs.set_loglevel(job.log_level) logs.names_report("info", 3, "util", "Setting log level", "%d", job.log_level) - logs.names_report("log", 0, "util", "Lua=%s", _VERSION) + logs.names_report("log", 2, "util", "Lua=%s", _VERSION) return true, true end @@ -695,7 +705,7 @@ actions.version = function (job) end actions.help = function (job) - help_msg() + help_msg (job.help_version or "luaotfload-tool") return true, false end @@ -1510,9 +1520,13 @@ local process_cmdline = function ( ) -- unit -> jobspec end if config.luaotfload.self == "mkluatexfontdb" then + result.help_version = "mkluatexfontdb" action_pending["generate"] = true - result.log_level = math.max(2, result.log_level) + result.log_level = math.max(1, result.log_level) logs.set_logout"stdout" + elseif nopts == 0 then + action_pending["help"] = true + result.help_version = "short" end return result end -- cgit v1.2.3 From 021f0c5e4859e15dc1d24cd232a327fd69446cb1 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 10 Jul 2013 00:46:31 +0200 Subject: fix format specifier in diagnose printer --- luaotfload-tool.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index c3c0f72..060b8a0 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -977,7 +977,7 @@ do local location = kpsefind_file (fname) if not location then errcnt = errcnt + 1 - out ("FAILED: file %d missing.", fname) + out ("FAILED: file %s missing.", fname) else out ("File: %s.", location) local raw = ioloaddata (location) -- cgit v1.2.3 From 3abd68b25bf2c12371df046c0a5ff035bcd20d11 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 10 Jul 2013 14:00:32 +0200 Subject: prioritize ``prefmodifiers`` oer ``subfamily`` follow-up to these previous modifications: * https://github.com/phi-gamma/luaotfload/commit/fcdbafd0c86fdba08 * https://github.com/phi-gamma/luaotfload/commit/2938e7d63404f1d2e * https://github.com/phi-gamma/luaotfload/commit/0e51cff12b24d264b addresses https://github.com/lualatex/luaotfload/issues/108 i.e. "name:DejaVu Serif" does not resolve to the Condensed face anymore. --- luaotfload-database.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index f939e83..7215e11 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -799,7 +799,7 @@ resolve = function (_, _, specification) -- the 1st two parameters are used by C if facenames then family = facenames.family subfamily = facenames.subfamily - prefmodifiers = facenames.prefmodifiers + prefmodifiers = facenames.prefmodifiers or facenames.subfamily fullname = facenames.fullname psname = facenames.psname fontname = facenames.fontname @@ -818,16 +818,19 @@ resolve = function (_, _, specification) -- the 1st two parameters are used by C if continue == false then break end elseif style == subfamily then exact = add_to_match(exact, askedsize, face) + elseif synonym_set[style] and synonym_set[style][prefmodifiers] + or synonym_set.regular[prefmodifiers] + then + --- treat synonyms for prefmodifiers as first-class + --- (needed to prioritize DejaVu Book over Condensed) + exact = add_to_match(exact, askedsize, face) elseif name == fullname or name == pfullname or name == fontname or name == psname then - synonymous, continue = add_to_match(synonymous, askedsize, face) - elseif synonym_set[style] and - (synonym_set[style][prefmodifiers] or - synonym_set[style][subfamily]) - or synonym_set.regular[prefmodifiers] + synonymous = add_to_match(synonymous, askedsize, face) + elseif synonym_set[style] and synonym_set[style][subfamily] or synonym_set.regular[subfamily] then synonymous = add_to_match(synonymous, askedsize, face) -- cgit v1.2.3 From 133d5eb6d6e7ba35f5bc4b73151393cac1e5d092 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 10 Jul 2013 14:23:10 +0200 Subject: change mode of mkstatus to executable --- mkstatus | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 mkstatus diff --git a/mkstatus b/mkstatus old mode 100644 new mode 100755 -- cgit v1.2.3 From 12bc6faf98fa9e8fc4ecc1db2cde14ff620b0429 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 10 Jul 2013 18:01:15 +0200 Subject: bump version, update NEWS --- NEWS | 3 ++- luaotfload-auxiliary.lua | 2 +- luaotfload-colors.lua | 2 +- luaotfload-database.lua | 2 +- luaotfload-extralibs.lua | 2 +- luaotfload-features.lua | 2 +- luaotfload-letterspace.lua | 2 +- luaotfload-loaders.lua | 2 +- luaotfload-override.lua | 2 +- luaotfload-tool.lua | 2 +- luaotfload-tool.rst | 4 ++-- luaotfload.dtx | 12 ++++++------ 12 files changed, 19 insertions(+), 18 deletions(-) diff --git a/NEWS b/NEWS index d4170a7..0875cfa 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,9 @@ Change History -------------- -2013/??/??, git tip +2013/07/10, luaotfload v2.3a * Detect LuaJIT interpreter (LuaJITTeX) + * Self-test functionality for luaotfload-tool.lua (option ``--diagnose``) 2013/07/03, luaotfload v2.3: * New experimental lookups: ``kpse`` (kpathsea), ``my`` (callback) diff --git a/luaotfload-auxiliary.lua b/luaotfload-auxiliary.lua index 8fc8477..d6c8eaa 100644 --- a/luaotfload-auxiliary.lua +++ b/luaotfload-auxiliary.lua @@ -4,7 +4,7 @@ -- DESCRIPTION: part of luaotfload -- REQUIREMENTS: luaotfload 2.3 -- AUTHOR: Khaled Hosny, Élie Roux, Philipp Gesang --- VERSION: 2.3 +-- VERSION: 2.3a -- CREATED: 2013-05-01 14:40:50+0200 ----------------------------------------------------------------------- -- diff --git a/luaotfload-colors.lua b/luaotfload-colors.lua index d3e77b0..b95e836 100644 --- a/luaotfload-colors.lua +++ b/luaotfload-colors.lua @@ -1,5 +1,5 @@ if not modules then modules = { } end modules ['luaotfload-colors'] = { - version = 2.3, + version = "2.3a", comment = "companion to luaotfload.lua (font color)", author = "Khaled Hosny, Elie Roux, Philipp Gesang", copyright = "Luaotfload Development Team", diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 7215e11..e0b977b 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -1,5 +1,5 @@ if not modules then modules = { } end modules ['luaotfload-database'] = { - version = 2.3, + version = "2.3a", comment = "companion to luaotfload.lua", author = "Khaled Hosny, Elie Roux, Philipp Gesang", copyright = "Luaotfload Development Team", diff --git a/luaotfload-extralibs.lua b/luaotfload-extralibs.lua index 3204229..3769e06 100644 --- a/luaotfload-extralibs.lua +++ b/luaotfload-extralibs.lua @@ -1,5 +1,5 @@ if not modules then modules = { } end modules ["extralibs"] = { - version = 2.3, + version = "2.3a", comment = "companion to luaotfload.lua", author = "Hans Hagen, Philipp Gesang", copyright = "PRAGMA ADE / ConTeXt Development Team", diff --git a/luaotfload-features.lua b/luaotfload-features.lua index 690a33c..a07992b 100644 --- a/luaotfload-features.lua +++ b/luaotfload-features.lua @@ -1,5 +1,5 @@ if not modules then modules = { } end modules ["features"] = { - version = 2.3, + version = "2.3a", comment = "companion to luaotfload.lua", author = "Hans Hagen, Khaled Hosny, Elie Roux, Philipp Gesang", copyright = "PRAGMA ADE / ConTeXt Development Team", diff --git a/luaotfload-letterspace.lua b/luaotfload-letterspace.lua index e4ebf0b..880c7bd 100644 --- a/luaotfload-letterspace.lua +++ b/luaotfload-letterspace.lua @@ -1,5 +1,5 @@ if not modules then modules = { } end modules ['letterspace'] = { - version = 2.3, + version = "2.3a", comment = "companion to luaotfload.lua", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL; adapted by Philipp Gesang", copyright = "PRAGMA ADE / ConTeXt Development Team", diff --git a/luaotfload-loaders.lua b/luaotfload-loaders.lua index 0ab1505..63e1d08 100644 --- a/luaotfload-loaders.lua +++ b/luaotfload-loaders.lua @@ -1,5 +1,5 @@ if not modules then modules = { } end modules ["loaders"] = { - version = 2.3, + version = "2.3a", comment = "companion to luaotfload.lua", author = "Hans Hagen, Khaled Hosny, Elie Roux, Philipp Gesang", copyright = "PRAGMA ADE / ConTeXt Development Team", diff --git a/luaotfload-override.lua b/luaotfload-override.lua index adc0426..f647826 100644 --- a/luaotfload-override.lua +++ b/luaotfload-override.lua @@ -1,5 +1,5 @@ if not modules then modules = { } end modules ['luat-ovr'] = { - version = 2.3, + version = "2.3a", comment = "companion to luatex-*.tex", author = "Khaled Hosny, Elie Roux, Philipp Gesang", copyright = "Luaotfload Development Team", diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 060b8a0..96cc9aa 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -4,7 +4,7 @@ -- DESCRIPTION: database functionality -- REQUIREMENTS: luaotfload 2.2 -- AUTHOR: Khaled Hosny, Élie Roux, Philipp Gesang --- VERSION: 2.3 +-- VERSION: 2.3a -- LICENSE: GPL v2 -- MODIFIED: 2013-06-02 19:23:54+0200 ----------------------------------------------------------------------- diff --git a/luaotfload-tool.rst b/luaotfload-tool.rst index 27e0069..e81aa8d 100644 --- a/luaotfload-tool.rst +++ b/luaotfload-tool.rst @@ -6,9 +6,9 @@ generate and query the Luaotfload font names database ----------------------------------------------------------------------- -:Date: 2013-06-02 +:Date: 2013-07-10 :Copyright: GPL v2.0 -:Version: 2.3 +:Version: 2.3a :Manual section: 1 :Manual group: text processing diff --git a/luaotfload.dtx b/luaotfload.dtx index 5133c1d..c1d182b 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -40,7 +40,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: luaotfload v2.3 OpenType layout system} +\Msg{* Package: luaotfload v2.3a OpenType layout system} \Msg{************************************************************************} \keepsilent @@ -111,7 +111,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{luaotfload.drv}% - [2013/05/23 v2.3d OpenType layout system]% + [2013/07/10 v2.3a OpenType layout system]% \documentclass{ltxdoc} \usepackage{metalogo,multicol,mdwlist,fancyvrb,xspace} \usepackage[x11names]{xcolor} @@ -231,7 +231,7 @@ and the derived files % \GetFileInfo{luaotfload.drv} % % \title{The \identifier{luaotfload} package} -% \date{2013/05/23 v2.3d} +% \date{2013/07/10 v2.3a} % \author{Elie Roux · Khaled Hosny · Philipp Gesang\\ % Home: \url{https://github.com/lualatex/luaotfload}\\ % Support: \email{lualatex-dev@tug.org}} @@ -1478,8 +1478,8 @@ config.luaotfload.index_file = config.luaotfload.index_file or "luaot luaotfload.module = { name = "luaotfload", - version = 2.3, - date = "2013/07/06", + version = 2.3a, + date = "2013/07/10", description = "OpenType layout system.", author = "Elie Roux & Hans Hagen", copyright = "Elie Roux", @@ -2069,7 +2069,7 @@ loadmodule"auxiliary.lua" --- additionaly high-level functionality (new) \else \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luaotfload}% - [2013/05/23 v2.3d OpenType layout system] + [2013/07/10 v2.3a OpenType layout system] \RequirePackage{luatexbase} \fi \ifnum\luatexversion<76 -- cgit v1.2.3 From 190129ad12d2a5567c9af7932f8632da9be40d2e Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 10 Jul 2013 18:14:46 +0200 Subject: consider that scripts are in the scripts/ tree when locating files --- luaotfload-tool.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 96cc9aa..4afd9d1 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -975,6 +975,7 @@ do for i = 1, nhashes do local fname, canonicalsum = unpack (hashes[i]) local location = kpsefind_file (fname) + or kpsefind_file (fname, "texmfscripts") if not location then errcnt = errcnt + 1 out ("FAILED: file %s missing.", fname) -- cgit v1.2.3 From c005b2dc2c002b970536ae3acf9532e1f673b478 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 10 Jul 2013 18:23:21 +0200 Subject: fix version number --- luaotfload.dtx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luaotfload.dtx b/luaotfload.dtx index c1d182b..d647efb 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -1478,7 +1478,7 @@ config.luaotfload.index_file = config.luaotfload.index_file or "luaot luaotfload.module = { name = "luaotfload", - version = 2.3a, + version = 2.3001, date = "2013/07/10", description = "OpenType layout system.", author = "Elie Roux & Hans Hagen", -- cgit v1.2.3