From 75be509021abdcd01f7d5caf35d026647042322a Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Fri, 4 Jun 2021 18:35:45 +0200 Subject: 2021-06-04 17:23:00 --- scripts/context/lua/mtx-context.lua | 39 +++++++++++++++++++++++++++---------- scripts/context/lua/mtx-context.xml | 3 +++ 2 files changed, 32 insertions(+), 10 deletions(-) (limited to 'scripts') diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua index d419dd25e..f5971e15c 100644 --- a/scripts/context/lua/mtx-context.lua +++ b/scripts/context/lua/mtx-context.lua @@ -361,20 +361,29 @@ local function multipass_changed(oldhash, newhash) return false end -local f_tempfile = formatters["%s-%s-%02d.tmp"] +local f_tempfile_i = formatters["%s-%s-%02d.tmp"] +local f_tempfile_s = formatters["%s-%s-keep.%s"] local function backup(jobname,run,kind,filename) - if run == 1 then - for i=1,10 do - local tmpname = f_tempfile(jobname,kind,i) - if validfile(tmpname) then - removefile(tmpname) - report("removing %a",tmpname) + if run then + if run == 1 then + for i=1,10 do + local tmpname = f_tempfile_i(jobname,kind,i) + if validfile(tmpname) then + removefile(tmpname) + report("removing %a",tmpname) + end end end - end - if validfile(filename) then - local tmpname = f_tempfile(jobname,kind,run or 1) + if validfile(filename) then + local tmpname = f_tempfile(jobname,kind,run or 1) + report("copying %a into %a",filename,tmpname) + file.copy(filename,tmpname) + else + report("no file %a, nothing kept",filename) + end + elseif validfile(filename) then + local tmpname = f_tempfile_s(jobname,kind,kind) report("copying %a into %a",filename,tmpname) file.copy(filename,tmpname) else @@ -395,6 +404,14 @@ local function multipass_copyluafile(jobname,run) end end +local function multipass_copypdffile(jobname,run) + local pdfname = jobname..".pdf" + if validfile(pdfname) then + backup(jobname,false,"pdf",pdfname) + report() + end +end + local function multipass_copylogfile(jobname,run) local logname = jobname..".log" if validfile(logname) then @@ -673,6 +690,7 @@ function scripts.context.run(ctxdata,filename) local a_texformat = getargument("texformat") local a_keeptuc = getargument("keeptuc") local a_keeplog = getargument("keeplog") + local a_keeppdf = getargument("keeppdf") local a_export = getargument("export") local a_nodates = getargument("nodates") local a_trailerid = getargument("trailerid") @@ -890,6 +908,7 @@ function scripts.context.run(ctxdata,filename) elseif returncode == 0 then multipass_copyluafile(jobname,a_keeptuc and currentrun) multipass_copylogfile(jobname,a_keeplog and currentrun) + multipass_copypdffile(jobname,a_keeppdf and currentrun) if not multipass_forcedruns then newhash = multipass_hashfiles(jobname) if multipass_changed(oldhash,newhash) then diff --git a/scripts/context/lua/mtx-context.xml b/scripts/context/lua/mtx-context.xml index 98a75244b..d4e0d33c5 100644 --- a/scripts/context/lua/mtx-context.xml +++ b/scripts/context/lua/mtx-context.xml @@ -202,6 +202,9 @@ keep previous tuc files (jobname-tuc-[run].tmp) + + keep previous pdf files (jobname-pdf-keep.tmp) + keep previous log files (jobname-log-[run].tmp) -- cgit v1.2.3