home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / cmdpk164.zip / install.cmd < prev    next >
OS/2 REXX Batch file  |  1998-01-10  |  11KB  |  336 lines

  1. /* install cmdshl */
  2. /* (w) (c) 1997 Ulrich Möller */
  3.  
  4. '@echo off'
  5. signal on halt; trace off
  6.  
  7. call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
  8. call SysLoadFuncs
  9.  
  10. nl = '0a0d'x
  11. foundList.0 = 0
  12.  
  13. say ""
  14. say 'Please select your language -- Bitte wählen Sie Ihre Sprache'
  15. say ""
  16. say 'Please press "E" to install MLRXSHL/CommandPak in English.'
  17. say 'Drücken Sie bitte "D", um MLRXSHL/CommandPak auf deutsch zu installieren.'
  18.  
  19. key = ''
  20. do until pos(key,"ED") > 0
  21.    key = translate(SysGetKey("NOECHO"))
  22. end /* do */
  23.  
  24. select
  25.     when (key = "D") then
  26.         lang="049"
  27.     when (key = "E") then
  28.         lang="001"
  29. end
  30.  
  31. callxhelpStr = "call xhelp -F inst"lang".msg"
  32.  
  33. cls
  34.  
  35. callxhelpStr "welcomeMsg"
  36. call pause
  37.  
  38. callxhelpStr "disclaimerMsg"
  39. call pause
  40. 'view cmdpak0 disclaimer'
  41. callxhelpStr "pauseMsg"
  42. call pause
  43.  
  44. callxhelpStr "checkingPrevious"
  45. call filesExist "cmdshl.cmd", value('PATH',,'OS2ENVIRONMENT')
  46. call filesExist "df.cmd", value('PATH',,'OS2ENVIRONMENT')
  47. call filesExist "fl.cmd", value('PATH',,'OS2ENVIRONMENT')
  48. call filesExist "less.cmd", value('PATH',,'OS2ENVIRONMENT')
  49. call filesExist "ln.cmd", value('PATH',,'OS2ENVIRONMENT')
  50. call filesExist "popd.cmd", value('PATH',,'OS2ENVIRONMENT')
  51. call filesExist "pushd.cmd", value('PATH',,'OS2ENVIRONMENT')
  52. call filesExist "query.cmd", value('PATH',,'OS2ENVIRONMENT')
  53. call filesExist "sdir.cmd", value('PATH',,'OS2ENVIRONMENT')
  54. call filesExist "watchdrv.cmd", value('PATH',,'OS2ENVIRONMENT')
  55. call filesExist "whence.cmd", value('PATH',,'OS2ENVIRONMENT')
  56. call filesExist "xcp.cmd", value('PATH',,'OS2ENVIRONMENT')
  57. call filesExist "xdel.cmd", value('PATH',,'OS2ENVIRONMENT')
  58. call filesExist "xdir.cmd", value('PATH',,'OS2ENVIRONMENT')
  59. call filesExist "xhelp.cmd", value('PATH',,'OS2ENVIRONMENT')
  60. call filesExist "xren.cmd", value('PATH',,'OS2ENVIRONMENT')
  61. call filesExist "profile.shl", value('PATH',,'OS2ENVIRONMENT')
  62. call filesExist "mlrxshl0.inf", value('BOOKSHELF',,'OS2ENVIRONMENT')
  63. call filesExist "mlrxshl.inf", value('BOOKSHELF',,'OS2ENVIRONMENT')
  64. call filesExist "cmdpak0.inf", value('BOOKSHELF',,'OS2ENVIRONMENT')
  65. call filesExist "cmdpak.inf", value('BOOKSHELF',,'OS2ENVIRONMENT')
  66. call filesExist "rexxvio.dll", getLibPath()
  67. call filesExist "wptools.dll", getLibPath()
  68. if foundList.0 > 0 then do
  69.     callxhelpStr "foundPrevious"
  70.     str = "<HTML><UL FIRST=3>"
  71.     do x = 1 to foundList.0
  72.         len = length(foundList.x)
  73.         str=str "<UL FIRST=3 NEXT="len+4"><LI>" foundList.x
  74.         do y = 1 to foundList.x.0
  75.             str = str foundList.x.y
  76.         end
  77.         str = str "</UL>"
  78.     end
  79.     'call xhelp "'str'"'
  80.     callxhelpStr "foundPrevious2"
  81.     callxhelpStr "pauseMsg"
  82.     call pause
  83. end
  84.  
  85. directories:
  86. callxhelpStr "targetDir"
  87. targetDir = queryDir(value('PATH',,'OS2ENVIRONMENT'), 'PATH')
  88.  
  89. callxhelpStr "dllDir"
  90. dllDir = queryDir(getLibPath(), 'LIBPATH')
  91.  
  92. /* callxhelpStr "profileDir"
  93. profileDir = queryDir(value('DPATH',,'OS2ENVIRONMENT'), 'DPATH') */
  94. profileDir = targetDir
  95.  
  96. callxhelpStr "helpDir"
  97. infDir = queryDir(value('BOOKSHELF',,'OS2ENVIRONMENT'), 'BOOKSHELF')
  98.  
  99. callxhelpStr "readyQuery"
  100. if (yesno() = "N") then signal directories
  101.  
  102. say ""
  103. curdir = directory()
  104. call checkDir targetDir
  105. call checkDir dllDir
  106. call checkDir profileDir
  107. call checkDir infDir
  108.  
  109. call charout ,"Now copying files... "
  110. call directory curdir
  111. 'copy *.cmd' targetDir '> NUL'
  112. 'copy *.msg' targetDir '> NUL'
  113. 'copy *.ico' targetDir '> NUL'
  114. 'copy readme*' targetDir '> NUL'
  115. 'copy history*' targetDir '> NUL'
  116. 'copy *.inf' infDir '> NUL'
  117. 'copy *.ipf' infDir '> NUL'
  118. 'copy *.dll' dllDir '> NUL'
  119. 'copy profile*' profileDir '> NUL'
  120. say 'Done.'
  121.  
  122. /* now change language code */
  123. call charout, "Setting language..."
  124. profileFile = targetDir"\profile.shl"
  125. if (stream(profileFile , "c", "QUERY EXIST" ) <> "") then do
  126.     profileLength = chars(profileFile)
  127.     call stream profileFile, "c", "OPEN READ"
  128.     profileC = CharIn(profileFile, 1, profileLength )
  129.     call stream profileFile, "c", "CLOSE"
  130.     "if exist" targetDir"\profile.001 del" targetDir"\profile.001"
  131.     "ren" profileFile "profile.001"
  132.     profileC = strReplace(profileC, "'SET HELP.COUNTRY=001'", "'SET HELP.COUNTRY="lang"'")
  133.     call stream profileFile, "c", "OPEN WRITE"
  134.     call charout profileFile, profileC
  135.     call stream profileFile, "c", "CLOSE"
  136. end
  137. say "Done."
  138.  
  139. parse version thisVersion .
  140. if (thisVersion = "OBJREXX") then do
  141.     callxhelpStr "compileQuery"
  142.     if (yesno() = "Y") then do
  143.         Say "Compiling. Please wait..."
  144.         "ren" targetDir||"\cmdshl.cmd cmdshl.rex"
  145.         "ren" targetDir||"\xdir.cmd xdir.rex"
  146.         "rexxc" targetDir||"\cmdshl.rex" targetDir||"\cmdshl.cmd"
  147.         "rexxc" targetDir||"\xdir.rex" targetDir||"\xdir.cmd"
  148.     end
  149. end
  150.  
  151. callxhelpStr "WPSQuery"
  152. if (yesno() = "N") then signal nowps
  153.  
  154. if SysCreateObject("WPFolder", 'MLRXSHL / CommandPak', '<WP_DESKTOP>', 'OBJECTID=<CMDPAK_FOLDER>;ICONFILE='curdir'\fld.ico;ICONNFILE=1,'curdir'\fld1.ico', "REPLACE") then
  155.     Say "Folder successfully created."
  156. else
  157.     Say "Folder creation failed! Something's gone wrong."
  158.  
  159. if SysCreateObject("WPProgram", 'CmdShl', '<CMDPAK_FOLDER>', 'OBJECTID=<CMDPAK_CMDSHL>;EXENAME='||targetdir||'\cmdshl.cmd;', "REPLACE") then
  160.     Say "CmdShl object successfully created."
  161. else
  162.     Say "CmdShl object creation failed! Something's gone wrong."
  163.  
  164. if SysCreateObject("WPProgram", 'MLRXSHL / CommandPak Reference', '<CMDPAK_FOLDER>', 'OBJECTID=<CMDPAK_REFERENCE>;PARAMETERS='||infDir||'\cmdpak0.inf+'||infDir||'\mlrxshl.inf+'||infDir||'\cmdpak.inf;EXENAME=view.exe;', "REPLACE") then
  165.     Say "Reference object successfully created."
  166. else
  167.     Say "Reference object object creation failed! Something's gone wrong."
  168.  
  169. if SysCreateObject("WPProgram", 'WatchDrive', '<CMDPAK_FOLDER>', 'OBJECTID=<CMDPAK_WATCHDRV>;EXENAME='||targetdir||'\watchdrv.cmd;', "REPLACE") then do
  170.     Say "WatchDrive object successfully created."
  171. end
  172. else
  173.     Say "WatchDrive object creation failed! Something's gone wrong."
  174.  
  175. if SysCreateObject("WPProgram", 'Read me!', '<CMDPAK_FOLDER>', 'OBJECTID=<CMDPAK_README>;PARAMETERS='||targetDir||'\readme.1st;EXENAME=e.exe;', "REPLACE") then
  176.     Say "Readme object successfully created."
  177. else
  178.     Say "Readme object object creation failed! Something's gone wrong."
  179.  
  180. callxhelpStr "pauseMsg"
  181. call pause
  182.  
  183. nowps:
  184. BootDrive = GetBootDrive()
  185. callxhelpStr "configSysQuery"
  186. say "        SET COMSPEC="BootDrive"\OS2\CMD.EXE /C "targetDir"\cmdshl.cmd"
  187. say "        SET OS2_SHELL="BootDrive"\OS2\CMD.EXE /C "targetDir"\cmdshl.cmd"
  188. callxhelpStr "configSysQuery2"
  189. if (yesno() = "Y") then do
  190.     'start /f e.exe' BootDrive||'\CONFIG.SYS'
  191. end
  192.  
  193. callxhelpStr "doneMsg"
  194. call pause
  195. rc = SysSetObjectData("<CMDPAK_README>","OPEN=DEFAULT")
  196. exit
  197.  
  198. yesno:
  199. key = ''
  200. do until pos(key,"YN") > 0
  201.    key = translate(SysGetKey("NOECHO"))
  202. end /* do */
  203. Say key
  204. return translate(key)
  205.  
  206. halt:
  207. say '0d0a'x'Installation aborted!'
  208. exit
  209.  
  210. queryDir:
  211.     callxhelpStr "dirPauseMsg"
  212.     call pause
  213.  
  214.     callxhelpStr "foundDirsMsg"
  215.     say arg(2)":"
  216.  
  217.     path. = ""
  218.     path2 = arg(1)
  219.     i = 1
  220.     do while (path2 \= "")
  221.         parse var path2 path3 ";" path2
  222.         say format(i,4)||":" path3
  223.         path.i = path3
  224.         i=i+1
  225.     end
  226.     callxhelpStr "xAskMeMsg"
  227.     path.0 = i-1
  228.     callxhelpStr "enterNumberQuery"
  229.     repeat:
  230.     parse pull _dir
  231.     if \((_dir = "x") | ((_dir > 0) & (_dir <= path.0))) then do
  232.         callxhelpStr "invalidMsg"
  233.         signal repeat
  234.     end
  235.     if (_dir = "x") then do
  236.         callxhelpStr "enterFullQuery"
  237.         parse pull dir
  238.     end
  239.     else dir = path._dir
  240.     say dir
  241. return dir
  242.  
  243. GetBootDrive: procedure
  244.     parse upper value VALUE( "PATH",, "OS2ENVIRONMENT" ) with "\OS2\SYSTEM" -2 boot_drive +2
  245. return boot_drive
  246.  
  247. GetLibPath: procedure
  248.    bootDrive = GetBootDrive()
  249.    thisRC = 0
  250.    if bootDrive <> "" then do
  251.                      /* get the LIBPATH value                          */
  252.      configSys = left( bootDrive,1 ) || ":\CONFIG.SYS"
  253.      lineSeparator = "0D0A"x
  254.      libpathStmt = lineSeparator || "LIBPATH="
  255.  
  256.      if (stream( configSys, "c", "QUERY EXIST" ) <> "") then do
  257.        configSysLength = chars( configSys )
  258.        call stream configSys, "c", "OPEN READ"
  259.        configSYS_ = CharIn( configSys, 1, configSysLength )
  260.        call stream configSys, "c", "CLOSE"
  261.        parse upper var ConfigSYS_ . (libPathStmt) LIBPATH (lineSeparator) .
  262.        LIBPATH = strip( LIBPATH )
  263.      end
  264.      else
  265.        thisRC = -1
  266.     end
  267. return LIBPATH
  268.  
  269. checkdir:
  270.     if translate(directory(arg(1))) \= translate(arg(1)) then do
  271.         call charout ,"Creating target directory... "
  272.         'md' arg(1)
  273.         say "Done."
  274.     end
  275. return
  276.  
  277. searchPath:
  278.     leftPath = arg(1)
  279.     sFile = arg(2)
  280.     do while leftPath \= ""
  281.         parse var leftPath curpath ";" leftPath
  282.         if (stream(curpath"\"sFile,'c','query exists') \= "") & (curPath \= "") & (curPath \= ".") & (curPath \= directory()) then
  283.             return curpath"\"sFile
  284.     end
  285. return 0
  286.  
  287. filesExist:
  288.     rc = sysFileTree(arg(1), installFiles)
  289.     searchPath = arg(2)
  290.     curdir_ = directory()
  291.     do i = 1 to installFiles.0
  292.         parse var installFiles.i fdate ftime fsize fattr fname
  293.         fname = filespec('NAME', fname)
  294.         found = SearchPath(searchPath, fname)
  295.         if (found \= "") then do
  296.             fpath = filespec('D', found)||filespec('PATH', found)
  297.             if fpath = "" then leave
  298.             found2 = 0
  299.             do j = 1 to foundList.0
  300.                 if foundList.j = fpath then
  301.                     found2 = j
  302.             end
  303.             if (found2 = 0) then do
  304.                 k = foundList.0 + 1
  305.                 foundList.k = fpath
  306.                 foundList.k.0 = 1
  307.                 foundList.k.1 = fname
  308.                 foundList.0 = k
  309.             end
  310.             else do
  311.                 k2 = foundList.found2.0 + 1
  312.                 foundList.found2.0 = k2
  313.                 foundList.found2.k2 = fname
  314.             end
  315.         end
  316.     end
  317. return (foundList.0 > 0)
  318.  
  319. pause:  procedure
  320. key = ""
  321. do while (key = "")
  322.    key = SysGetKey("NOECHO")
  323. end /* do */
  324. say ""
  325. return
  326.  
  327. strReplace: procedure
  328.     /* syntax: result = strReplace(str, old, new) */
  329.     /* will replace a by b in oldstr */
  330.     parse arg str, old, new
  331.     p = pos(old, str)
  332.     if (p > 0) then
  333.         str = left(str, p-1)||new||substr(str,p+length(old))
  334. return str
  335.  
  336.