ret = RxFuncAdd("SysLoadFuncs", "REXXUTIL", "SysLoadFuncs")
call SysLoadFuncs
SIGNAL on error
/* Load text strings for SysFileDel and SysRmDir return codes. */
CALL LoadDELRCText /* provides text strings for SysFileDel return codes */
CALL LoadRDRCText /* provides text strings for SysRmDir return codes */
say
say INTRO
say
say "On which drive do you want emTeX/TDS to be installed or updated?"
say "(hit <return> only to select the boot drive)"
answer = linein()
texdrive = translate(substr(answer,1,1)) || ":"
if texdrive = ":" then texdrive = bootdrv
ver = SysIni(texdrive"\texmf\emtex\data\EMTEXTDS.INI", "EMTEXTDS", "VERSION")
if ver = "ERROR:" then
ver = 0
else do
say
say "emTeX/TDS version " || ver || " detected."
say
end
/* full install or update only?
ver = 0 : first install, no cleanup required
ver = 0.1 : force full install, despite higher version #
ver < 0.53 : full install
ver >= 0.53 : update only
*/
/* skip this step if full install is required, anyway */
if ver < 0.53 then signal checkfiles
say "By default, your emTeX/TDS system will be updated only."
say "However, you may also force a full reinstall."
say
say "Do you request a full reinstall? (y/n)"
answer = translate(substr(linein(),1,1))
if answer = "Y" then ver = 0.1
/* Determine the required files */
checkfiles:
if ver >= 0.55 then
reqfile.0 = 1
else
if ver >= 0.53 then
reqfile.0 = 2
else
reqfile.0 = 11
/* search for the files in the current directory */
reqfile.1 = "texmf.zip"
reqfile.2 = "config.zip"
reqfile.3 = "bibtex4b.zip"
reqfile.4 = "dvid16h1.zip"
reqfile.5 = "mf4b.zip"
reqfile.6 = "mfjob12d.zip"
reqfile.7 = "mfware.zip"
reqfile.8 = "tex4b.zip"
reqfile.9 = "texware.zip"
reqfile.10= "makeindx.zip"
reqfile.11 = "dvid16h2.zip"
if CheckRequiredFiles("V") then do
do i = 1 to reqfile.0
reqfile.i = wrkdir|| "\" || reqfile.i
end
end
else signal fileerr
/* Last exit */
say
say "emTeX/TDS on drive " || texdrive || " will be installed/updated."
say "Continue? (y/n)"
answer = translate(substr(linein(),1,1))
if answer <> "Y" then signal cancel
/*
Step 0
------
go to the target drive and create the texmf root directory
*/
call SysFileDelete("doc\generic\german\gerdoc.tex")
call SysFileDelete("fonts\source\public\logo\manfnt.mf")
call SysFileDelete("fonts\tfm\public\logo\manfnt.tfm")
call SysFileDelete("source\generic\babel\lcydefs.tex")
call SysFileDelete("dvips\micropress\cmfonts.map")
/* files have been moved to other directory */
call SysFileDelete("emtex\bin\bibtex.exe")
call SysFileDelete("emtex\bin\makeindex.exe")
call SysFileDelete("emtex\bin\dvihplj.exe")
/* will be replaced later */
do i = 1 to 12
if stream(old.i, "C", "QUERY EXISTS") <> "" & ,
stream("\texmf\fonts\type1\adobe\eurofont\"||new.i, "C", "QUERY EXISTS") = "" then do
"ren " old.i new.i
end
end
/*
Step 3
------
Install the required parts of the original emTeX distribution.
*/
emtex:
/* skip this step, if ver>=0.53 found */
if ver >= 0.53 then signal tds
/*
Step 4
------
Installing
- the non-emTeX parts of the TDS tree and
customized cmd scripts for emtex,
- the configuration files,
*/
tds:
say "Installing the texmf tree ..."
/* Overwrite existing files */
ret=value("UNZIP", "-qqo", "OS2ENVIRONMENT")
/* reqfile.1 => texmf */
"unzip "||reqfile.1
if reqfile.0 >= 2 then do
/* here we have to ask before owerwriting configuration files: */
ret=value("UNZIP", "-qq", "OS2ENVIRONMENT")
/* reqfile.2 => config */
"unzip "||reqfile.2
end
say " done."
/* The configuration file docstrip.cfg is special, */
/* because its contents must reflect the drive letter */
/* where TeX is installed. */
/* This file is generated unless it's already present.*/
filename = texdrive || "\texmf\tex\latex\local\docstrip.cfg"
if stream(filename, "C", "QUERY EXISTS") = "" then do
say "Creating the file docstrip.cfg ..."
call lineout filename, "%% file docstrip.cfg, generated by tdsinst.cmd"
call lineout filename, "%% do not edit this file!"
call lineout filename, "\BaseDirectory{"||texdrive||"/texmf}"
call lineout filename, "\UseTDS"
call stream filename, "C", "CLOSE"
say " done."
end
/*
Step 5
------
Creating a program object for dvipm
*/
/* skip this step, unless full install is required */
if ver > 0.1 then signal writever
say
say "Do you want an object for dvipm to be created on the desktop? (y/n)"
answer = translate(substr(linein(),1,1))
if answer = "Y" then do
say "Creating an object for the dvi viewer ..."
res = make_po('dvipm', 'PM', texdrive||'\texmf\emtex\bin\dvipm.exe', '@vp.cnf %*', '')
if res = 1 then say " done."
else say " failed."
end
/*
Step 5a
--------
Writing the version number
*/
writever:
call SysIni "\texmf\emtex\data\EMTEXTDS.INI", "EMTEXTDS", "VERSION", VERSION
say
say "Version number" VERSION "written."
say
say "All files of the emTeX/TDS system have been successfully installed."
"pause"
/*
Step 6
------
Checking emx
*/
say
say "I am going to check the EMX library now."
say
emxpaths = 0
currentrev = emxrevision()
say "emx rev. =" currentrev
if (currentrev = 0) then do
call beep 440,250
say
say "I cannot find the emx runtime environment."
say "Install the latest version of emx before using TeX!"
"pause"
end
if (currentrev > 0) & (currentrev < REQEMXREV)then do
call beep 440,250
say
say "The emx runtime environment found is not up to date."
say "Install the latest version of emx before using TeX!"
"pause"
end
else say "Ok."
/*
Step 7
------
Updating config.sys
*/
/* skip this step if ver > 0.5 found */
if ver > 0.5 then signal done
configfile = bootdrv||"\config.sys"
if stream(configfile,"C","QUERY EXISTS") = "" then signal nobootdrv
call readconfig configfile
if checkvar("TMP") = "" then do
tmpname = bootdrv||"\tmp"
call SysMkDir tmpname
call addvar "TMP", tmpname
say
say "Temporary files will be created in the directory" tmpname "."
say
end /* do */
call addvar "EMTEXDIR", texdrive||"\TEXMF\EMTEX"
call addvar "TEXMACROS", texdrive||"\TEXMF\TEX"
call addvar "TEXTFM", texdrive||"\TEXMF\FONTS\TFM!!;."
call addvar "BFONTS", texdrive||"\TEXMF\FONTS\PK"
call addvar "TYPE1FONTS", texdrive||"\TEXMF\FONTS\TYPE1"
call addvar "TEXCONFIG", texdrive||"\TEXMF\DVIPS!!"
call addvar "VFONTS", texdrive||"\TEXMF\FONTS\VF!!"
call addvar "EMTEXSWCHAR", "-"
call addvar "MFOPT", "-mp50000"
call addvar "MFJOBOPT", "-3 -i"
call addvar "MFINPUT", texdrive||"\TEXMF\FONTS\SOURCE!!;"||texdrive"\TEXMF\METAFONT!"
call addvar "INDEXSTYLE", texdrive||"\TEXMF\MAKEINDEX"
call addvar "BSTINPUT", texdrive||"\TEXMF\BIBTEX\BST"
call addvar "BIBINPUT", texdrive||"\TEXMF\BIBTEX\BIB"
if pathedit("PATH", texdrive||"\texmf\emtex\bin;") = 0 then signal updfailed
if pathedit( "HELP", texdrive||"\texmf\emtex\help;") = 0 then signal updfailed
if libpathedit(texdrive||"\texmf\emtex\dll;") = 0 then signal updfailed
say
say "The installation program is going to update the file config.sys now."
say "If you prefer to do this manually, then enter `n' below,"
say "otherwise enter `y' to continue."
say "Continue? (y/n)"
answer = translate(substr(linein(),1,1))
if answer <> "Y" then signal done
tempfile=SysTempFileName(bootdrv||"\config??.sys")
if tempfile="" then signal updfailed
signal on error name updfailed
savedfile = filespec("N", tempfile)
"ren" configfile savedfile
say
say "The file" configfile "has been renamed to" savedfile "."
res = writeconfig(configfile)
if res=0 then do
call beep 440,250
say "Writing a new file" configfile "failed".
say "Rename" savedfile "to config.sys and apply the changes manually."
end
else do
say
say "A new file" configfile "has been written."
say "Shutdown and reboot OS/2 now to make the changes come into effect."
end
/*
exiting
*/
done:
say
say "Finis!"
exit
/*
Error handling:
*/
nobootdrv:
say
say "The installation program could not locate the file config.sys"
say "and was unable to determine whether it needs to be updated."
say "Please, see the installation instructions for the changes required"
say "and how to apply them manually."
exit
updfailed:
say
say "Updating config.sys failed."
say "The file config.sys has *** not *** been changed."
say "Please, read the installation instructions"
say "and apply any changes manually."
exit
error:
call beep 440,250
say
say 'Error: "'condition('D')'"' 'failed.'
exit
fileerr:
call beep 440,250
say
say "One or more of the files required to"
say "install or update emTeX/TDS were not found."
exit
unziperr:
call beep 440,250
say
say 'The required program "unzip.exe" could not be found.'
exit
cancel:
say "You have terminated the installation program."
exit
/*
Procedures used above:
*/
/*
make_folder: procedure
location = '<EMTEXTDS_FOLDER>'
if \SysCreateObject('WPFolder', 'emTeX/TDS', '<WP_DESKTOP>', ,
'OBJECTID='||location, 'update') then do
say 'Cannot create emTeX/TDS folder.'
exit 1
end
return
*/
if parameters <> '' then
options = options || 'PARAMETERS='||parameters||';'
if workdir <> '' then
options = options || 'STARTUPDIR='||workdir||';'
if \SysCreateObject('WPProgram', title, '<WP_DESKTOP>', options, 'Update') then do
say 'Cannot create program object.'
return 0
end
else
return 1
/*
query boot drive
usage: querybootdrv()
returns: letter of boot drive incl. colon
*/
querybootdrv: PROCEDURE
bootdr = value('COMSPEC', , 'OS2ENVIRONMENT')
bootdr = filespec('D', bootdr)
if bootdr = "" then do
say "Please, tell me the drive letter of the boot drive:"
answer = linein()
bootdr = substr(strip(answer),1,1)||":"
end
return bootdr
/*
Do all required files exist?
usage: CheckRequiredFiles() or CheckRequiredFiles("V")
returns: 1 if all files found, 0 otherwise
*/
CheckRequiredFiles: PROCEDURE expose reqfile.
parse arg verbose
/* empty line, to make further messages more visible: */
if verbose = "V" then say
res = 1
do i = 1 to reqfile.0
if stream(reqfile.i, "C", "QUERY EXISTS") = "" then do
res = 0
if verbose = "V" then say "missing file:" reqfile.i
end
end
return res
/*
read config file
usage: call readconfig filename
returns: (nothing)
*/
readconfig: PROCEDURE expose config. cmax
parse arg infile
cmax=0
do while lines(infile) > 0
cmax=cmax+1
config.cmax=linein(infile)
end /* do */
call stream infile, "C", "CLOSE"
return
/*
write config file
usage: call writeconfig filename
returns: 1 if successful
0 if writing the file failed
*/
writeconfig: PROCEDURE expose config. cmax
parse arg outfile
call SysFileDelete outfile
do i = 1 TO cmax
if config.i <> "deleted" then do
res = lineout(outfile, config.i)
end
end /* do */
call stream outfile, "C", "CLOSE"
if res <> 0 then return 0
else return 1
/*
search for a given environment variable
usage: checkvar(name)
returns: setting
"" if undefined or defined as empty
*/
checkvar: PROCEDURE expose config. cmax
parse upper arg name
i=0
name=strip(name)
trigger=" "||name||"="
do forever
i=i+1
if i>cmax then leave
parse upper value config.i with junk (trigger) setting
if (setting <> "") & (junk="SET") then leave
end /* do */
if i>cmax then return ""
else return setting
/*
add environment variable, overwrites current setting
usage: call addvar name, value
returns: (nothing)
*/
addvar: PROCEDURE expose config. cmax
parse arg name, value
name = strip(translate(name))
trigger=" "||name||"="
i=0
do forever
i=i+1
if i>cmax then leave
parse upper value config.i with junk (trigger) setting
if (setting <> "") & (junk = "SET") then leave
end /* do */
config.i = "SET " || name || "=" || value
if i>cmax then cmax=i
return
/*
delete environment variable
usage: delvar(name)
returns: 1 if successful
0 if variable not found
*/
delvar: PROCEDURE expose config. cmax
parse arg name
name=strip(translate(name))
trigger=" "||name||"="
i=0
do forever
i=i+1
if i>cmax then leave
parse upper value config.i with junk (trigger) setting
if (setting <> "") & (junk="SET") then leave
end /* do */
if i>cmax then return 0
else do
config.i = "deleted"
return 1
end /* do */
/*
edit a path
usage: pathedit(path, entry, op)
op = "D" means "delete this entry"
op = "A" (default) means "add entry"
returns 1 if successful
0 if path or entry to be deleted not found
2 if entry to be added was already present
*/
pathedit: PROCEDURE expose config. cmax
parse upper arg path, directory, op
i=0
path=strip(path)
trigger = " "||path||"="
do forever
i=i+1
if i>cmax then leave
parse upper value config.i with junk (trigger) setting
if (setting <> "") & (junk="SET") then leave
end /* do */
if i>cmax then return 0
setting=strip(setting,"T")
if substr(directory,length(directory),1) <> ";" then directory = directory || ";"
if substr(setting,length(setting),1) <> ";" then setting = setting || ";"
if op="D" then do
posi = pos(directory,setting)
if posi<>0 then config.i= "SET " || path || "=" || delstr(setting, posi, length(directory))
else return 0
end /* do */
else do
if pos(directory,setting)<>0 then return 2
else do
setting=setting || directory
config.i = "SET " || path || "=" || setting
end /* do */
end /* do */
return 1
/*
edit LIBPATH
usage: libpathedit(entry, op)
op = "D" means "delete this entry, if existing"
op = "A" (default) means "add entry"
returns: 1 if successful
0 if LIBPATH or entry to be deleted not found
2 if entry to be added was already present
*/
libpathedit: PROCEDURE expose config. cmax
parse upper arg directory, op
i=0
do forever
i=i+1
if i>cmax then leave
parse upper value config.i with junk "LIBPATH" setting
if (setting <> "") & (junk = "") then leave
end /* do */
if i>cmax then return 0
setting=strip(setting,"T")
if substr(directory,length(directory),1) <> ";" then directory = directory || ";"
if substr(setting,length(setting),1) <> ";" then setting = setting || ";"
if op="D" then do
posi = pos(directory,setting)
if posi<>0 then config.i= "LIBPATH" || delstr(setting, posi, length(directory))
else return 0
end /* do */
else do
if pos(directory,setting)<>0 then return 2
else do
setting=setting || directory
config.i = "LIBPATH" || setting
end /* do */
end /* do */
return 1
emxrevision: procedure
call RxFuncAdd emx_revision, "emx", emx_revision
signal on syntax name noemx
tmp = emx_revision()
signal off syntax
call RxFuncDrop emx_revision
return tmp
noemx: return 0
/*
Procedures for deleting a directory tree
*/
DDT:
parse arg user_dir
/* Check to make sure the directory exists */
rc=SysFileTree(user_dir,dir_list, 'D')
IF dir_list.0 = 0 THEN
DO
SAY user_dir 'not found.'
RETURN
END
DROP dir_list.
/* Mark all the read-only files to be non read-only */
rc=SysFileTree(user_dir || '\*.*', dir_list, 'FSO', '****','----')
DROP dir_list.
/* Go through the list of files and delete each one */
rc=SysFileTree(user_dir || '\*.*', dir_list, 'FSO')
DO x = 1 TO dir_list.0
rc = SysFileDelete(dir_list.x)
if rc <> 0 then SAY dir_list.x '........' DELRCText.RC
END
DROP dir_list.
/* Go through all the subdirectories and remove them. */
/* We go backwards through the list in order to delete the */
/* lowest level sudirectories first and work our way back up */
/* the tree. */
rc=SysFileTree(user_dir || '\*.*', dir_list, 'DSO')
DO x = dir_list.0 TO 1 BY -1
rc=SysRmDir(dir_list.x)
if RC <> 0 then SAY dir_list.x '........' RDRCText.RC
END
DROP dir_list.
/* Delete the topmost directory */
rc=SysRmDir(user_dir)
SAY user_dir '........' RDRCText.RC
RETURN
LoadDELRCText:
/* provides text strings for SysFileDel return codes */
/* The return codes and strings are in the online Rexx manual */