[tex-live] TL in portable mode on Windows

T T t34www at googlemail.com
Sat Dec 20 18:55:45 CET 2008


I'm trying to figure out a way to prepare a portable installation of TL2008
and I'm having some trouble with this. I know that TL2008 can be run live
from DVD and it even comes with a batch launcher for that purpose, which is
really welcome, but it's a whooping 2.5GB with kitchen sink included, so I'm
looking for a slimmer solution.

Let me first explain what I'm trying to achieve and then I'll describe some
of the issues I encountered in my poking around so far.

I want to find a way to turn TL into fully functional (i.e. with working
tlmgr, etc.) portable distribution that (optionally) integrates with
PortableApps. By finding a way I mean a procedure that could be easily
followed by a boarder range of users (read: all those windoze illiterates
out there) so it shouldn't be too arcane. Preferably, this procedure should
allow for a full or at least partial automation of the process, so it can be
canned for regular users.

I have a fairly good idea how this could be done but there seem to be some
limitations in the current installer and I don't know how to get around
them.

The first problem is that there seems to be no way to make administrative
installation on Windows (i.e. without any system integration, like shortcuts
or uninstaller). Is that right?

Next, upon installation, TL breaks any other TeX installation on the system
by removing it from the path. Although this is documented (
http://www.tug.org/texlive/windows.html) I still consider it a bug to
interfere with other software on the system without explicit user consent.
It's essentially as bad as changing file associations without asking (not
that uncommon on Windows, I'm afraid). Furthermore, during uninstallation
the original path is not restored and user has to fix it manually.

My attempt to run tl-portable.bat script (copied from live .iso) from the
root of installed TL failed because some installer files were missing (the
installation itself was functional). I could probably track down the missing
files but I will leave it for later (if anybody knows which files are
missing, it will save me some forensic work). Bypassing

"%TEXDIR%tlpkg\installer\perl" "%TEXDIR%install-tl" --portable

in tl-portable.bat seemed to do the trick for now. As far as I can tell from
skimming through the installer source, calling it with --portable switch has
no effect unless there are some texmf trees missing, in which case they are
generated. In fact, only TEXMFSYSVAR is tested for existence, if I read it
correctly (note: I don't know perl). This test could be moved into the
launcher script itself to make it run faster (more on that below).

tl-portable.bat could be useful not only for launching TL shell but also
other tools, e.g. text editor or compilation script. Unfortunately, in its
current form this not possible. I would suggest the following modification
near the end of tl-portable.bat:

:doit
path %TEXDIR%bin\win32;%path%
if [%1]==[] goto :tlshell
%*
exit /b %errorlevel%

:tlshell
set PROMPT=TL $P$G
%COMSPEC% /k

Without any arguments tl-portable.bat will work almost exactly as before
(the only difference is that 'exit' after '%COMSPEC% /k' has been removed -
there is no need for it). With arguments, the supplied command line will be
executed instead of starting cmd shell. For example:

tl-portable.bat pdflatex <file>

can be used for portable compilation with pdflatex (or in configuration of a
text editor). For that purpose it would be also important to avoid calling
Perl installer if not necessary as mentioned above and also to preserve the
current working directory from the calling process. Currently
tl-portable.bat (and install-tl.bat as well) starts like this:

rem TeX Live Root; ends with backslash
rem This should also work with UNC names
set TEXDIR=%~dp0
set tldrive=%~d0

%tldrive%
cd %TEXDIR%

Despite what the comment says, this code will fail with UNC paths. This is
because '%~d0' will expand to '\\' and furthermore cmd.exe does not allow
UNC path to be used as a current directory (it will fallback on %WINDIR% if
launched from network drive). This creates some problems. Under restricted
account %WINDIR% is not writeable and launcher will behave as if run from
DVD (i.e. it will use %USERPROFILE%). For admin user TL will generate files
in the system folder.

I don't see anything in tl-portable.bat or install-tl.bat that would require
changing the current directory (except for perhaps the Perl installer - I
couldn't deduce that from the source). Thus, it should be OK to either
remove that part all together or change it only for the Perl installer. I
tested both scripts without changing cw and launching them from other
location than TL root. In both cases all appeared to function properly (I
could compile sample files without problems). So, it would seem that
changing the current directory is not required, but I cannot say that with
certainty based on my limited testing.

To play it save, below I suggest a modification with pushd/popd commands
combo. This will temporarily map network location onto a drive letter if
necessary. The possible drawback is that if for some reason the script would
terminate before popd is reached, the drive will have to be unmapped
manually.

if exist %TEXMFSYSVAR%\ goto doit
pushd "%TEXDIR%"
set PERL5LIB=%TEXDIR%tlpkg\installer\perllib
"%TEXDIR%tlpkg\installer\perl" "%TEXDIR%install-tl" --portable
popd
if not errorlevel 1 goto doit
echo Initialization of TeXLive failed!
pause
exit /b %errorlevel%

Note that this also incorporates the TEXMFSYSVAR test to speed up the
launcher. With this change the initial part of the script can be removed
(except for 'set TEXDIR=%~dp0' line). Another difference with respect to the
current script will be that the welcome banner will not be displayed anymore
(this is done by the perl script but it can be easily fixed, e.g. by putting
welcome message in an external file and calling 'type banner.txt').


To summarize this already long post: I think I can manage to resolve most of
the issues on my own; the only thing I don't know is how to tell TL
installer to skip system integration. I could probably write a script that
runs installer, copy files and uninstalls TL but: (a) I don't know if TL
will work portably without any side effects in this manner and (b) it would
be a real kludge and I would have to watch for things like messing up
MiKTeX, so I'm not very keen on that.

I hope someone can help me to find some solution. I'm happy to contribute
any changes upstream if desired and I can offer my help in batch scripting
and automation on Windows. Unfortunately my Perl knowledge is very limited,
so that rules out any but trivial changes to the installer on my part.

Cheers,

Tomek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/tex-live/attachments/20081220/932453bc/attachment.html 


More information about the tex-live mailing list