| 571 | # @return True on success; False on failure |
| 572 | #------------------------------------------------------------------------------ |
| 573 | def MakeTargetDMGFile(msg=""): |
| 574 | #----------------------------------------------------------------------- |
| 575 | # The work DMG is mounted like: |
| 576 | # /dev/disk6s1 248Mi 228Mi 20Mi 93% 58449 5027 92% /Volumes/KLayout |
| 577 | #----------------------------------------------------------------------- |
| 578 | global MountDir # the mount directory: eg. /Volumes/KLayout |
| 579 | global FileSys # the file system : eg. /dev/disk6s1 |
| 580 | |
| 581 | #------------------------------------------------------------- |
| 582 | # [1] Print message |
| 583 | #------------------------------------------------------------- |
| 584 | if not msg == "": |
| 585 | print(msg) |
| 586 | |
| 587 | #------------------------------------------------------------- |
| 588 | # [2] Do the following jobs (0) through (14) sequentially |
| 589 | #------------------------------------------------------------- |
| 590 | |
| 591 | #-------------------------------------------------------- |
| 592 | # (0) Cleanup ProjectDir/ |
| 593 | #-------------------------------------------------------- |
| 594 | CleanUp() |
| 595 | |
| 596 | #-------------------------------------------------------- |
| 597 | # (1) Read the AppleScript template file and generate |
| 598 | # the actual one to execute later |
| 599 | #-------------------------------------------------------- |
| 600 | os.chdir(ProjectDir) |
| 601 | print( ">>> (1) Preparing AppleScript to execute later..." ) |
| 602 | tempScr = "macbuild/Resources/template-KLayoutDMG.applescript" |
| 603 | try: |
| 604 | fd = open( tempScr, "r" ) |
| 605 | tmpl = fd.read() |
| 606 | fd.close() |
| 607 | except Exception as e: |
| 608 | print( " ! Failed to read <%s>" % tempScr, file=sys.stderr ) |
| 609 | return False |
| 610 | else: |
| 611 | t = string.Template(tmpl) |
| 612 | # Figures below were determined by experiments for best fit |
| 613 | applescript = t.safe_substitute( |
| 614 | ORGX='50', ORGY='100', |
| 615 | WIN_WIDTH='1000', WIN_HEIGHT='540', |
| 616 | FULL_PATH_DS_STORE='/Volumes/%s/.DS_Store' % VolumeDMG, |
| 617 | BACKGROUND_PNG_FILE=BackgroundPNG, |
| 618 | ITEM_1='%s' % BundleName, X1='900', Y1='165', |
| 619 | ITEM_2='Applications', X2='900', Y2='345', |
| 620 | ITEM_3=Item3AppleScript, |
| 621 | CHECK_BASH='[ -f " & dotDSStore & " ]; echo $?' |
| 622 | ) |
| 623 | try: |
| 624 | # print(applescript) |
| 625 | fd = open( AppleScriptDMG, "w" ) |
| 626 | fd.write(applescript) |
| 627 | fd.close() |
| 628 | except Exception as e: |
| 629 | print( "! Failed to write <%s>" % AppleScriptDMG, file=sys.stderr ) |
| 630 | return False |