@@ -517,39 +517,96 @@ end toolsBuilderMakeAppBundle
517517command toolsBuilderMakeDisk pVersion, pEdition, pPlatform
518518 -- Get the name of the app bundle that is being built
519519 local tOutputFileFolder
520+ local tDmgFolder
520521 local tAppBundle
521522 put builderOutputFolder() into tOutputFileFolder
523+ put builderOutputFolder() & slash & "DMG" into tDmgFolder
522524 put tOutputFileFolder & slash & getBundleFilenameStub(pVersion , pPlatform , pEdition ) & ".app" into tAppBundle
523525
524526 -- DMG output filename
525527 local tDmgFile
526- put tOutputFileFolder & slash & getInstallerFilenameStub(pVersion , pPlatform , pEdition ) & ".dmg" into tDmgFile
528+ local tTempDmg
529+ put tOutputFileFolder & slash & getDmgFilenameStub(pVersion , pPlatform , pEdition ) & ".dmg" into tDmgFile
530+ put tOutputFileFolder & slash & getDmgFilenameStub(pVersion , pPlatform , pEdition ) & "-rw.dmg" into tTempDmg
531+
532+ -- Remove any stale DMG folder
533+ if there is a folder tDmgFolder then
534+ builderLog "message" , "Removing old DMG directory"
535+ get shell ("rm -r" && escapeArg(tDmgFolder ))
536+ if the result is not zero then
537+ builderLog "error" ,"Failed to remove old DMG directory:" && it
538+ throw "failure"
539+ end if
540+ end if
541+
542+ -- Create a new DMG folder
543+ create folder tDmgFolder
544+
545+ -- Copy the app bundle into the DMG contents folder
546+ builderLog "message" , "Copying app bundle into DMG directory"
547+ get shell ("cp -R" && escapeArg(tAppBundle ) && escapeArg(tDmgFolder & slash))
548+ if the result is not zero then
549+ builderLog "error" , "Failed to copy app bundle into DMG directory:" && it
550+ throw "failure"
551+ end if
527552
528553 builderLog "message" , "Building Mac DMG to '" & tDmgFile & "'"
529554 if there is a file tDmgFile then
530555 delete file tDmgFile
531- if there is a file tDmgFile then
532- builderLog "error" , "Could not remove existing dmg - make sure it is not mounted"
533- throw "failure"
534- end if
556+ end if
557+ if there is a file tTempDmg then
558+ delete file tTempDmg
559+ end if
560+ if there is a file tDmgFile or there is a file tTempDmg then
561+ builderLog "error" , "Could not remove existing dmg - make sure it is not mounted"
562+ throw "failure"
535563 end if
536564
537565 -- The following is sometimes needed to work around bugs in hdiutil
538566 -- local tTrashFile
539567 -- put builderWorkspaceFolder() & "/deploy/.Trash" into tTrashFile
540568 -- put empty into URL ("file:" & tTrashFile)
541569
542- -- Create an "Applications" symlink to place in the DMG
543- -- This is a common helper shortcut added to OSX DMGs
544- local tApplicationsAlias
545- put tOutputFileFolder & slash & "Applications" into tApplicationsAlias
546- create alias tApplicationsAlias to "/Applications"
547-
548- -- Do the DMG build
549- get shell ("hdiutil create -fs HFS+ -format UDBZ -volname" && escapeArg(getBundleFilenameStub(pVersion , pPlatform , pEdition )) && "-srcfolder" && escapeArg(tAppBundle ) && escapeArg(tDmgFile ) && "-srcfolder" && escapeArg(tApplicationsAlias ))
550- rename tDmgAppFolder to (tOutputFileStub & ".app" )
570+ -- Attempt to detach any DMGs with the name we're about to create
571+ -- We ignore failures here as it may not be mounted and an already-mounted
572+ -- disk will cause a very visible error during the next step.
573+ local tVolumeName
574+ put getBundleFilenameStub(pVersion , pPlatform , pEdition ) into tVolumeName
575+ get shell ("hdiutil detach" && escapeArg(tVolumeName ))
576+
577+ -- Generate an initial read-write DMG and mount it
578+ builderLog "message" , "Generating initial DMG"
579+ get shell ("hdiutil create -fs HFS+ -format UDRW -attach -volname" && escapeArg(tVolumeName ) && "-srcfolder" && escapeArg(tDmgFolder ) && escapeArg(tTempDmg ))
551580 if "created:" is not in it then
552- builderLog "error" , "Dmg creation failed -" && the last line of it
581+ builderLog "error" , "Failed to create initial DMG:" && it
582+ throw "failure"
583+ end if
584+
585+ -- Generate the multi-resolution TIFF for the DMG background image
586+ local tBackgroundImage
587+ put tOutputFileFolder & slash & "bg-" & pEdition & ".tiff" into tBackgroundImage
588+ builderLog "message" , "Generating DMG background image"
589+ get shell ("tiffutil -cathidpicheck" && escapeArg(builderCommunityResourceFolder() & "/dmg/bg-" & pEdition & ".png" ) \
590+ && escapeArg(builderCommunityResourceFolder() & "/dmg/bg-" & pEdition & "@2x.png" ) \
591+ && "-out" && escapeArg(tBackgroundImage ))
592+ if the result is not zero then
593+ builderLog "error" ,"Failed to generate DMG background image:" && it
594+ throw "failure"
595+ end if
596+
597+ -- Run the DMG prettifier script (this unmounts the DMG at the end)
598+ builderLog "message" , "Setting DMG background and styling"
599+ get shell (builderRepoFolder() & "/tools/make-dmg-pretty.sh" && escapeArg(tVolumeName ) && escapeArg(tBackgroundImage ))
600+ if it is not empty or the result is not zero then
601+ builderLog "error" , "Failed to apply DMG styling:" && it
602+ throw "failure"
603+ end if
604+
605+ -- Convert the DMG into a read-only, compressed DMG
606+ builderLog "message" , "Compressing DMG"
607+ get shell ("hdiutil convert" && escapeArg(tTempDmg ) && "-format UDBZ -o" && escapeArg(tDmgFile ))
608+ if the result is not zero or not line - 1 of it begins with "created:" then
609+ builderLog "error" , "Failed to compress DMG:" && it
553610 throw "failure"
554611 end if
555612
@@ -608,13 +665,26 @@ function getInstallerFilenameStub pVersion, pPlatform, pEdition
608665 else if pPlatform is "linux" or pPlatform is "linux-x64" or pPlatform is "linux-armv6hf" then
609666 put "Linux" into pPlatform
610667 end if
611- if pEdition is "Community" then
612- return "LiveCodeCommunityInstaller-" & pVersion & "-" & pPlatform
613- else
614- return "LiveCodeInstaller-" & pVersion & "-" & pPlatform
615- end if
668+ return "LiveCode" & the upper of char 1 of pEdition & the lower of char 2 to - 1 of pEdition & "Installer-" & pVersion & "-" & pPlatform
616669end getInstallerFilenameStub
617670
671+ function getDmgFilenameStub pVersion, pPlatform, pEdition
672+ set the itemDelimiter to "-"
673+ if item 2 of pVersion is "gm" then
674+ delete item - 2 to - 1 of pVersion
675+ end if
676+ replace "-" with "_" in pVersion
677+ replace "." with "_" in pVersion
678+ if pPlatform is "macosx" then
679+ put "Mac" into pPlatform
680+ else if pPlatform is "windows" then
681+ put "Windows" into pPlatform
682+ else if pPlatform is "linux" or pPlatform is "linux-x64" or pPlatform is "linux-armv6hf" then
683+ put "Linux" into pPlatform
684+ end if
685+ return "LiveCode" & the upper of char 1 of pEdition & the lower of char 2 to - 1 of pEdition & "-" & pVersion & "-" & pPlatform
686+ end getDmgFilenameStub
687+
618688function loadTextFile pFile
619689 get url ("binfile:" & pFile )
620690 replace numToChar (13 ) & numToChar (10 ) with return in it
0 commit comments