home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pmd20d.zip / install.cmd < prev    next >
OS/2 REXX Batch file  |  1995-08-15  |  15KB  |  419 lines

  1. /*
  2. @echo off
  3. cls
  4. echo.
  5. echo ERROR: You do not have REXX support installed.
  6. echo.
  7. echo Before you can run this install script, you must install REXX support
  8. echo from the 'Selective Install' program object.
  9. echo.
  10. pause
  11. exit
  12. */
  13.  
  14. /*
  15.  * Install.CMD
  16.  *
  17.  * Installs PMD 2.0 Demo Edition
  18.  */
  19.  
  20.  
  21. TRACE n
  22. signal on HALT
  23. call LoadLibs
  24.  
  25. /*
  26.  * get the cmd line
  27.  */
  28. parse arg destdir sourcedir
  29.  
  30. /*
  31.  * find out where this cmd file resides
  32.  */
  33. parse source . . thispgm
  34.  
  35. if sourcedir = ' ' then do
  36.   sourcedir = substr(thispgm, 1, (length(thispgm) - (length('install.cmd') + 1)));
  37.   say sourcedir
  38. end
  39.  
  40.  
  41. /*
  42.  * do the intro screen
  43.  */
  44. call SysCls
  45. say '┌─────────────────────────────────────────────────────────────────────┐'
  46. say '│                        PMD V.2.0 Installation                       │'
  47. say '├─────────────────────────────────────────────────────────────────────┤'
  48. say '│                                                                     │'
  49. say '│   This is the install program for the demo version of PMD           │'
  50. say '│   version 2.0. It will install the PMD demo files on your hard      │'
  51. say '│   disk.                                                             │'
  52. say '│                                                                     │'
  53. say '│   Please follow through the screens and answer the prompts as       │'
  54. say '│   they appear.                                                      │'
  55. say '│                                                                     │'
  56. say '│   You will be asked for a destination directory. Please choose      │'
  57. say '│   a destination directory on a drive or partition that has at       │'
  58. say '│   least 5 MB of free space.                                         │'
  59. say '│                                                                     │'
  60. say '│                                                                     │'
  61. say '│                                                                     │'
  62. say '│   Press any key to continue, or Ctrl+C to exit.                     │'
  63. say '└─────────────────────────────────────────────────────────────────────┘'
  64. '@pause > NUL'
  65.  
  66. /*
  67.  * Get the destination directory
  68.  */
  69. if destdir = ' ' then do
  70.   call SysCls
  71.   say '┌─────────────────────────────────────────────────────────────────────┐'
  72.   say '│                        PMD V.2.0 Installation                       │'
  73.   say '├─────────────────────────────────────────────────────────────────────┤'
  74.   say '│                                                                     │'
  75.   say '│                                                                     │'
  76.   say '│       Please enter the name of the directory you wish to            │'
  77.   say '│       install PMD to, at the prompt below.                          │'
  78.   say '│                                                                     │'
  79.   say '│                                                                     │'
  80.   say '│                                                                     │'
  81.   say '│                                                                     │'
  82.   say '│                                                                     │'
  83.   say '│                                                                     │'
  84.   say '│                                                                     │'
  85.   say '│                                                                     │'
  86.   say '│                                                                     │'
  87.   say '│                                                                     │'
  88.   say '└─────────────────────────────────────────────────────────────────────┘'
  89.   say '  Directory to install to (Default = C:\PMD): '
  90.   parse pull destdir
  91.   /* if they accepted the default */
  92.   if destdir = ' ' then destdir = 'C:\PMD'
  93. end
  94.  
  95. if sourcedir = ' ' then do
  96.   thisdir = directory()
  97.   call SysCls
  98.   say '┌─────────────────────────────────────────────────────────────────────┐'
  99.   say '│                        PMD V.2.0 Installation                       │'
  100.   say '├─────────────────────────────────────────────────────────────────────┤'
  101.   say '│                                                                     │'
  102.   say '│                                                                     │'
  103.   say '│       Please enter the name of the directory where the              │'
  104.   say '│       installation files are, at the prompt below:                  │'
  105.   say '│                                                                     │'
  106.   say '│                                                                     │'
  107.   say '│                                                                     │'
  108.   say '│                                                                     │'
  109.   say '│                                                                     │'
  110.   say '│                                                                     │'
  111.   say '│                                                                     │'
  112.   say '│                                                                     │'
  113.   say '│                                                                     │'
  114.   say '│                                                                     │'
  115.   say '└─────────────────────────────────────────────────────────────────────┘'
  116.   say '  Directory to install from (Default = 'thisdir'): '
  117.   parse pull sourcedir
  118.   /* if they accepted the default */
  119.   if sourcedir = ' ' then do
  120.     sourcedir = thisdir
  121.   end
  122. end
  123.  
  124. /*
  125.  * is the dest. dir a valid path?
  126.  */
  127. if stream(sourcedir'\install.cmd', 'c', 'query exists') = '' then do
  128.   call SysCls
  129.   say 'Error:'
  130.   say 'Could not verify that the installation files are actually in'
  131.   say 'the directory ' sourcedir '.'
  132.   say ''
  133.   say 'Please re-run this program from the directory where it and the'
  134.   say 'other installation files are stored,'
  135.   say 'or run it and specify <source dir> <dest dir> as arguments.'
  136.   say ''
  137.   say 'Press ENTER to exit:'
  138.   pull MyFinger
  139.   call SysCls
  140.   exit 0
  141. end
  142.  
  143.  
  144. /*
  145.  * make sure the source path is good
  146.  */
  147. if substr(sourcedir, length(sourcedir), 1) \= '\' then
  148.   sourcedir = sourcedir||'\'
  149.  
  150. /*
  151.  * Confirm the user's selections
  152.  */
  153. call SysCls
  154. say '┌─────────────────────────────────────────────────────────────────────┐'
  155. say '│                     PMD V.2.0 Demo Installation                     │'
  156. say '├─────────────────────────────────────────────────────────────────────┤'
  157. say '│     PM Designer will be installed using the following settings:     │'
  158. say '└─────────────────────────────────────────────────────────────────────┘'
  159. say ''
  160. say '  Source directory: ' sourcedir
  161. say '  Dest. directory: ' destdir
  162. say ''
  163.  
  164. if(AskYN('Okay to continue') = 0) then do
  165.   say
  166.   say 'Installation cancelled.'
  167.   exit
  168. end
  169.  
  170. call SysCls
  171. say ''
  172. say 'Installing PMD...'
  173.  
  174. /*
  175.  * Check the output directory
  176.  */
  177. rc = SysMkDir(destdir)
  178. if rc \= 0 then do
  179.   select
  180.     when rc = 3   then msg = 'Path not found.'
  181.     when rc = 5   then msg = 'Access denied.'
  182.     when rc = 26  then msg = 'Not a DOS disk.'
  183.     when rc = 87  then msg = 'Invalid parameter specified.'
  184.     when rc = 108 then msg = 'Drive Locked.'
  185.     when rc = 206 then msg = 'Filename exceeds range.'
  186.     otherwise msg = 'Unknown error (???)'
  187.   end
  188.   /* if rc==5, it's probably because the directory exists already.  */
  189.   if rc <> 5 then do
  190.     say 'Error creating destination directory. ' msg
  191.     if askNY('Proceed anyway?') = 0 then do
  192.       exit
  193.     end
  194.   end
  195. end
  196.  
  197. /* Create the required subdirs */
  198. rc = SysMkDir(destdir||'\bin')
  199. rc = SysMkDir(destdir||'\examples')
  200. rc = SysMkDir(destdir||'\vic')
  201. rc = SysMkDir(destdir||'\Projects')
  202. rc = SysMkDir(destdir||'\Projects\Project')
  203.  
  204. basedir = destdir
  205.  
  206. say 'Source dir: 'sourcedir
  207. say 'Dest dir: 'basedir
  208.  
  209. /*
  210.  * Copy the files
  211.  */
  212. say
  213. say 'NOTE:'
  214. say 'If you are installing this program from a floppy disk,'
  215. say 'this process may will take several minutes.'
  216. say ''
  217. say
  218. say 'Install is copying files, please wait...'
  219. call CopyFile 'readme.inf', sourcedir, basedir
  220. call CopyFile 'pmd.ico',   sourcedir, basedir||'\BIN'
  221.  
  222. say 'Install is unpacking files, please wait...'
  223.  
  224. '@view.exe '||destdir||'\Readme Introduction'
  225.  
  226. /*
  227.  * Install the individual archives:
  228.  *
  229.   The archives are .lzh files that have the required directory
  230.   structures stored in them already. They are set up so they
  231.   just have to be unpacked to the base dest. directory.
  232.  */
  233.  
  234. /*-- unpack the PMDBIN.EXE archive --*/
  235. say 'Unpacking program files...'
  236. command = '@echo y |'||sourcedir||'PMDBASE.EXE /o 'basedir'>NUL'
  237. command
  238.  
  239. /*-- unpack the VPPGEN.EXE archive --*/
  240. say 'Unpacking the code generator files...'
  241. command = '@echo y |'||sourcedir||'VICGEN.EXE /o 'basedir'>NUL'
  242. command
  243.  
  244. /*-- unpack the VICBASE.EXE archive --*/
  245. say 'Unpacking the VIC files...'
  246. command = '@echo y |'||sourcedir||'VICBASE.EXE /o 'basedir'\vic>NUL'
  247. command
  248.  
  249. say 'Unpacking the Example files...'
  250. command = '@echo y |'||sourcedir||'PMDXMP.EXE /o 'basedir'\examples>NUL'
  251. command
  252.  
  253. /*
  254.  * Create the objects on the desktop
  255.  */
  256. say
  257. say 'Creating the program folder,'
  258. x = SysCreateObject("WPFolder",,
  259.                     "PMD V.2.0 demo edition",,
  260.                     "<WP_DESKTOP>",,
  261.         "OBJECTID=<PMD>;ICONFILE="||destdir||"\BIN\PMD.ICO;OPEN=DEFAULT", "replace")
  262. if x = 0 then do
  263.   say 'Unable to create folder; cancelling.'
  264.   exit
  265. end
  266.  
  267. say 'Adding the'
  268.  
  269. say 'ReadMe file,'
  270. x = SysCreateObject("WPProgram",,
  271.                     "Read Me First",,
  272.                     "<PMD>",,
  273.                     "EXENAME=VIEW.EXE;PARAMETERS="||destdir||"\README.INF")
  274.  
  275. say 'Manual,'
  276. x = SysCreateObject("WPProgram",,
  277.                     "PMD Help",,
  278.                     "<PMD>",,
  279.                     "EXENAME=VIEW.EXE;PARAMETERS="||destdir||"\DOC\PMD.INF")
  280.  
  281. say 'VICGEN Manual,'
  282. x = SysCreateObject("WPProgram",,
  283.                     "VICGEN Help",,
  284.                     "<PMD>",,
  285.                     "EXENAME=VIEW.EXE;PARAMETERS="||destdir||"\DOC\VICGEN.INF")
  286.  
  287. say 'VIC Reference,'
  288. x = SysCreateObject("WPProgram",,
  289.                     "VIC Reference",,
  290.                     "<PMD>",,
  291.                     "EXENAME=VIEW.EXE;PARAMETERS="||destdir||"\VIC\VIC.INF")
  292.  
  293. say 'PM Designer,'
  294. x = SysCreateObject("WPProgram",,
  295.                     "PM Designer",,
  296.                     "<PMD>",,
  297.   "EXENAME="||destdir||"\BIN\PMD.EXE;STARTUPDIR="||destdir"\BIN;ASSOCFILTER=*.APP")
  298.  
  299. say 'License agreement,'
  300. x = SysCreateObject("WPProgram",,
  301.                     "License Agreement",,
  302.                     "<PMD>",,
  303.   "EXENAME=E.EXE;PARAMETERS="||destdir||"\DOC\LICENSE.TXT")
  304.  
  305. say 'Problem reporting form,'
  306. x = SysCreateObject("WPProgram",,
  307.                     "Problem report form",,
  308.                     "<PMD>",,
  309.   "EXENAME=E.EXE;PARAMETERS="||destdir||"\DOC\pmdprob.TXT")
  310.  
  311.  
  312. say 'Examples folder,'
  313. x = SysCreateObject("WPShadow",,
  314.                    "Examples",,
  315.                    "<PMD>",,
  316.  "SHADOWID="||destdir||"\examples")
  317.  
  318. say 'Projects folder,'
  319. x = SysCreateObject("WPShadow",,
  320.                     "Projects",,
  321.                     "<PMD>",,
  322.   "SHADOWID="||destdir||"\Projects")
  323.  
  324. say 'Project template,'
  325. x = SysSetObjectData(destdir||"\Projects\project", "TEMPLATE=YES")
  326. if x = 0 then do
  327.   say 'Unable to set the "TEMPLATE" attribute on the project template.'
  328.   say 'You will have to do this manually...'
  329.   pull confirm
  330. end
  331.  
  332. /*
  333.  * Create the template .APP file in the Projects\Project folder
  334.  */
  335. templatedir = destdir||"\Projects\Project"
  336. appfile = destdir||"\bin\_default.app "
  337.  
  338. say 'Creating template files...'
  339. '@copy 'appfile templatedir'\newapp.app'
  340.  
  341.  
  342. say 'Creating PMDENV.CMD...'
  343. '@echo SET BOOKSHELF=%BOOKSHELF%;'destdir||'\DOC >> 'destdir||'\bin\pmdenv.cmd'
  344. '@echo SET HELPNDX='destdir||'\BIN\PMDAPI.NDX >> 'destdir||'\bin\pmdenv.cmd'
  345. '@echo SET PATH=%PATH%;'destdir||'\BIN >> 'destdir||'\bin\pmdenv.cmd'
  346.  
  347. GoodBye:
  348. /*-- exit with a goodbye --*/
  349. say
  350. say 'Done.'
  351. say
  352. say
  353. say 'The PMD demo has been installed on your system.'
  354. say 'Please run the PMDENV.CMD file in the PMD\BIN directory to add the'
  355. say 'relevant PMD variables to your environment settings.'
  356. say
  357. say 'Be sure to read the README file for up-to-date information.'
  358. say
  359.  
  360. exit
  361.  
  362. /*----------------------------------------------*/
  363. /*-- FUNCTION:                                --*/
  364. /*-- LoadLibs                                 --*/
  365. /*-- ACTION:                                  --*/
  366. /*-- loads the libraries needed by this REXX  --*/
  367. /*----------------------------------------------*/
  368. LoadLibs:
  369.   if RxFuncQuery('SysLoadFuncs') THEN
  370.   do
  371.     /*-- load the load-function --*/
  372.     CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  373.     /*-- load the Sys* utilities --*/
  374.     CALL SysLoadFuncs
  375.   end
  376. return
  377.  
  378. HALT:
  379.   say
  380.   say 'Program cancelled; Interrupted by user.'
  381.   exit
  382.  
  383. /*-----------------------------------------------------------------------------*/
  384. /*-- CopyFile                                                                --*/
  385. /*-----------------------------------------------------------------------------*/
  386. CopyFile: parse Arg ArgFile2Copy, ArgSourceDir, ArgInstallDir
  387.  
  388.     Say 'Copying 'ArgSourceDir||ArgFile2Copy' to 'ArgInstallDir||'\'||ArgFile2Copy'...'
  389.     Command = '@Copy 'ArgSourceDir||ArgFile2Copy' 'ArgInstallDir||'\'||ArgFile2Copy' >NUL'
  390.     Command
  391.     if rc \= 0 Then Do
  392.         say 'Error! 'ArgFile2Copy' was not installed properly.'
  393.         pull MyFinger
  394.     End
  395.     Return
  396.  
  397. /*-----------------------------------------------------------------------------*/
  398. /*-- AskYN: defaults to 'YES'                                                --*/
  399. /*-----------------------------------------------------------------------------*/
  400. AskYN: parse arg argPrompt
  401.   say
  402.   say argPrompt||'(Y/n)?'
  403.   k = SysGetKey('NOECHO')
  404.   if k = 'N' | k = 'n' then return 0
  405.   else return 1
  406.  
  407. /*-----------------------------------------------------------------------------*/
  408. /*-- AskNY: defaults to 'NO'                                                 --*/
  409. /*-----------------------------------------------------------------------------*/
  410. AskNY: parse arg argPrompt
  411.   say
  412.   say argPrompt||'(y/N)?'
  413.   k = SysGetKey('NOECHO')
  414.   if k = 'Y' | k = 'y' then return 1
  415.   else return 0
  416.  
  417. /* eof */
  418.  
  419.