data-tmf.lua /size: 2601 b    last modification: 2020-07-01 14:35
1
if
not
modules
then
modules
=
{
}
end
modules
[
'
data-tmf
'
]
=
{
2
version
=
1
.
001
,
3
comment
=
"
companion to luat-lib.mkiv
"
,
4
author
=
"
Hans Hagen, PRAGMA-ADE, Hasselt NL
"
,
5
copyright
=
"
PRAGMA ADE / ConTeXt Development Team
"
,
6
license
=
"
see context related readme files
"
7
}
8 9
local
resolvers
=
resolvers
10 11
local
report_tds
=
logs
.
reporter
(
"
resolvers
"
,
"
tds
"
)
12 13
-- = <<
14
-- ? ??
15
-- < +=
16
-- > =+
17 18
function
resolvers
.
load_tree
(
tree
,
resolve
)
19
if
type
(
tree
)
=
=
"
string
"
and
tree
~
=
"
"
then
20 21
local
getenv
,
setenv
=
resolvers
.
getenv
,
resolvers
.
setenv
22 23
-- later might listen to the raw osenv var as well
24
local
texos
=
"
texmf-
"
.
.
os
.
platform
25 26
local
oldroot
=
environment
.
texroot
27
local
newroot
=
file
.
collapsepath
(
tree
)
28 29
local
newtree
=
file
.
join
(
newroot
,
texos
)
30
local
newpath
=
file
.
join
(
newtree
,
"
bin
"
)
31 32
if
not
lfs
.
isdir
(
newtree
)
then
33
report_tds
(
"
no %a under tree %a
"
,
texos
,
tree
)
34
os
.
exit
(
)
35
end
36
if
not
lfs
.
isdir
(
newpath
)
then
37
report_tds
(
"
no '%s/bin' under tree %a
"
,
texos
,
tree
)
38
os
.
exit
(
)
39
end
40 41
local
texmfos
=
newtree
42 43
environment
.
texroot
=
newroot
44
environment
.
texos
=
texos
45
environment
.
texmfos
=
texmfos
46 47
-- Beware, we need to obey the relocatable autoparent so we
48
-- set TEXMFCNF to its raw value. This is somewhat tricky when
49
-- we run a mkii job from within. Therefore, in mtxrun, there
50
-- is a resolve applied when we're in mkii/kpse mode or when
51
-- --resolve is passed to mtxrun. Maybe we should also set the
52
-- local AUTOPARENT etc. although these are alwasy set new.
53 54
if
resolve
then
55
-- resolvers.luacnfspec = resolvers.joinpath(resolvers.resolve(resolvers.expandedpathfromlist(resolvers.splitpath(resolvers.luacnfspec))))
56
resolvers
.
luacnfspec
=
resolvers
.
resolve
(
resolvers
.
luacnfspec
)
57
end
58 59
setenv
(
'
SELFAUTOPARENT
'
,
newroot
)
60
setenv
(
'
SELFAUTODIR
'
,
newtree
)
61
setenv
(
'
SELFAUTOLOC
'
,
newpath
)
62
setenv
(
'
TEXROOT
'
,
newroot
)
63
setenv
(
'
TEXOS
'
,
texos
)
64
setenv
(
'
TEXMFOS
'
,
texmfos
)
65
setenv
(
'
TEXMFCNF
'
,
resolvers
.
luacnfspec
,
true
)
-- already resolved
66
setenv
(
'
PATH
'
,
newpath
.
.
io
.
pathseparator
.
.
getenv
(
'
PATH
'
)
)
67 68
report_tds
(
"
changing from root %a to %a
"
,
oldroot
,
newroot
)
69
report_tds
(
"
prepending %a to PATH
"
,
newpath
)
70
report_tds
(
"
setting TEXMFCNF to %a
"
,
resolvers
.
luacnfspec
)
71
report_tds
(
)
72
end
73
end
74