Ticket #156: InstallPath.patch
File InstallPath.patch, 7.8 KB (added by Caligari, 16 years ago) |
---|
Patch to install-from-workspace |
-
Source/InstallFromWorkspace.cobra
114 114 print 115 115 print 'Working...' 116 116 print 117 .verifyInstallDirectory 117 118 .verifyInWorkspace 118 119 .verifyVirtualMachineVersion 119 120 .locateSnapshotCompiler … … 208 209 print 'found dir:', dir 209 210 else 210 211 print 'make dir :', dir 211 Directory.createDirectory(dir) 212 try 213 Directory.createDirectory(dir) 214 catch ex as SystemException 215 .error('Unable to create installation directory.\n[ex.message]\nCannot proceed.\nPut the install path into a file called "installDirectory".') 212 216 213 217 def startStage(description as String) 214 218 print '====', description … … 283 287 284 288 ## Stages 285 289 290 def verifyInstallDirectory 291 .startStage('Verify installation directory') 292 default = if(.isRunningOnUnix, .installDirectories[1], .installDirectories[0]) 293 if File.exists('installDirectory') 294 # get install directory from first line of the file 295 useDir = File.openText('installDirectory').readLine 296 if useDir, default = useDir 297 # TODO: prompt the user for the location 298 .requireDir(default) 299 _baseDir = default 300 286 301 def verifyInWorkspace 287 302 .startStage('Verify running in workspace') 288 303 msg = 'The current directory does not appear to be a workspace. This program is for installing from the workspace.' … … 453 468 print 454 469 455 470 def copyFilesToInstallDirectory 456 .startStage('Copy files to install directory') 457 slash = .slash 458 default = if(.isRunningOnUnix, .installDirectories[1], .installDirectories[0]) 459 # TODO: prompt the user for the location 460 _baseDir = baseDir = default 471 require 472 _baseDir is not nil 473 body 474 .startStage('Copy files to install directory') 475 slash = .slash 476 baseDir = _baseDir 461 477 462 .requireDir(baseDir) 463 if Directory.exists(Path.combine(baseDir, 'Source')) 464 print 'The directory "[baseDir]" appears to contain a workspace or snapshot of the' 465 print 'Cobra source code, due to containing the subdirectory "Source".' 466 print 'Installing to that location can lead to confusion and technical difficulties.' 467 print 'Consider clearing out "[baseDir]" and creating a workspace *inside* it called,' 468 print 'for example, "Workspace".' 469 print 470 .error('Cannot install to workspace or workspace snapshot. See message above.') 471 472 versionDir = '[baseDir][slash]Cobra-[_baseVersion]' 473 .deleteDir(versionDir) 474 .requireDir(versionDir) 475 _versionDir = versionDir 478 if baseDir, .requireDir(baseDir) 479 if Directory.exists(Path.combine(baseDir, 'Source')) 480 print 'The directory "[baseDir]" appears to contain a workspace or snapshot of the' 481 print 'Cobra source code, due to containing the subdirectory "Source".' 482 print 'Installing to that location can lead to confusion and technical difficulties.' 483 print 'Consider clearing out "[baseDir]" and creating a workspace *inside* it called,' 484 print 'for example, "Workspace".' 485 print 486 .error('Cannot install to workspace or workspace snapshot. See message above.') 476 487 477 # TODO: readme file? 478 parent = Path.getFullPath('..') 488 versionDir = '[baseDir][slash]Cobra-[_baseVersion]' 489 .deleteDir(versionDir) 490 .requireDir(versionDir) 491 _versionDir = versionDir 479 492 480 versionOutput = '' 481 if File.exists('[parent][slash]InformalRelease.text') 482 versionOutput = File.readAllText('[parent][slash]InformalRelease.text') 483 else 484 # record "svn info" in the installation directory 485 try 486 process as Process? 487 versionOutput = .runCommand('svn', 'info', out process, false) 488 if process.exitCode 489 print '"snv info" failed. Check your svn installation.' 490 print '[versionOutput]' 491 print 493 # TODO: readme file? 494 parent = Path.getFullPath('..') 495 496 versionOutput = '' 497 if File.exists('[parent][slash]InformalRelease.text') 498 versionOutput = File.readAllText('[parent][slash]InformalRelease.text') 499 else 500 # record "svn info" in the installation directory 501 try 502 process as Process? 503 versionOutput = .runCommand('svn', 'info', out process, false) 504 if process.exitCode 505 print '"snv info" failed. Check your svn installation.' 506 print '[versionOutput]' 507 print 508 .error('Cannot find version information, installation halted.') 509 catch ex as SystemException 510 # user could be on TortoiseSVN 511 print 'svn is not installed or it is not in the PATH. ', ex.message 492 512 .error('Cannot find version information, installation halted.') 493 catch ex as SystemException 494 # user could be on TortoiseSVN 495 print 'svn is not installed or it is not in the PATH. ', ex.message 496 .error('Cannot find version information, installation halted.') 497 if versionOutput <> '' 498 fileName = '[versionDir][slash]Version.text' 499 print 'writing :', fileName 500 File.writeAllText(fileName, versionOutput) 501 print 513 if versionOutput <> '' 514 fileName = '[versionDir][slash]Version.text' 515 print 'writing :', fileName 516 File.writeAllText(fileName, versionOutput) 517 print 502 518 503 for dir in ['HowTo', 'Reusables', 'Samples', 'Supplements']504 .copyContents('[parent][slash][dir]', '[versionDir][slash][dir]')519 for dir in ['HowTo', 'Reusables', 'Samples', 'Supplements'] 520 .copyContents('[parent][slash][dir]', '[versionDir][slash][dir]') 505 521 506 versionBinDir = '[versionDir][slash]bin'507 .requireDir(versionBinDir)508 print 'copy bin: [versionBinDir]'509 binFiles = 'cobra.exe Cobra.Lang.dll styles-cobra-doc.css styles-exception-report.css styles-output-html.css'.split510 for fileName in binFiles511 File.copy(fileName, '[versionBinDir][slash][fileName]')522 versionBinDir = '[versionDir][slash]bin' 523 .requireDir(versionBinDir) 524 print 'copy bin: [versionBinDir]' 525 binFiles = 'cobra.exe Cobra.Lang.dll styles-cobra-doc.css styles-exception-report.css styles-output-html.css'.split 526 for fileName in binFiles 527 File.copy(fileName, '[versionBinDir][slash][fileName]') 512 528 513 .copyContents('Cobra.Lang', '[versionBinDir][slash]Cobra.Lang')529 .copyContents('Cobra.Lang', '[versionBinDir][slash]Cobra.Lang') 514 530 515 # delete _svn or .svn from the installation directory516 .findAndDeleteDir(versionDir, '_svn')517 .findAndDeleteDir(versionDir, '.svn')531 # delete _svn or .svn from the installation directory 532 .findAndDeleteDir(versionDir, '_svn') 533 .findAndDeleteDir(versionDir, '.svn') 518 534 519 # create cobra.bat / cobra for invoking the latest version520 baseBinDir = '[baseDir][slash]bin'521 .requireDir(baseBinDir)522 if .isRunningOnUnix523 _cobraCommandPath = '[baseBinDir][slash]cobra'524 print 'writing :', _cobraCommandPath525 using f = File.createText(_cobraCommandPath)526 f.writeLine('#!/bin/sh')527 f.writeLine('exec mono "[versionDir][slash]bin[slash]cobra.exe" "$@"')528 .runCommand('chmod', "a+x '[_cobraCommandPath]'")529 else530 _cobraCommandPath = '[baseBinDir][slash]cobra.bat'531 print 'writing :', _cobraCommandPath532 using f = File.createText(_cobraCommandPath)533 f.writeLine('@"[versionDir][slash]bin[slash]cobra.exe" %*')534 print535 # create cobra.bat / cobra for invoking the latest version 536 baseBinDir = '[baseDir][slash]bin' 537 .requireDir(baseBinDir) 538 if .isRunningOnUnix 539 _cobraCommandPath = '[baseBinDir][slash]cobra' 540 print 'writing :', _cobraCommandPath 541 using f = File.createText(_cobraCommandPath) 542 f.writeLine('#!/bin/sh') 543 f.writeLine('exec mono "[versionDir][slash]bin[slash]cobra.exe" "$@"') 544 .runCommand('chmod', "a+x '[_cobraCommandPath]'") 545 else 546 _cobraCommandPath = '[baseBinDir][slash]cobra.bat' 547 print 'writing :', _cobraCommandPath 548 using f = File.createText(_cobraCommandPath) 549 f.writeLine('@"[versionDir][slash]bin[slash]cobra.exe" %*') 550 print 535 551 536 552 def verifyNewlyInstalledCobra 537 553 .startStage('Verify newly installed Cobra compiler')