summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2008-04-27 09:27:40 +0000
committerNorbert Preining <preining@logic.at>2008-04-27 09:27:40 +0000
commita2f1940330172217c9585fbb77148af940753c04 (patch)
treec6d964b2c6c56e950210153344955ff9296e3113 /Master
parent752197187e840c9fecfb96509605a430eb41528b (diff)
more lua library out factoring
git-svn-id: svn://tug.org/texlive/trunk@7678 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf/scripts/texlive/lua/getopt.tlu1
-rw-r--r--Master/texmf/scripts/texlive/lua/texlive/utils.tlu68
-rwxr-xr-xMaster/texmf/scripts/texlive/texconf.tlu15
-rwxr-xr-xMaster/texmf/scripts/texlive/tlmgr.tlu78
4 files changed, 77 insertions, 85 deletions
diff --git a/Master/texmf/scripts/texlive/lua/getopt.tlu b/Master/texmf/scripts/texlive/lua/getopt.tlu
index d1e90503de7..94ae411f26e 100644
--- a/Master/texmf/scripts/texlive/lua/getopt.tlu
+++ b/Master/texmf/scripts/texlive/lua/getopt.tlu
@@ -1,6 +1,7 @@
-- getopt.tlu
--
-- (tex)lua library function for argument processing
+-- $Id$
--
-- Copyright 2008 Norbert Preining
--
diff --git a/Master/texmf/scripts/texlive/lua/texlive/utils.tlu b/Master/texmf/scripts/texlive/lua/texlive/utils.tlu
new file mode 100644
index 00000000000..92c46872389
--- /dev/null
+++ b/Master/texmf/scripts/texlive/lua/texlive/utils.tlu
@@ -0,0 +1,68 @@
+-- texlive/utils.tlu
+-- $Id$
+--
+-- Copyright (C) 2008 Reinhard Kotucha, Norbert Preining
+-- You may freely use, modify and/or distribute this file.
+--
+-- general utilities for TeX Live lua scripts
+
+function setupperl()
+ -- For Windows we use the shipped perl interpreter, otherwise we expect
+ -- a perl to be installed
+ local perlbin
+ if os.type == 'windows' then
+ perlbin=TEXDIR..'/tlpkg/tlperl/bin/perl.exe'
+ os.setenv('PERL5LIB', TEXDIR..'/tlpkg/tlperl/lib')
+ else
+ perlbin = 'perl'
+ end
+ return perlbin
+end
+
+function findscript(scriptname)
+ local script = kpse.find_file(scriptname, 'texmfscripts')
+ if script then
+ return script
+ else
+ io.stderr:write(filename..': Cannot find script '..scriptname)
+ return false
+ end
+end
+
+-- fix arguments for windows
+function fixwin(args_unix)
+ if os.type == 'windows' then
+ local args_win={} -- new table
+ args_win[0]=args_unix[1]
+ for i=1, #args_unix do
+ args_win[i]='"'..args_unix[i]..'"'
+ end
+ return args_win
+ else
+ return args_unix
+ end
+end
+
+function rmtree (path)
+ if lfs.isdir(path) then
+ for file in lfs.dir(path) do
+ if file ~= '.' and file ~= '..' then
+ local f = path..'/'..file
+ if lfs.isdir(f) then
+ rmtree(f)
+ lfs.rmdir(f)
+ else
+ os.remove(f)
+ end
+ end
+ end
+ lfs.rmdir(path)
+ end
+end
+
+-- Local Variables:
+-- lua-indent-level: 2
+-- tab-width: 2
+-- indent-tabs-mode: nil
+-- End:
+-- vim:set tabstop=2 expandtab: #
diff --git a/Master/texmf/scripts/texlive/texconf.tlu b/Master/texmf/scripts/texlive/texconf.tlu
index 8a15789815e..d4494e02ad0 100755
--- a/Master/texmf/scripts/texlive/texconf.tlu
+++ b/Master/texmf/scripts/texlive/texconf.tlu
@@ -7,20 +7,6 @@
-- texconf is a subset of Thomas Esser's texconfig shell script.
-
-function fixwin(args_unix)
- if os.type == 'windows' then
- local args_win={} -- new table
- args_win[0]=args_unix[1]
- for i=1, #args_unix do
- args_win[i]='"'..args_unix[i]..'"'
- end
- return args_win
- else
- return args_unix
- end
-end
-
if string.find(arg[0], '/') then -- UNIX path
filename=select(1, string.gsub(arg[0], '.*/', ''))
elseif string.find(arg[0], '\\') then -- Windows path
@@ -54,6 +40,7 @@ kpse.set_program_name( "mktexlsr" )
texmfmain = kpse.var_value('TEXMFMAIN')
package.path = texmfmain.."/scripts/texlive/lua/?.tlu"
require("getopt")
+require("texlive.utils")
-- do argument processing
options = getopt ( { sys = 0, prog = 1 } )
diff --git a/Master/texmf/scripts/texlive/tlmgr.tlu b/Master/texmf/scripts/texlive/tlmgr.tlu
index f60abe36717..04676f448eb 100755
--- a/Master/texmf/scripts/texlive/tlmgr.tlu
+++ b/Master/texmf/scripts/texlive/tlmgr.tlu
@@ -23,72 +23,6 @@
-- anything else tl-package-manager.pl
-- that is update, install, remove, search, ......
-function fixwin(args_unix)
- if os.type == 'windows' then
- local args_win={} -- new table
- args_win[0]=args_unix[1]
- for i=1, #args_unix do
- args_win[i]='"'..args_unix[i]..'"'
- end
- return args_win
- else
- return args_unix
- end
-end
-
-function setupperl()
- -- For Windows we use the shipped perl interpreter, otherwise we expect
- -- a perl to be installed
- if os.type == 'windows' then
- perlbin=TEXDIR..'/tlpkg/tlperl/bin/perl.exe'
- os.setenv('PERL5LIB', TEXDIR..'/tlpkg/tlperl/lib')
- else
- perlbin = 'perl'
- end
-end
-
-function findscript(scriptname)
- local script = kpse.find_file(scriptname, 'texmfscripts')
- if script then
- return script
- else
- io.stderr:write(filename..': Cannot find script '..scriptname)
- return false
- end
-end
-
--- function from Reinhard, could replace rmdir, needs testing
-function rmtree (path)
- if lfs.isdir(path) then
- for file in lfs.dir(path) do
- if file ~= '.' and file ~= '..' then
- local f = path..'/'..file
- if lfs.isdir(f) then
- rmtree(f)
- lfs.rmdir(f)
- else
- os.remove(f)
- end
- end
- end
- lfs.rmdir(path)
- end
-end
-
-function rmdir(name)
- if os.type == 'windows' then
- -- code from Hans
- os.execute('rmdir /s /q "' .. name:gsub('/', '\\')..'"')
- else
- ret = os.spawn({"rm", "-rf", name})
- end
- local ok = lfs.attributes(name)
- if ok then
- io.stderr:write(string.format("%s: removing '%s' didn't succeed\n",filename,name))
- end
- return ok
-end
-
if string.find(arg[0], '/') then -- UNIX path
filename=select(1, string.gsub(arg[0], '.*/', ''))
elseif string.find(arg[0], '\\') then -- Windows path
@@ -113,6 +47,13 @@ TEXDIR=kpse.var_value('SELFAUTOPARENT')
TEXMFSYSVAR=kpse.var_value('TEXMFSYSVAR')
BINDIR=kpse.var_value('SELFAUTOLOC')
+-- set the search path for lua libraries
+texmfmain = kpse.var_value('TEXMFMAIN')
+package.path = texmfmain.."/scripts/texlive/lua/?.tlu"
+require("texlive.utils")
+
+-- setup perl once and for all
+perlbin = setupperl()
if arg[1] == 'uninstall' then
if os.type == 'windows' then
@@ -130,7 +71,6 @@ if arg[1] == 'uninstall' then
-- TEXDIR/install-tl.log, TEXMFSYSVAR
-- that should remove all the stuff
-- Or other options?
- setupperl()
script = findscript('uninstall-tl.pl')
if script then
command = { perlbin, script }
@@ -171,7 +111,6 @@ if arg[1] == 'uninstall' then
os.exit(0)
end
elseif arg[1] == 'generate-fmtutil' then
- setupperl()
script = findscript('generate-fmtutil.pl')
if script then
command = { perlbin, script }
@@ -179,7 +118,6 @@ elseif arg[1] == 'generate-fmtutil' then
os.exit(1)
end
elseif arg[1] == 'generate-language' then
- setupperl()
script = findscript('generate-language.pl')
if script then
command = { perlbin, script }
@@ -187,7 +125,6 @@ elseif arg[1] == 'generate-language' then
os.exit(1)
end
elseif arg[1] == 'generate-updmap' then
- setupperl()
script = findscript('generate-updmap.pl')
if script then
command = { perlbin, script }
@@ -206,7 +143,6 @@ elseif arg[1] == 'paper' or
end
else
-- in all other cases we call tl-package-manager for now ...
- setupperl()
script = findscript('tl-package-manager.pl')
if script then
command = { perlbin, script }