home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mod201j.zip / setup-gr.cmd < prev    next >
OS/2 REXX Batch file  |  1996-03-29  |  12KB  |  422 lines

  1. /* Modula-2 installation für OS/2 2.x or 3.x */
  2. /* trace all */
  3.  
  4. /* functions loaded from RexxUtil */
  5. call RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
  6. call RxFuncAdd 'SysDriveInfo', 'RexxUtil', 'SysDriveInfo'
  7. call RxFuncAdd 'SysMkDir', 'RexxUtil', 'SysMkDir'
  8. call RxFuncAdd 'SysDestroyObject', 'RexxUtil', 'SysDestroyObject'
  9. call RxFuncAdd 'SysGetMessage', 'RexxUtil', 'SysGetMessage'
  10. call RxFuncAdd 'SysFileSearch', 'RexxUtil', 'SysFileSearch'
  11.  
  12. /* display introducing message */
  13. "echo off"
  14. say
  15. say "Modula-2 Setup für OS/2  (c) 1996 Mill Hill & Canterbury Group"
  16. say "--------------------------------------------------------------"
  17. say
  18.  
  19. /* get default source path, usually A:\ */
  20. parse upper source origin origin origin
  21. origin = filespec( "drive", origin ) || filespec( "path", origin )
  22. origin = delstr( origin, length( origin ) )
  23. if (datatype( substr( origin, 1, 1 ) ) \= 'CHAR') then do
  24.   origin = 'A:\'
  25. end
  26. else if (substr( origin, 2, 1 ) \= ':') then do
  27.   origin = 'A:\'
  28. end
  29. else if (substr( origin, 3, 1 ) = '') then do
  30.   origin = origin || '\'
  31. end
  32. else if (substr( origin, 3, 1 ) \= '\') then do
  33.   origin = 'A:\'
  34. end
  35.  
  36.  
  37. /* let the user confirm or modify source path */
  38. do forever
  39.   default = origin
  40.   do forever
  41.     say 'Installieren von Herkunft "' || origin || '" ? (J=ok N=sonstig)'
  42.     pull answer
  43.     if answer \= "J" then do
  44.       if answer \= "N" then do
  45.         iterate
  46.       end
  47.     end
  48.     leave
  49.   end
  50.   if answer \= 'J' then do
  51.     do forever
  52.       origin = default
  53.       say 'Bitte vollständig eine andere Herkunft eintippen: "Laufwerk:\Pfad"'
  54.       pull drivepath
  55.       if datatype( substr( drivepath,1,1 ) ) = 'CHAR' then do
  56.         if substr( drivepath, 2, 1 ) = ':' then do
  57.           if substr( drivepath, 3, 1 ) = '\' then do
  58.             if length( drivepath ) > 3 then do
  59.               if right( drivepath, 1 ) \= '\' then do
  60.                 origin = drivepath
  61.                 leave
  62.               end
  63.             end
  64.           end
  65.           if substr( drivepath, 3, 1 ) = '' then do
  66.             origin = drivepath
  67.             leave
  68.           end
  69.         end
  70.       end
  71.       say "Laufwerk und/oder Pfad für Herkunft ist ungültig oder unvollständig"
  72.     end
  73.   end
  74.   rc = SysFileTree( origin, origin_filetree, 'D' )
  75.   if rc = 0 then do
  76.     if origin_filetree.0 > 0 then do
  77.       leave
  78.     end
  79.     if substr( origin, 2, 2 ) = ':\' then do
  80.       if substr( origin, 4, 1 ) = '' then do
  81.         /* installing from a main directory */
  82.         leave
  83.        end
  84.     end
  85.   end
  86.   say 'Herkunft nicht ansprechbar: "' || origin || '"'
  87. end
  88. origindrive = substr( origin, 1, 2 )
  89. say
  90. say 'Modula-2 wird von folgender Herkunft installiert: "' || origin || '"'
  91. say
  92.  
  93.  
  94. /* get default target path from OS/2 drive, e.g. C:\MOD32 */
  95. dest = value( 'system_ini',,'os2environment' )
  96. dest = substr( dest, 1, 2 )
  97. os2drive = dest
  98. dest = os2drive || "\MOD32"
  99. default = dest
  100.  
  101.  
  102. /* let the user confirm or change the default target */
  103. querydest:
  104. do forever
  105.   dest = default
  106.   do forever
  107.     say 'Installieren auf das Ziel "' || dest || '" ? (J=ok N=woanders)'
  108.     pull answer
  109.     if answer \= "J" then do
  110.       if answer \= "N" then do
  111.         iterate
  112.       end
  113.     end
  114.     leave
  115.   end
  116.   if answer \= 'J' then do
  117.     do forever
  118.       dest = default
  119.       say 'Bitte eine vollständige Zielangabe eintippen: "Laufwerk:\Pfad"'
  120.       pull drivepath
  121.       if drivepath = '' then do
  122.         leave
  123.       end
  124.       if datatype( substr( drivepath,1,1 ) ) = 'CHAR' then do
  125.         if substr( drivepath, 2, 1 ) = ':' then do
  126.           if substr( drivepath, 3, 1 ) = '\' then do
  127.             if length( drivepath ) > 3 then do
  128.               if right( drivepath, 1 ) \= '\' then do
  129.                 dest = drivepath
  130.                 leave
  131.               end
  132.             end
  133.           end
  134.         end
  135.       end
  136.       say "Laufwerk und/oder Pfad für Zielangabe ist verkehrt oder unvollständig"
  137.     end
  138.   end
  139.   if dest = '' then do
  140.     iterate
  141.   end
  142.   overwrite = 0
  143.   rc = SysFileTree( dest, dest_filetree, 'D' )
  144.   if rc = 0 then do
  145.     if dest_filetree.0 > 0 then do
  146.       do forever
  147.         say
  148.         say '"' || dest || '" existiert schon, überschreiben? (J/N)'
  149.         pull answer
  150.         if answer \= "J" then do
  151.           if answer \= "N" then do
  152.             iterate
  153.           end
  154.         end
  155.         leave
  156.       end
  157.       if answer = 'J' then do
  158.         overwrite = 1
  159.         leave
  160.       end
  161.       iterate
  162.     end
  163.     leave
  164.   end
  165.   say 'Ziel nicht zugreifbar: "' || dest || '"'
  166. end
  167. destdrive = substr( dest, 1, 2 )
  168. say
  169. say 'Modula-2 wird installiert nach: "' || dest || '"'
  170. say
  171.  
  172.  
  173. /* delete old destination path if there and if not needed */
  174. if overwrite = 1 then do
  175.   if filespec( "name", dest ) \= '' then do
  176.     i = 3;
  177.     do forever
  178.       j = pos( '\', dest, i+1 )
  179.       if j == 0 then do
  180.         j = length( dest )
  181.         destpath = substr( dest, i+1, j-i )
  182.         leave
  183.       end
  184.       i = j
  185.     end
  186.     do forever
  187.       say 'Soll bisheriges "' || destpath || '" vorher gelöscht werden? (J/N)'
  188.       pull answer
  189.       if answer \= "J" then do
  190.         if answer \= "N" then do
  191.           iterate
  192.         end
  193.       end
  194.       leave
  195.     end
  196.     if answer = 'J' then do
  197.       say
  198.       say 'Lösche altes "' || destpath || '"'
  199.       say
  200.       chdir filespec( "drive", dest ) || '\'
  201.       rc = SysDestroyObject( dest )
  202.       if rc \= 1 then do
  203.         say 'Bisheriges Zielverzeichnis "' || destpath || '" kann nicht gelöscht werden'
  204.         exit
  205.       end
  206.       overwrite = 0
  207.     end
  208.   end
  209. end
  210.  
  211. /* check disk space before installation */
  212. driveinfo = SysDriveInfo( destdrive )
  213. parse upper var driveinfo    drive free total label
  214. if free < 3000000 then do
  215.   say 'Ziel-Laufwerk "' || destdrive || '" hat nicht ausreichend Platz'
  216.   signal querydest
  217. end
  218.  
  219.  
  220. /* create destination directories if new */
  221. if overwrite = 0 then do
  222.   say
  223.   say 'Erzeuge Zielverzeichnis(se) "' || dest || '"'
  224.   say
  225.   i = 3
  226.   if right( dest, 1 ) \= '\' then do
  227.     dest = dest || '\'
  228.   end
  229.   do forever
  230.     i = pos( "\", dest, i+1 )
  231.     if (i == 0) then do
  232.       leave
  233.     end
  234.     destpath = substr( dest, 1, i-1 )
  235.     if (SysFileTree( destpath, dest_filetree, 'D' ) == 0) then do
  236.       if dest_filetree.0 > 0 then do
  237.         iterate
  238.       end
  239.     end
  240.     rc = SysMkDir( destpath )
  241.     if rc \= 0 then do
  242.       destcreated = 0
  243.       leave
  244.     end
  245.     destcreated = 1
  246.   end
  247.   if destcreated == 0 then do
  248.     say 'Zielverzeichnis "' || destpath || '" kann nicht erzeugt werden'
  249.     say SysGetMessage( rc )
  250.     exit
  251.   end
  252.   if right( dest, 1 ) == '\' then do
  253.     if right( dest, 2 ) \= ':\' then do
  254.       dest = substr( dest, 1, length( dest )-1 )
  255.     end
  256.   end
  257. end
  258.  
  259.  
  260.  
  261. /* now do the installation */
  262. say
  263. say 'Extrahiere Modula-2-Archiv nach "' || dest || '"'
  264. say
  265. chdir origin
  266. chdir dest
  267. destdrive
  268. if overwrite = 1 then do
  269.   if right( origin, 1 ) \= '\' then do
  270.     origin || '\' || "modula2.exe -fo"
  271.     origin || '\' || "modula2.exe -un"
  272.   end
  273.   else do
  274.     origin || "modula2.exe -fo"
  275.     origin || "modula2.exe -un"
  276.   end
  277. end
  278. else do
  279.   if right( origin, 1 ) \= '\' then do
  280.     origin || '\' || "modula2.exe"
  281.   end
  282.   else do
  283.     origin || "modula2.exe"
  284.   end
  285. end
  286. os2obj = dest || "\os2obj"
  287. os2obj_exist = 0
  288. rc = SysFileTree( os2obj, os2obj_filetree, 'D' )
  289. if rc = 0 then do
  290.   if os2obj_filetree.0 > 0 then do
  291.     os2obj_exist = 1
  292.   end
  293. end
  294. if os2obj_exist = 0 then do
  295.   mkdir os2obj
  296. end
  297.  
  298. /* now create a command file for Modula-2 environment */
  299. say
  300. say 'Erzeuge "' || dest || '\OS2BIN\MODENV.CMD" für Modula-2-Umgebung'
  301. say
  302. mod_src = ".;"    || dest || "\OS2MOD;"
  303. mod_src = mod_src || dest || "\OS2API;"
  304. mod_src = mod_src || dest || "\OS2SRC;"
  305. mod_src = mod_src || dest || "\OS2DEMO\OOPS;"
  306. mod_src = mod_src || dest || "\OS2DEMO\HELLO;"
  307. mod_src = mod_src || dest || "\OS2DEMO\ANIMALS;"
  308. mod_tmp = dest
  309. lib = value( 'LIB',,'OS2ENVIRONMENT' )
  310. mod_lib = ""
  311. if pos( ".", lib ) = 0 then do
  312.   mod_lib = ".;"
  313. end
  314. mod_lib = mod_lib || dest || "\OS2LIB;" || lib
  315. ;dpath = value( 'DPATH',,'OS2ENVIRONMENT' )
  316. ;mod_obj_flat32 = dest || "\OS2OBJ;" || dpath
  317. mod_obj_flat32 = dest || "\OS2OBJ;"
  318. mod_obj_small = ".;"
  319. mod_obj_medium = ".;"
  320. mod_obj_compact = ".;"
  321. mod_obj_large = ".;"
  322. path = value( 'PATH',,'OS2ENVIRONMENT' )
  323. if pos( dest || "\OS2BIN;", path ) = 0 then do
  324.   path = dest || "\OS2BIN;" || path
  325. end
  326. tmp = value( 'TMP',,'OS2ENVIRONMENT' )
  327. if tmp = "" then do
  328.   tmp = mod_tmp
  329. end
  330. modenv = dest || "\OS2BIN\MODENV.CMD"
  331. "ECHO REM --- Modula-2 settings --- "           || ">"  || modenv
  332. "ECHO SET MOD_SRC="         || mod_src          || ">>" || modenv
  333. "ECHO SET MOD_TMP="         || mod_tmp          || ">>" || modenv
  334. "ECHO SET MOD_LIB="         || mod_lib          || ">>" || modenv
  335. "ECHO SET MOD_OBJ_FLAT32="  || mod_obj_flat32   || ">>" || modenv
  336. "ECHO SET MOD_OBJ_SMALL="   || mod_obj_small    || ">>" || modenv
  337. "ECHO SET MOD_OBJ_MEDIUM="  || mod_obj_medium   || ">>" || modenv
  338. "ECHO SET MOD_OBJ_COMPACT=" || mod_obj_compact  || ">>" || modenv
  339. "ECHO SET MOD_OBJ_LARGE="   || mod_obj_large    || ">>" || modenv
  340. "ECHO SET PATH="            || path             || ">>" || modenv
  341. "ECHO SET TMP="             || tmp              || ">>" || modenv
  342.  
  343.  
  344. /* update CONFIG.SYS if requested */
  345. configsys = os2drive || "\CONFIG.SYS"
  346. do forever
  347.   say '"' || modenv || '" in die "' || configsys || '" einfügen ? (J/N)'
  348.   pull answer
  349.   if answer \= "J" then do
  350.     if answer \= "N" then do
  351.       iterate
  352.     end
  353.   end
  354.   leave
  355. end
  356. configos2 = dest || "\OS2BIN\CONFIG.OS2"
  357. if answer = "J" then do
  358.   call SysFileSearch ' MOD_', configsys, 'setfile.'
  359.   if setfile.0 > 0 then do
  360.     say 'Möglicherweise existiert schon eine andere Modula-2-Umgebung'
  361.     do forever
  362.       say 'Trotzdem "' || modenv || '" in die "' || configsys || '" einfügen ? (J/N)'
  363.       pull answer
  364.       if answer \= "J" then do
  365.         if answer \= "N" then do
  366.           iterate
  367.         end
  368.       end
  369.       leave
  370.     end
  371.   end
  372.   if answer = "N" then do
  373.     modenvold = dest || "\OS2BIN\MODENV.OLD"
  374.     say 'Schreibe alte Angaben der Umgebung in "' || modenvold || '"'
  375.     "ECHO REM --- Vermutlich alte Modula-2-Angaben aus CONFIG.SYS --- >" || modenvold
  376.     if setfile.0 > 0 then do
  377.       do i = 1 to setfile.0
  378.         "ECHO " || setfile.i || " >>" || modenvold
  379.       end
  380.     end
  381.     say
  382.   end
  383. end
  384. configsys_changed = answer
  385. if answer = "J" then do
  386.   say '"Füge jetzt "' || modenv || '" in die "' || configsys || '" ein'
  387.   "COPY " || configsys || " " || configos2
  388.   "COPY " || configos2 || "/A + " || modenv || " /A  " || configsys
  389. end
  390. else do
  391.   say 'Ihre "' || configsys || '" wird nicht verändert'
  392. end
  393.  
  394.  
  395. /* Create a command file for restoring the OS/2 environment */
  396. os2env = dest || "\OS2BIN\OS2ENV.CMD"
  397. say
  398. say 'Erzeuge eine Kommando-Datei "' || os2env || '"'
  399. say
  400. destdrive
  401. chdir dest || "\OS2BIN"
  402. "SAVEENV OS2ENV.CMD"
  403.  
  404.  
  405. /* Installation done */
  406. say
  407. say 'Installation ist jetzt fertig.'
  408. if configsys_changed = 'J' then do
  409.   say 'Sie sollten den Rechner neu starten wegen Ihrer geänderten "CONFIG.SYS".'
  410. end
  411. else do
  412.   say 'Ihre "' || configsys || '" ist nicht geändert worden.'
  413.   say 'Sie sollten jedoch "' || modenv || '" immer dann starten,'
  414.   say '  wenn Modula-2 zur Anwendung kommt.'
  415. end
  416. say 'Sie können jederzeit die ursprüngliche OS/2-Umgebung wiederherstellen,'
  417. say '  indem Sie einfach "' || os2env '" aufrufen.'
  418. say
  419. say '-------------------------------------------------------------------'
  420.  
  421. exit
  422.