summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-04-06 13:21:15 +0900
committerNorbert Preining <norbert@preining.info>2023-04-07 12:52:51 +0900
commita0719a65a46db59d07274a935e6961e386240bd4 (patch)
tree44f99c17b6611a3c4c18439fb63f0873b1c79bbb
parentf306fa9f0c418b92952d1ed6fedab293e0c2bdfd (diff)
Adjust paper size configuration for ConTeXt
- ship a file texmf-dist/tex/context/texlive/cont-sys.mkxl that invalidates the cache based on changes to the ls-R files - remove mtxrun/context calls from tlmgr.pl - adjust TLPaper.pm to use context-papersize.tex Code provided by Max Chernoff
-rwxr-xr-xMaster/texmf-dist/scripts/texlive/tlmgr.pl11
-rw-r--r--Master/texmf-dist/tex/context/texlive/cont-sys.mkxl46
-rw-r--r--Master/tlpkg/TeXLive/TLPaper.pm43
3 files changed, 57 insertions, 43 deletions
diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl
index bf7f498b6da..d0d4456bce1 100755
--- a/Master/texmf-dist/scripts/texlive/tlmgr.pl
+++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl
@@ -892,17 +892,6 @@ sub handle_execute_actions {
if ($::files_changed) {
$errors += do_cmd_and_check("mktexlsr");
- # see comments in install-tl about lmtx.
- my $lmtx = "$bindir/luametatex";
- if (defined($localtlpdb->get_package('context'))
- && (-x "$lmtx" || -x "$lmtx.exe")
- && TeXLive::TLUtils::system_ok("$lmtx --version")
- ) {
- $errors += do_cmd_and_check("mtxrun --generate");
- $errors += do_cmd_and_check("context --luatex --generate");
- } else {
- debug("skipped ConTeXt cache regeneration\n");
- }
$::files_changed = 0;
}
diff --git a/Master/texmf-dist/tex/context/texlive/cont-sys.mkxl b/Master/texmf-dist/tex/context/texlive/cont-sys.mkxl
new file mode 100644
index 00000000000..73c619f41d6
--- /dev/null
+++ b/Master/texmf-dist/tex/context/texlive/cont-sys.mkxl
@@ -0,0 +1,46 @@
+% Update the ConTeXt filename cache if the system ls-R files are modified
+\startluacode
+ local addsuffix = file.addsuffix
+ local attributes = lfs.attributes
+ local difftime = os.difftime
+ local file_join = file.join
+ local getfirstreadablefile = caches.getfirstreadablefile
+ local gethashes = resolvers.gethashes
+ local hashed = caches.hashed
+ local ipairs = ipairs
+ local pcall = pcall
+ local resolve = resolvers.resolve
+ local time = os.time
+ local totime = utilities.parsers.totime
+
+ local stale = false
+ for _, tree in ipairs(gethashes()) do
+ local lsR_path = file_join(resolve(tree.name), "ls-R")
+ local lsR_time = attributes(lsR_path, "modification")
+
+ local hash = hashed(tree.name)
+ local path = getfirstreadablefile(addsuffix(hash, "lua"), "trees")
+
+ local state, blob = pcall(loadfile, path)
+ local hash_time
+
+ if blob then
+ local data = blob()
+ if data then
+ hash_time = time(totime(data.date .. " " .. data.time))
+ end
+ end
+
+ if lsR_time and hash_time and difftime(lsR_time, hash_time) > 0 then
+ stale = true
+ end
+ end
+
+ if stale then
+ resolvers.renewcache()
+ resolvers.load()
+ end
+\stopluacode
+
+% Set the default paper size
+\readsysfile{context-papersize.tex}{}{}
diff --git a/Master/tlpkg/TeXLive/TLPaper.pm b/Master/tlpkg/TeXLive/TLPaper.pm
index e31d5c1ea23..9cef035b248 100644
--- a/Master/tlpkg/TeXLive/TLPaper.pm
+++ b/Master/tlpkg/TeXLive/TLPaper.pm
@@ -83,14 +83,8 @@ our %paper = (
"context" => {
sub => \&paper_context,
default_component => "tex/context/user",
- default_file => "cont-sys.mkxl",
+ default_file => "context-papersize.tex",
pkg => "context",
- variant => {
- sub => \&paper_context,
- default_component => "tex/context/user",
- default_file => "cont-sys.mkiv",
- pkg => "context",
- }
},
"psutils" => {
sub => \&paper_psutils,
@@ -292,11 +286,10 @@ sub find_paper_file {
sub setup_names {
my $prog = shift;
- my $variant = shift || "";
my $outcomp = $paper_config_path_component{$prog}
- || ($variant eq "variant" ? $paper{$prog}{'variant'}{'default_component'} : $paper{$prog}{'default_component'});
+ || $paper{$prog}{'default_component'};
my $filecomp = $paper_config_name{$prog}
- || ($variant eq "variant" ? $paper{$prog}{'variant'}{'default_file'} : $paper{$prog}{'default_file'});
+ || $paper{$prog}{'default_file'};
return ($outcomp, $filecomp);
}
@@ -681,7 +674,7 @@ sub paper_dvipdfmx {
# context format:
-# /--- cont-sys.mkxl and cont-sys.mkiv // formerly {tex,rme}
+# /--- context-papersize.tex // formerly cont-sys.{tex,rme}
# |...
# |\setuppapersize[letter][letter]
# |...
@@ -696,21 +689,8 @@ sub paper_context {
if ($newpaper && $newpaper eq "a4") {
$newpaper = "A4";
}
- return (__paper_context($outtree, $newpaper, "context") | __paper_context($outtree, $newpaper, "variant"));
-}
-
-sub __paper_context {
- my $outtree = shift;
- my $newpaper = shift;
- my $what = shift;
- my $prog = $what;
- my $prog_long = $what;
- if ($what eq "variant") {
- $prog = "context";
- $prog_long = "context (MkIV)";
- }
- my ($outcomp, $filecomp) = setup_names($prog, $what);
- my $dftfile = ($what eq 'variant' ? $paper{$prog}{'variant'}{'default_file'} : $paper{$prog}{'default_file'});
+ my ($outcomp, $filecomp) = setup_names('context');
+ my $dftfile = $paper{'context'}{'default_file'};
my $outfile = "$outtree/$outcomp/$filecomp";
my $inp = &find_paper_file("context", "tex", $filecomp, $dftfile);
@@ -749,7 +729,6 @@ sub __paper_context {
}
} else {
@lines = []
- # TODO ???
}
# if we haven't found a paper line, assume a4
$currentpaper || ($currentpaper = "A4");
@@ -768,7 +747,7 @@ sub __paper_context {
push @ret, $p unless ($p eq $currentpaper);
}
my %foo;
- $foo{'program'} = $prog;
+ $foo{'program'} = 'context';
$foo{'file'} = $inp;
$foo{'options'} = \@ret;
return \%foo;
@@ -803,14 +782,14 @@ sub __paper_context {
$lines[$#lines] = $addlines;
}
}
- info("$prg: setting paper size for $prog_long to $newpaper: $outfile\n");
+ info("$prg: setting paper size for context to $newpaper: $outfile\n");
mkdirhier(dirname($outfile));
# if we create the outfile we have to call mktexlsr
TeXLive::TLUtils::announce_execute_actions("files-changed")
unless (-r $outfile);
if (!open(TMP, ">$outfile")) {
tlwarn("$prg: Cannot write to $outfile: $!\n");
- tlwarn("Not setting paper size for $prog_long.\n");
+ tlwarn("Not setting paper size for context.\n");
return($F_ERROR);
}
for (@lines) { print TMP; }
@@ -819,12 +798,12 @@ sub __paper_context {
# TODO should we return the value of announce_execute action?
return($F_OK);
} else {
- tlwarn("$prg: Not a valid paper size for $prog_long: $newpaper\n");
+ tlwarn("$prg: Not a valid paper size for context: $newpaper\n");
return($F_WARNING);
}
}
} else {
- info("Current $prog_long paper size (from $inp): $currentpaper\n");
+ info("Current context paper size (from $inp): $currentpaper\n");
}
return($F_OK);
}