home *** CD-ROM | disk | FTP | other *** search
/ IBM Aptiva Multimeda Exploration / BPCDROM.ISO / la / install.cmd < prev    next >
OS/2 REXX Batch file  |  1994-10-06  |  6KB  |  257 lines

  1. /* **********************************************************************
  2. *  *               Copyright (c) IBM Corporation, 1994                  *
  3. *  *                       All Rights Reserved                          *
  4. *  **********************************************************************
  5. *
  6. *             IBM OS/2 Bonus Pak Installation Utility Setup
  7. */
  8.  
  9.    /* Initalize Environment:
  10.    *  This command file attempts to improve application load time by
  11.    *  unpacking application files (EXE & DLL) to harddrive. DLL load time
  12.    *  from removable media is about 45secs slower loadtime from hardrive.
  13.    *
  14.    *  To avoid NLV translation requirements, all errors are filtered
  15.    *  and defered to the OSO0001.MSG file for appropriate translated text.
  16.    */
  17.    '@echo off'
  18.    trace off
  19.  
  20.    /* Parse Call Path Info
  21.    */
  22.    Parse Source . . callPath
  23.  
  24.    /* Load in function library
  25.    */
  26.    Call RxFuncAdd "SysLoadFuncs","RexxUtil","SysLoadFuncs"
  27.    Call SysLoadFuncs
  28.  
  29.    /* Strip program name
  30.    */
  31.    rcp = REVERSE(callPath)
  32.    callPathDir = REVERSE(substr(rcp,POS("\",rcp)+1))
  33.  
  34.    /* Create Queue to catch system error messages
  35.    */
  36.    rcode = RXQUEUE('delete', errq)
  37.    errq = RXQUEUE('create')
  38.    new = RXQUEUE('set', errq)
  39.  
  40.    /* Define stem of files to be copied
  41.    */
  42.    MaxCopyIndex = 6
  43.    Files. = ""
  44.    Files.0 = MaxCopyIndex
  45.    Files.1 = "BPIU.@"
  46.    Files.2 = "INFOHWAY.CMD"
  47.    Files.3 = "INFOHWY1.ICO"
  48.    Files.4 = "INFOHWY2.ICO"
  49.    Files.5 = "INET1.ICO"
  50.    Files.6 = "INET2.ICO"
  51.  
  52.    /* Determine bootdrive
  53.    */
  54.    CurDir = DIRECTORY()
  55.    SrcDir = callPathDir
  56.    if (SubStr(SrcDir,Length(SrcDir),1) \= "\") then
  57.      SrcDir = SrcDir||"\"
  58.    BootDrive = GetBootDrive()
  59.    if (BootDrive == "") then
  60.      do
  61.       /* ;OS2 is a required somewhere in the path directory!
  62.       */
  63.       'helpmsg SYS0010 | RXQUEUE 'errq
  64.        call DumpErrMsg
  65.        call Done
  66.      end
  67.    InsPath = TRANSLATE(BootDrive||"\OS2\INSTALL")
  68.  
  69.    /* Determine Multimedia Status
  70.    */
  71.    fMMInstalled = value("MMBASE",,"OS2ENVIRONMENT")
  72.    MMLen = LENGTH(fMMInstalled)
  73.    if (MMLen > 0) then
  74.      if (Substr(fMMInstalled,MMLen,1) == ";") then
  75.        fMMInstalled = Substr(fMMInstalled,1,MMLen-1)
  76.  
  77.    /* Verify Source Files
  78.    */
  79.    do i = 1 to MaxCopyIndex
  80.      rc = VerifySourcePath( SrcDir||Files.i )
  81.      if ( rc == 1 ) then
  82.        call Done
  83.    end
  84.  
  85.    /* Check and Clean Dirty System
  86.    */
  87.    InsDir = DIRECTORY(InsPath)
  88.    if (InsDir == InsPath) then
  89.      do
  90.        CleanDir = InsDir||"\BPIU"
  91.        TargetDir = DIRECTORY(CleanDir)
  92.        if (TargetDir == CleanDir) then
  93.          do
  94.            call DeleteFiles CleanDir
  95.            InsDir = DIRECTORY(InsPath)
  96.            rc = SysRmDir(CleanDir)
  97.            if (rc \= 0) then
  98.              do
  99.                'helpmsg sys'||rc||' | RXQUEUE 'errq
  100.                call DumpErrMsg
  101.                call Done
  102.              end
  103.          end
  104.      end
  105.     else do
  106.            /* \OS2\INSTALL is a required path directory!
  107.            */
  108.            'helpmsg SYS0010 | RXQUEUE 'errq
  109.             call DumpErrMsg
  110.             call Done
  111.          end
  112.  
  113.    /* Run Installation Utility
  114.    */
  115.    tmpDir = DIRECTORY(InsPath)
  116.    if (tmpDir \= "") then
  117.      do
  118.        if (MMLen > 0) then
  119.          call PlayMusic SrcDir, fMMInstalled
  120.        rc = SysMkDir("BPIU")
  121.        if (rc \= 0) then
  122.          do
  123.            'helpmsg sys'||rc||' | RXQUEUE 'errq
  124.            call DumpErrMsg
  125.            call Done
  126.          end
  127.        NewDir = InsDir||"\BPIU"
  128.        tmpDir = DIRECTORY(NewDir)
  129.        do t = 2 to Files.0
  130.          copystr = SrcDir||Files.t||' '||tmpDir||'\'||Files.t
  131.          'copy 'copystr
  132.        end
  133.        success = UnpackFiles(SrcDir, tmpDir, 1)
  134.        if (success == 0) then
  135.          do
  136.            BPIU Left(SrcDir,1)
  137.            /* Update Workplace Shell Desktop with Information Highway Folder
  138.            */
  139.            'call 'tmpdir'\'Files.2
  140.            call DeleteFiles tmpDir
  141.            tempDir = DIRECTORY(InsDir)
  142.            rc = SysRmDir(tmpDir)
  143.            if (rc \= 0) then
  144.              do
  145.                'helpmsg sys'||rc||' | RXQUEUE 'errq
  146.                call DumpErrMsg
  147.                call Done
  148.              end
  149.            tmpDir = DIRECTORY(SrcDir)
  150.          end
  151.      end
  152.  
  153.  
  154. Done:
  155.    rc = RXQUEUE('delete', errq)
  156.    OriginalDir = DIRECTORY(CurDir)
  157.    exit
  158.  
  159. /* Procedures and Functions
  160. */
  161.  
  162. VerifySourcePath: Procedure Expose errq
  163.  
  164.    Parse Arg file;
  165.  
  166.    fExists = Stream(file,'c','query exists')
  167.    if (fExists == "")
  168.      then do
  169.            'helpmsg SYS002 | RXQUEUE 'errq
  170.             call DumpErrMsg
  171.             return 1
  172.           end
  173.  
  174. return 0
  175.  
  176. UnpackFiles: Procedure Expose Files. errq
  177.  
  178.    Parse Arg SrcPath, TargetPath, index;
  179.  
  180.    if (SubStr(SrcPath,Length(SrcPath),1) == "\") then
  181.      unpackstr = SrcPath||Files.index||" "||TargetPath||,
  182.                  " /V /F  > nul 2>&1"
  183.    else unpackstr = SrcPath||"\"||Files.index||" "||TargetPath||,
  184.                     " /V /F > nul 2>&1"
  185.  
  186.    'unpack 'unpackstr
  187.  
  188.    if (rc \= 0) then
  189.      do
  190.        'helpmsg sys'||rc||' | RXQUEUE 'errq
  191.        call DumpErrMsg
  192.        return 1
  193.      end
  194.  
  195. return 0
  196.  
  197. DumpErrMsg: Procedure
  198.  
  199.    do while(QUEUED() \= 0)
  200.      parse pull line
  201.      if (POS("SYS",line) \= 0) then
  202.        fFound = 1
  203.      if ((line == "") & (fFound = 1)) then
  204.        do
  205.          /* Empty out queue
  206.          */
  207.          do while(QUEUED() \= 0)
  208.            parse pull line
  209.          end
  210.          leave
  211.        end
  212.      say line
  213.    end
  214.  
  215. return
  216.  
  217. PlayMusic: Procedure Expose Files. errq
  218.  
  219.    Parse Arg Source, MMBase;
  220.  
  221.    Target = MMBase||"\SOUNDS"
  222.    playstr = '"Rock-Intro" /C /MIN cmd.exe /q /c "'||MMBase||,
  223.              '\play.cmd FILE='||Target||,
  224.              '\BLUEJAM.MID FROM=0 TO=120000"'
  225.    'start 'playstr
  226.  
  227. return
  228.  
  229. DeleteFiles: Procedure Expose errq
  230.  
  231.   Parse Arg dir;
  232.  
  233.   fspec = dir||"\*.*"
  234.   call SysFileTree fspec, 'dellst', 'FO'
  235.   do i = 1 to dellst.0
  236.     rc = SysFileDelete(dellst.i)
  237.     if (rc \= 0) then
  238.       do
  239.         'helpmsg sys'||rc||' | RXQUEUE 'errq
  240.         call DumpErrMsg
  241.       end
  242.   end
  243.  
  244. return
  245.  
  246. GetBootDrive: Procedure
  247.  
  248.    PathStr = VALUE("PATH",,"OS2ENVIRONMENT")
  249.    InsPathPos = POS(":\OS2",TRANSLATE(PathStr))
  250.    if (InsPathPos \= 0) then
  251.      do
  252.        bdrive = Substr(PathStr,InsPathPos-1,2)
  253.      end
  254.    else bdrive = ""
  255.  
  256. return bdrive
  257.