From d9825168b0fb7b07e315879584487f9d4d9e9494 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 11 Feb 2014 06:27:04 +0100 Subject: [*] move mkcharacters, mktests, mkglyphlist, mkstatus to separate subdirectory scripts --- scripts/mkstatus | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100755 scripts/mkstatus (limited to 'scripts/mkstatus') diff --git a/scripts/mkstatus b/scripts/mkstatus new file mode 100755 index 0000000..6e6e375 --- /dev/null +++ b/scripts/mkstatus @@ -0,0 +1,149 @@ +#!/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-diagnostics.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-log.lua", + "luaotfload-main.lua", + "luaotfload-fontloader.lua", + "luaotfload-override.lua", + "luaotfload-parsers.lua", + "luaotfload-tool.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 () + +--- vim:ft=lua:ts=2:et:sw=2 -- cgit v1.2.3 From 9e4c3a5390bd101a382ed959f81cd5bce62ed98b Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 11 Feb 2014 06:42:03 +0100 Subject: [status] adapt status script to work on subdirectories --- scripts/mkstatus | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'scripts/mkstatus') diff --git a/scripts/mkstatus b/scripts/mkstatus index 6e6e375..cc0a62c 100755 --- a/scripts/mkstatus +++ b/scripts/mkstatus @@ -24,11 +24,14 @@ local md5sumhexa = md5.sumhexa local ioloaddata = io.loaddata local iosavedata = io.savedata local iopopen = io.popen +local iowrite = io.write +local lfsisdir = lfs.isdir ----------------------------------------------------------------------- -- settings ----------------------------------------------------------------------- +local verbose = false local filelist = "luaotfload-status.lua" --- result local names = { @@ -56,9 +59,9 @@ local names = { "luaotfload-override.lua", "luaotfload-parsers.lua", "luaotfload-tool.lua", - "mkcharacters", - "mkglyphlist", - "mkstatus", + { "scripts", "mkcharacters", }, + { "scripts", "mkglyphlist", }, + { "scripts", "mkstatus", }, } ----------------------------------------------------------------------- @@ -122,17 +125,38 @@ hash_all = function (list, acc) return hash_all (table.fastcopy (names), { }) end - local fname = list[#list] + local finfo = list[#list] list[#list] = nil - if fname then - local sum = hash_file (fname) - acc[#acc+1] = { fname, sum } + if finfo then + local fpath + if type (finfo) == "table" then + local d, f = finfo [1], finfo [2] + if lfs.isdir (d) then + fpath = file.join (d, f) + else + fpath = f + end + else + fpath = finfo + end + if verbose then + iowrite "· md5(" + iowrite (fpath) + end + local sum = hash_file (fpath) + if verbose then + iowrite ") = \"" + iowrite (sum) + iowrite "\"\n" + end + acc[#acc+1] = { fpath, sum } return hash_all (list, acc) end return acc end local main = function () + if arg [1] == "-v" then verbose = true end local hashes = hash_all () local notes = git_info () local serialized = table.serialize ({ notes = notes, -- cgit v1.2.3 From 7c5b3005c07314b2ba916b1577a4825213a2a454 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 11 Feb 2014 07:05:31 +0100 Subject: [status] fix target path --- scripts/mkstatus | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/mkstatus') diff --git a/scripts/mkstatus b/scripts/mkstatus index cc0a62c..efd9874 100755 --- a/scripts/mkstatus +++ b/scripts/mkstatus @@ -32,7 +32,7 @@ local lfsisdir = lfs.isdir ----------------------------------------------------------------------- local verbose = false -local filelist = "luaotfload-status.lua" --- result +local filelist = "./build/luaotfload-status.lua" --- result local names = { --- only the runtime files and scripts -- cgit v1.2.3 From e9d34a8805f14361272864ea0470def2914315b4 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 11 Feb 2014 07:28:32 +0100 Subject: [status] adapt mkstatus to respect the ./build directory --- scripts/mkstatus | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts/mkstatus') diff --git a/scripts/mkstatus b/scripts/mkstatus index efd9874..fcf8b24 100755 --- a/scripts/mkstatus +++ b/scripts/mkstatus @@ -39,7 +39,7 @@ local names = { "luaotfload-auxiliary.lua", "luaotfload-basics-gen.lua", "luaotfload-basics-nod.lua", - "luaotfload-characters.lua", + { "build", "luaotfload-characters.lua", }, "luaotfload-colors.lua", "luaotfload-database.lua", "luaotfload-diagnostics.lua", @@ -50,7 +50,7 @@ local names = { "luaotfload-fonts-ext.lua", "luaotfload-fonts-lua.lua", "luaotfload-fonts-tfm.lua", - "luaotfload-glyphlist.lua", + { "build", "luaotfload-glyphlist.lua", }, "luaotfload-letterspace.lua", "luaotfload-loaders.lua", "luaotfload-log.lua", -- cgit v1.2.3