home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / PMQWK008.LZH / Install.Cmd < prev    next >
OS/2 REXX Batch file  |  1993-04-22  |  17KB  |  613 lines

  1. /* -----------------------------------------------------------------------
  2.  
  3. @echo off
  4. cls
  5. ECHO This INSTALL routine requires that you have OS/2 REXX support installed.
  6. ECHO You should run Selective Installation from the OS/2 Setup Folder to
  7. ECHO install REXX support before attempting to run this CMD file.
  8. PAUSE
  9. EXIT
  10.  
  11.    -----------------------------------------------------------------------
  12.  
  13.      SETUP.CMD -- Oberon Software PMQWK Install Procedure
  14.                   Copyright (c) 1993 by Oberon Software, Mankato, MN
  15.                   All rights reserved
  16.  
  17.    ----------------------------------------------------------------------- */
  18.  
  19. /* ----------------------------------------------------------------------- */
  20. '@echo off'
  21.  
  22. /* ----------------------------------------------------------------------- */
  23. /* Load REXXUTIL */
  24. call rxfuncadd sysloadfuncs, rexxutil, sysloadfuncs
  25. call sysloadfuncs
  26.  
  27. /* ----------------------------------------------------------------------- */
  28. /* "Global" variables */
  29.  
  30. CopyRLine0 = 'Oberon Software PMQWK Install Procedure'
  31. CopyRLine1 = 'Copyright (c) 1993 by Oberon Software, Mankato, MN'
  32. CopyRLine2 = 'All rights reserved'
  33.  
  34. SourcePath  = ''
  35. TargetPath  = 'C:\PMQWK'
  36. TargetPath2 = ''
  37. DLLPath     = ''
  38. RestorePath = ''
  39. AvailDrives = ''
  40. BootDrive   = ''
  41. LIBSubPath. = ''
  42. SpaceNeeded = 500000
  43. SpaceAvail  = 0
  44.  
  45. SourceFile.   = ''
  46. SourceFile.0  = 12
  47. SourceFile.1  = 'Coming.Up'    ; SourceFile.1.Shadow  = 1
  48. SourceFile.2  = 'Oberon.Ico'   ; SourceFile.2.FIcon   = 1
  49. SourceFile.3  = 'PmQWK.Doc'    ; SourceFile.3.Shadow  = 1
  50. SourceFile.4  = 'PmQWK.Exe'    ; SourceFile.4.Program = 1
  51. SourceFile.5  = 'PmQWK.Hlp'
  52. SourceFile.6  = 'Read.Me'      ; SourceFile.6.Shadow  = 1
  53. SourceFile.7  = 'RegExpUT.DLL' ; SourceFile.7.DLL     = 1
  54. SourceFile.8  = 'Setup.Cmd'    ; SourceFile.8.NoInst  = 1
  55. SourceFile.9  = 'Taglines.Txt' ; SourceFile.9.Careful = 1
  56. SourceFile.10 = 'Whats.New'    ; SourceFile.10.Shadow = 1
  57. SourceFile.11 = 'ZFront.Doc'   ; SourceFile.11.Shadow = 1
  58. SourceFile.12 = 'ZFront.Exe'
  59.  
  60.  
  61. AvailDrives = SysDriveMap('A:', 'USED')
  62. call Install
  63. call SysCls
  64. say ''
  65. say 'Oberon Software PMQWK Install Ended!'
  66. say ''
  67. say '  Oberon Software'
  68. say '  518 Blue Earth St.'
  69. say '  Mankato, MN 56001-2142'
  70. say '  1-507-388-7001'
  71. say ''
  72. Exit 0
  73.  
  74.  
  75. /* ----------------------------------------------------------------------- */
  76.  
  77. Install:
  78.   if BootDrive = '' then
  79.     do
  80.       call GetBootDrive
  81.       if result = 0 then return
  82.     end
  83.   if SourcePath = '' then
  84.     do
  85.       parse source . . argv0 .
  86.       temp = reverse(argv0)
  87.       temp = substr(temp, pos('\', temp))
  88.       if length(temp) > 3 then temp = substr(temp, 2)
  89.       SourcePath = reverse(temp)
  90.     end
  91.  
  92.   do forever
  93.     parse value SysDriveInfo(substr(TargetPath, 1, 2)) with dummy SpaceAvail dummy2
  94.     if DLLPath = '*Program Directory*' then
  95.       tempDLLPath = TargetPath
  96.     else
  97.       tempDLLPath = DLLPath
  98.     InstallDone = 0
  99.     call PutCopyright
  100.     say ''
  101.     say 'Select one of the following:'
  102.     say ''
  103.     say ''
  104.     say '       1. Select SOURCE Path      (Current is:' SourcePath')'
  105.     say '       2. Select TARGET Path      (Current is:' TargetPath')'
  106.     say '       3. Select DLL    Path      (Current is:' tempDLLPath')'
  107.     say '       4. Install PMQWK'
  108.     say '       0. Quit Install Procedure'
  109.     say ''
  110.     say ''
  111.     if SpaceAvail < SpaceNeeded then
  112.       say 'NOTE: Installation requires' SpaceNeeded 'bytes on target drive, only' SpaceAvail 'available!.'
  113.     call charout ,'Enter 0, 1, 2, 3, or 4: '
  114.     do forever
  115.       k = SysGetKey('NOECHO')
  116.       if k = '0' | k = '1' | k = '2' | k = '3' | k = '4' | k = D2C(27) then
  117.         do
  118.           if k = D2C(27) then k = '0'
  119.           say k
  120.           ProgAction = k
  121.           leave
  122.         end
  123.       else
  124.         call beep 1760, 50
  125.     end
  126.     select
  127.       when ProgAction = '0' then leave
  128.       when ProgAction = '1' then call AskPath 'SOURCE'
  129.       when ProgAction = '2' then call AskPath 'TARGET'
  130.       when ProgAction = '3' then call AskLIBPath
  131.       when ProgAction = '4' then call DoInstall
  132.     end
  133.     if InstallDone \= 0 then leave
  134.   end
  135.   return
  136.  
  137.  
  138. /* ----------------------------------------------------------------------- */
  139.  
  140. DoInstall:
  141.   call PutCopyright
  142.  
  143.   if SpaceAvail < SpaceNeeded then
  144.     do
  145.       say ''
  146.       say 'You do NOT have enough room on the target disk for all files!'
  147.       call GetYN 'Do you want to continue anyway?'
  148.       if result \= 1 then return
  149.       call PutCopyright
  150.     end
  151.  
  152.   pathOK = 1
  153.   cwd = directory()
  154.   testpath = directory(TargetPath)
  155.   call directory cwd
  156.   if translate(testpath) \= translate(TargetPath) then
  157.     do
  158.       say ''
  159.       say 'Target path "'TargetPath'" does not exist!'
  160.       call GetYN 'Create it?'
  161.       if result = '1' then
  162.         do
  163.           r = SysMkDir(TargetPath)
  164.           if r \= 0 then
  165.             do
  166.               say 'Cannot create directory "'TargetPath'"'
  167.               call charout ,'Press any key...'
  168.               call SysGetKey 'NOECHO'
  169.               pathOK = 0
  170.             end
  171.         end
  172.       else
  173.         pathOK = 0
  174.     end
  175.  
  176.   if pathOK = 0 then return
  177.  
  178.   tempSrc = SourcePath
  179.   n = length(tempSrc)
  180.   if substr(tempSrc, n, 1) \= '\' then tempSrc = tempSrc||'\'
  181.   tempDest = TargetPath
  182.   n = length(tempDest)
  183.   if substr(tempDest, n, 1) \= '\' then tempDest = tempDest||'\'
  184.   do i = 1 to SourceFile.0
  185.     if SourceFile.i.NoInst \= 1 then
  186.       do
  187.         if SourceFile.i.DLL = 1 & DLLPath \= '*Program Directory*' then
  188.           say 'Installing' tempSrc||SourceFile.i '-->' DLLPath
  189.         else
  190.           say 'Installing' tempSrc||SourceFile.i '-->' TargetPath
  191.         r = stream(tempSrc||SourceFile.i, 'C', 'query exists')
  192.         if r = '' then
  193.           do
  194.             call beep 1760, 50
  195.             say '  Cannot find' tempSrc||SourceFile.i'!!'
  196.             say '  File not installed.'
  197.             call charout ,'  Press any key...'
  198.             call SysGetKey 'NOECHO'
  199.             say ''
  200.           end
  201.         else
  202.           do
  203.             if SourceFile.i.Careful = 1 then
  204.               do
  205.                 r2 = stream(tempDest||SourceFile.i, 'C', 'query exists')
  206.                 if r2 \= '' then
  207.                   do
  208.                     call beep 1760, 50
  209.                     say '  File:' tempDest||SourceFile.i 'exists and may contain user data!'
  210.                     call charout ,'  Select: (1) Skip file, (2) Overwrite file: '
  211.                     do forever
  212.                       k = SysGetKey('NOECHO')
  213.                       if k = '1' | k = '2' then
  214.                         leave
  215.                       else
  216.                         call beep 1760, 50
  217.                     end
  218.                     say k
  219.                   end
  220.                 else
  221.                   k = '2'
  222.                 if k = '2' then 'copy' tempSrc||SourceFile.i TargetPath '>nul'
  223.               end
  224.             else
  225.               do
  226.                 if SourceFile.i.DLL = 1 & DLLPath \= '*Program Directory*' then
  227.                   'copy' tempSrc||SourceFile.i DLLPath '>nul'
  228.                 else
  229.                   'copy' tempSrc||SourceFile.i TargetPath '>nul'
  230.               end
  231.           end
  232.       end
  233.   end
  234.  
  235.   call PutCopyright
  236.   say '    Installation of files is complete!'
  237.   say ''
  238.   say ''
  239.   say 'If you wish, Install can create a desktop folder containing PMQWK'
  240.   say 'program and information objects for you.'
  241.   say ''
  242.   call GetYN 'Do you want a desktop folder installed?'
  243.   if result = 1 then call CreateFolder
  244.  
  245.   call PutCopyright
  246.   say '    Installation of files is complete!'
  247.   say ''
  248.   say ''
  249.   call charout ,'Press any key...'
  250.   call SysGetKey 'NOECHO'
  251.  
  252.   InstallDone = 1
  253.   return
  254.  
  255.  
  256. /* ----------------------------------------------------------------------- */
  257.  
  258. CreateFolder:
  259.   call PutCopyright
  260.  
  261.   hadError = 0
  262.   iconFile = ''
  263.   do i = 1 to SourceFile.0
  264.     if SourceFile.i.FIcon = 1 then
  265.       do
  266.         iconFile = SourceFile.i
  267.         leave
  268.       end
  269.   end
  270.  
  271.   classname='WPFolder'
  272.   title='Oberon Software'
  273.   location='<WP_DESKTOP>'
  274.   if iconFile = '' then
  275.     do
  276.       setup='OBJECTID=<OBERON_FOLDER>;'||,
  277.             'ICONPOS=25,75;'||,
  278.             'OPEN=ICON;'
  279.     end
  280.   else
  281.     do
  282.       setup='OBJECTID=<OBERON_FOLDER>;'||,
  283.             'ICONFILE='tempDest||iconFile';'||,
  284.             'ICONPOS=25,75;'||,
  285.             'OPEN=ICON;'
  286.     end
  287.   option='F'
  288.   call BldObj
  289.  
  290.   do i = 1 to SourceFile.0
  291.     if SourceFile.i.Program = 1 then
  292.       do
  293.         classname='WPProgram'
  294.         title='PmQWK! 1.00ß-8'
  295.         location='<OBERON_FOLDER>'
  296.         setup='OBJECTID=<OBERON_PMQWK>;'||,
  297.               'EXENAME='tempDest||SourceFile.i';'||,
  298.               'STARTUPDIR='TargetPath';'||,
  299.               'PROGTYPE=PM;'
  300.         option='U'
  301.         call BldObj
  302.         leave
  303.       end
  304.   end
  305.  
  306.   do i = 1 to SourceFile.0
  307.     if SourceFile.i.Shadow = 1 then
  308.       do
  309.         classname='WPShadow'
  310.         title=SourceFile.i
  311.         location='<OBERON_FOLDER>'
  312.         setup='SHADOWID='||tempDest||SourceFile.i';'
  313.         option='U'
  314.         call BldObj
  315.       end
  316.   end
  317.  
  318.   if hadError = 1 then
  319.     do
  320.       call charout ,'Press any key...'
  321.       call SysGetKey 'NOECHO'
  322.     end
  323.   return
  324.  
  325.  
  326.  
  327.  
  328. BldObj:
  329.   call charout ,'    Building:' title '... '
  330.   r = SysCreateObject(classname, title, location, setup, option)
  331.   if r = 1 then
  332.     say 'Object created!'
  333.   else
  334.     do
  335.       if r = 0 then
  336.         say 'Not created!  Already exists.'
  337.       else
  338.         do
  339.           say 'Not created!  Return code='r
  340.           hadError = 1
  341.         end
  342.     end
  343.   return
  344.  
  345.  
  346. /* ----------------------------------------------------------------------- */
  347.  
  348. PutCopyright:
  349.   call SysCls
  350.   say CopyRLine0
  351.   say CopyRLine1
  352.   say CopyRLine2
  353.   say ''
  354.   say ''
  355.   return
  356.  
  357. /* ----------------------------------------------------------------------- */
  358.  
  359. GetBootDrive:
  360.   gbdRC = -1
  361.   do while gbdRC = -1
  362.     call PutCopyright
  363.     say '    Please enter the drive letter for your boot drive.'
  364.     call charout ,'    Press the letter for the drive or ESC to quit: '
  365.     do forever
  366.       k = translate(SysGetKey('NOECHO'))
  367.       if k = D2C(27) then
  368.         do
  369.           gbdRC = 0
  370.           leave
  371.         end
  372.       else
  373.         do
  374.           if k = D2C(13) then k = 'C'
  375.           k = k||':'
  376.           if pos(k, AvailDrives) = 0 then
  377.             call beep 1760, 50
  378.           else
  379.             do
  380.               call SysFileTree k||'\Config.Sys', 'foo', 'F'
  381.               if foo.0 = 0 then
  382.                 do
  383.                   say ''
  384.                   say 'Cannot locate file "'k'\Config.Sys"'
  385.                   call charout ,'Press any key...'
  386.                   call SysGetKey 'NOECHO'
  387.                   leave
  388.                 end
  389.               else
  390.                 do
  391.                   BootDrive = k
  392.                   call GetLIBPath
  393.                   gbdRC = 1
  394.                   leave
  395.                 end
  396.             end
  397.         end
  398.     end
  399.   end
  400.   return gbdRC
  401.  
  402. /* ----------------------------------------------------------------------- */
  403.  
  404. GetLIBPATH:
  405.   srchRC = SysFileSearch('LIBPATH=', BootDrive||'\Config.Sys', 'lpath')
  406.   if srchRC = 0 then
  407.     do i = 1 to lpath.0
  408.       if translate(substr(lpath.i, 1, 8)) = 'LIBPATH=' then
  409.         do
  410.           j = 0
  411.           temp = substr(lpath.i, 9)
  412.           do while length(temp) > 0
  413.             parse var temp tpath ';' temp
  414.             j = j + 1
  415.             if tpath = '.' then
  416.               do
  417.                 LIBSubPath.j = '*Program Directory*'
  418.                 DLLPath = LIBSubPath.j
  419.               end
  420.             else
  421.               LIBSubPath.j = tpath
  422.           end
  423.           LIBSubPath.0 = j
  424.           if DLLPath = '' then DLLPath = LIBSubPath.1
  425.         end
  426.     end
  427.   return
  428.  
  429.  
  430. AskLIBPath:
  431.   if LIBSubPath.0 > 0 then
  432.     do
  433.       j = 0
  434.       i = 0
  435.       lpSelect = 0
  436.       topval   = 1
  437.       call PutCopyright
  438.       say "    Please select a path for PMQWK's associated DLL file to be placed"
  439.       say '    from the following list of paths in your LIBPATH:'
  440.       say ''
  441.       do forever
  442.         i = i + 1
  443.         j = j + 1
  444.         say '    ' D2C(j+64)':' LIBSubPath.i
  445.         if j = 10 | i = LIBSubPath.0 then
  446.           do
  447.             topkey = D2C(j+C2D('A')-1)
  448.             say ''
  449.             call charout ,' -- A-'topkey'=Select, R=restart, Q (or ESC)=exit, any other key=more --'
  450.             k = C2D(translate(SysGetKey('NOECHO')))
  451.             if k = 27 then k = C2D('Q')
  452.             if k = C2D('Q') then leave
  453.             if k = C2D('R') then
  454.               do
  455.                 i = 0
  456.                 j = 0
  457.                 topval = 1
  458.               end
  459.             else
  460.               do
  461.                 topkey = j+C2D('A')
  462.                 if k > C2D('@') & k < topkey then
  463.                   do
  464.                     lpSelect = topval + (k - C2D('A'))
  465.                     DLLPath = LIBSubPath.lpSelect
  466.                     leave
  467.                   end
  468.                 j = 0
  469.                 if i = LIBSubPath.0 then i = 0
  470.                 topval = i + 1
  471.                 call PutCopyright
  472.                 say "    Please select a path for PMQWK's associated DLL file to be placed"
  473.                 say '    from the following list of paths in your LIBPATH:'
  474.                 say ''
  475.               end
  476.           end
  477.       end
  478.     end
  479.   return
  480.  
  481.  
  482. /* ----------------------------------------------------------------------- */
  483.  
  484. AskPath:
  485. parse arg apType
  486.   cwd = directory()
  487.   do forever
  488.     call SysCls
  489.     say 'Select' apType 'Path'
  490.     say ''
  491.     say 'Current setting is:'
  492.     if apType = 'SOURCE' then
  493.       say '    ' SourcePath
  494.     else
  495.       say '    ' TargetPath
  496.     say ''
  497.     call charout ,'Enter new setting (press ENTER to leave unchanged): '
  498.     np = linein('stdin')
  499.     np = strip(np, 'B')
  500.     if length(np) = 0 then
  501.       leave
  502.     else
  503.       do
  504.         if substr(np, length(np), 1) = '\' then
  505.           do
  506.             if (np = '\') | (length(np) = 3 & substr(np, 2, 1) = ':') then
  507.               nop
  508.             else
  509.               np = substr(np, 1, length(np) - 1)
  510.           end
  511.         if np = '..' & length(cwd) > 3 then
  512.           do
  513.             temp = reverse(cwd)
  514.             temp = substr(temp, pos('\', temp)+1)
  515.             np = reverse(temp)
  516.           end
  517.         if np = '.' then np = cwd
  518.         if substr(np, 2, 1) \= ':' then
  519.           do
  520.             if substr(np, 1, 1) = '\' then
  521.               np = substr(cwd, 1, 2) || np
  522.             else
  523.               np = cwd || '\' || np
  524.           end
  525.         if pos(translate(substr(np, 1, 2)), AvailDrives) = 0 then
  526.           do
  527.             call beep 1760, 50
  528.             say ''
  529.             say 'Invalid drive letter "'substr(np, 1, 2)'"'
  530.             call charout ,'Press any key...'
  531.             call SysGetKey 'NOECHO'
  532.           end
  533.         else
  534.           do
  535.             testnp = directory(np)
  536.             if translate(testnp) = translate(np) then
  537.               do
  538.                 call directory cwd
  539.                 if apType = 'SOURCE' then
  540.                   SourcePath = testnp
  541.                 else
  542.                   TargetPath = testnp
  543.                 leave
  544.               end
  545.             else
  546.               do
  547.                 call beep 1760, 50
  548.                 say ''
  549.                 say 'Directory path "'np'" does not exist!'
  550.                 if apType = 'SOURCE' then
  551.                   do
  552.                     call charout ,'Press any key...'
  553.                     call SysGetKey 'NOECHO'
  554.                   end
  555.                 else
  556.                   do
  557.                     call GetYN 'Create it?'
  558.                     if result = '1' then
  559.                       do
  560.                         r = SysMkDir(np)
  561.                         if r = 0 then
  562.                           do
  563.                             testnp = directory(np)
  564.                             call directory cwd
  565.                             if apType = 'SOURCE' then
  566.                               SourcePath = testnp
  567.                             else
  568.                               TargetPath = testnp
  569.                             leave
  570.                           end
  571.                         else
  572.                           do
  573.                             say 'Cannot create directory "'np'"'
  574.                             call charout, 'Press any key...'
  575.                             call SysGetKey 'NOECHO'
  576.                           end
  577.                       end
  578.                   end
  579.               end
  580.           end
  581.       end
  582.   end
  583.   return
  584.  
  585.  
  586. /* ----------------------------------------------------------------------- */
  587.  
  588. GetYN: procedure
  589. parse arg gynPrompt
  590.   call charout ,gynPrompt '(y/N) '
  591.   do forever
  592.     k = translate(SysGetKey('NOECHO'))
  593.     if k = D2C(27) | k = D2C(13) then k = 'N'
  594.     select
  595.       when k = 'Y' then
  596.         do
  597.           ynRC = 1
  598.           leave
  599.         end
  600.       when k = 'N' then
  601.         do
  602.           ynRC = 0
  603.           leave
  604.         end
  605.       otherwise
  606.         call beep 1760, 50
  607.     end
  608.   end
  609.   return ynRC
  610.  
  611. /* ----------------------------------------------------------------------- */
  612.  
  613.