diff --git a/.github/workflows/ci-macvim.yaml b/.github/workflows/ci-macvim.yaml index 01ecdf8cf9..7d256e873b 100644 --- a/.github/workflows/ci-macvim.yaml +++ b/.github/workflows/ci-macvim.yaml @@ -312,7 +312,11 @@ jobs: run: | # Use the --skip-jenkins flag to skip the prettify osascript calls which could fail due to permission issues in # CI environment. - make -C src macvim-dmg CREATEDMG_FLAGS=--skip-jenkins + if ${{ matrix.legacy == true }}; then + make -C src macvim-dmg-legacy CREATEDMG_FLAGS=--skip-jenkins + else + make -C src macvim-dmg CREATEDMG_FLAGS=--skip-jenkins + fi if ${{ matrix.publish_postfix != '' }}; then mv src/MacVim/build/Release/MacVim.dmg src/MacVim/build/Release/MacVim${{ matrix.publish_postfix }}.dmg diff --git a/src/create-dmg/.editorconfig b/src/MacVim/create-dmg/.editorconfig similarity index 100% rename from src/create-dmg/.editorconfig rename to src/MacVim/create-dmg/.editorconfig diff --git a/src/create-dmg/.gitignore b/src/MacVim/create-dmg/.gitignore similarity index 100% rename from src/create-dmg/.gitignore rename to src/MacVim/create-dmg/.gitignore diff --git a/src/create-dmg/.this-is-the-create-dmg-repo b/src/MacVim/create-dmg/.this-is-the-create-dmg-repo similarity index 100% rename from src/create-dmg/.this-is-the-create-dmg-repo rename to src/MacVim/create-dmg/.this-is-the-create-dmg-repo diff --git a/src/create-dmg/LICENSE b/src/MacVim/create-dmg/LICENSE similarity index 100% rename from src/create-dmg/LICENSE rename to src/MacVim/create-dmg/LICENSE diff --git a/src/create-dmg/Makefile b/src/MacVim/create-dmg/Makefile similarity index 100% rename from src/create-dmg/Makefile rename to src/MacVim/create-dmg/Makefile diff --git a/src/MacVim/create-dmg/README b/src/MacVim/create-dmg/README new file mode 100644 index 0000000000..496e77dcef --- /dev/null +++ b/src/MacVim/create-dmg/README @@ -0,0 +1 @@ +Content of this directory is copied from https://github.com/create-dmg/create-dmg (c89d743919acb1a16259ed7b98059393978fb639 / 2023-01-23). diff --git a/src/create-dmg/README.md b/src/MacVim/create-dmg/README.md similarity index 95% rename from src/create-dmg/README.md rename to src/MacVim/create-dmg/README.md index 01f68d5ccc..9a06a2bf05 100644 --- a/src/create-dmg/README.md +++ b/src/MacVim/create-dmg/README.md @@ -63,7 +63,8 @@ All contents of source\_folder will be copied into the disk image. - **--eula \:** attach a license file to the dmg - **--rez \:** specify custom path to Rez tool used to include license file - **--no-internet-enable:** disable automatic mount© -- **--format:** specify the final image format (UDZO|UDBZ|ULFO|ULMO) (default is UDZO) +- **--format:** specify the final image format (UDZO|UDBZ|ULFO|ULMO) (default is UDZO) +- **--filesystem:** specify the image filesystem (HFS+|APFS) (default is HFS+, APFS supports macOS 10.13 or newer) - **--add-file \ \ \ \:** add additional file or folder (can be used multiple times) - **--disk-image-size \:** set the disk image size manually to x MB - **--hdiutil-verbose:** execute hdiutil in verbose mode @@ -73,7 +74,7 @@ All contents of source\_folder will be copied into the disk image. - **--notarize \:** notarize the disk image (waits and staples) with the keychain stored credentials For more information check [Apple's documentation](https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/customizing_the_notarization_workflow) - **--skip-jenkins:** skip Finder-prettifying AppleScript, useful in Sandbox and non-GUI environments, [#72](https://github.com/create-dmg/create-dmg/pull/72) -- **--sandbox-safe:** hdiutil with sandbox compatibility, do not bless and do not execute the cosmetic AppleScript +- **--sandbox-safe:** hdiutil with sandbox compatibility, do not bless and do not execute the cosmetic AppleScript (not supported for APFS disk images) - **--version:** show tool version number - **-h, --help:** display the help diff --git a/src/create-dmg/builder/create-dmg.builder b/src/MacVim/create-dmg/builder/create-dmg.builder similarity index 100% rename from src/create-dmg/builder/create-dmg.builder rename to src/MacVim/create-dmg/builder/create-dmg.builder diff --git a/src/create-dmg/create-dmg b/src/MacVim/create-dmg/create-dmg similarity index 87% rename from src/create-dmg/create-dmg rename to src/MacVim/create-dmg/create-dmg index 4a9715e671..6af8b5889e 100755 --- a/src/create-dmg/create-dmg +++ b/src/MacVim/create-dmg/create-dmg @@ -4,13 +4,18 @@ # Bail out on any unhandled errors set -e; +# Any command that exits with non-zero code will cause the pipeline to fail +set -o pipefail; -CDMG_VERSION='1.1.0' +CDMG_VERSION='1.1.1' # The full path to the "support/" directory this script is using # (This will be set up by code later in the script.) CDMG_SUPPORT_DIR="" +OS_FULL_VERSION="$(sw_vers | sed -n 2p | cut -d : -f 2 | tr -d '[:space:]' | cut -c1-)" +OS_MAJOR_VERSION="$(echo $OS_FULL_VERSION | cut -d . -f 1)" +OS_MINOR_VERSION="$(echo $OS_FULL_VERSION | cut -d . -f 2)" WINX=10 WINY=60 WINW=500 @@ -18,6 +23,7 @@ WINH=350 ICON_SIZE=128 TEXT_SIZE=16 FORMAT="UDZO" +FILESYSTEM="HFS+" ADD_FILE_SOURCES=() ADD_FILE_TARGETS=() IMAGEKEY="" @@ -33,6 +39,26 @@ function pure_version() { echo "$CDMG_VERSION" } +function hdiutil_detach_retry() { + # Unmount + unmounting_attempts=0 + until + echo "Unmounting disk image..." + (( unmounting_attempts++ )) + hdiutil detach "$1" + exit_code=$? + (( exit_code == 0 )) && break # nothing goes wrong + (( exit_code != 16 )) && exit $exit_code # exit with the original exit code + # The above statement returns 1 if test failed (exit_code == 16). + # It can make the code in the {do... done} block to be executed + do + (( unmounting_attempts == MAXIMUM_UNMOUNTING_ATTEMPTS )) && exit 16 # patience exhausted, exit with code EBUSY + echo "Wait a moment..." + sleep $(( 1 * (2 ** unmounting_attempts) )) + done + unset unmounting_attempts +} + function version() { echo "create-dmg $(pure_version)" } @@ -76,6 +102,8 @@ Options: disable automatic mount & copy --format specify the final disk image format (UDZO|UDBZ|ULFO|ULMO) (default is UDZO) + --filesystem + specify the disk image filesystem (HFS+|APFS) (default is HFS+, APFS supports macOS 10.13 or newer) --add-file | add additional file or folder (can be used multiple times) --disk-image-size @@ -91,7 +119,7 @@ Options: --notarize notarize the disk image (waits and staples) with the keychain stored credentials --sandbox-safe - execute hdiutil with sandbox compatibility and do not bless + execute hdiutil with sandbox compatibility and do not bless (not supported for APFS disk images) --version show create-dmg version number -h, --help @@ -162,6 +190,9 @@ while [[ "${1:0:1}" = "-" ]]; do --format) FORMAT="$2" shift; shift;; + --filesystem) + FILESYSTEM="$2" + shift; shift;; --add-file | --add-folder) ADD_FILE_TARGETS+=("$2") ADD_FILE_SOURCES+=("$3") @@ -230,6 +261,16 @@ if [[ "${DMG_PATH: -4}" != ".dmg" ]]; then exit 1 fi +if [[ "${FILESYSTEM}" != "HFS+" ]] && [[ "${FILESYSTEM}" != "APFS" ]]; then + echo "Unknown disk image filesystem: ${FILESYSTEM}. Run 'create-dmg --help' for help." + exit 1 +fi + +if [[ "${FILESYSTEM}" == "APFS" ]] && [[ ${SANDBOX_SAFE} -eq 1 ]]; then + echo "Creating an APFS disk image that is sandbox safe is not supported." + exit 1 +fi + # Main script logic SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -280,7 +321,12 @@ function blocks_to_megabytes() { function get_size() { # Get block size in disk - bytes_size=$(du -s "$1" | sed -e 's/ .*//g') + if [[ $OS_MAJOR_VERSION -ge 12 ]]; then + bytes_size=$(du -B 512 -s "$1") + else + bytes_size=$(du -s "$1") + fi + bytes_size=$(echo $bytes_size | sed -e 's/ .*//g') echo $(blocks_to_megabytes $bytes_size) } @@ -291,9 +337,14 @@ if [[ -n "$DISK_IMAGE_SIZE" ]]; then fi if [[ $SANDBOX_SAFE -eq 0 ]]; then + if [[ "$FILESYSTEM" == "APFS" ]]; then + FILESYSTEM_ARGUMENTS="" + else + FILESYSTEM_ARGUMENTS="-c c=64,a=16,e=16" + fi hdiutil create ${HDIUTIL_VERBOSITY} -srcfolder "$SRC_FOLDER" -volname "${VOLUME_NAME}" \ - -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW ${CUSTOM_SIZE} "${DMG_TEMP_NAME}" -else + -fs "${FILESYSTEM}" -fsargs "${FILESYSTEM_ARGUMENTS}" -format UDRW ${CUSTOM_SIZE} "${DMG_TEMP_NAME}" +else hdiutil makehybrid ${HDIUTIL_VERBOSITY} -default-volume-name "${VOLUME_NAME}" -hfs -o "${DMG_TEMP_NAME}" "$SRC_FOLDER" hdiutil convert -format UDRW -ov -o "${DMG_TEMP_NAME}" "${DMG_TEMP_NAME}" DISK_IMAGE_SIZE_CUSTOM=$DISK_IMAGE_SIZE @@ -335,7 +386,7 @@ MOUNT_DIR="/Volumes/${VOLUME_NAME}" if [[ -d "${MOUNT_DIR}" ]]; then echo "Unmounting old disk image from $MOUNT_DIR..." DEV_NAME=$(hdiutil info | grep -E --color=never '^/dev/' | sed 1q | awk '{print $1}') - hdiutil detach "${DEV_NAME}" + hdiutil_detach_retry "${DEV_NAME}" fi echo "Mounting disk image..." @@ -399,7 +450,7 @@ else true else echo >&2 "Failed running AppleScript" - hdiutil detach "${DEV_NAME}" + hdiutil_detach_retry "${DEV_NAME}" exit 64 fi echo "Done running the AppleScript..." @@ -416,7 +467,11 @@ echo "Done fixing permissions" # Make the top window open itself on mount: if [[ $BLESS -eq 1 && $SANDBOX_SAFE -eq 0 ]]; then echo "Blessing started" - bless --folder "${MOUNT_DIR}" --openfolder "${MOUNT_DIR}" + if [ $(uname -m) == "arm64" ]; then + bless --folder "${MOUNT_DIR}" + else + bless --folder "${MOUNT_DIR}" --openfolder "${MOUNT_DIR}" + fi echo "Blessing finished" else echo "Skipping blessing on sandbox" @@ -431,23 +486,7 @@ fi echo "Deleting .fseventsd" rm -rf "${MOUNT_DIR}/.fseventsd" || true -# Unmount -unmounting_attempts=0 -until - echo "Unmounting disk image..." - (( unmounting_attempts++ )) - hdiutil detach "${DEV_NAME}" - exit_code=$? - (( exit_code == 0 )) && break # nothing goes wrong - (( exit_code != 16 )) && exit $exit_code # exit with the original exit code - # The above statement returns 1 if test failed (exit_code == 16). - # It can make the code in the {do... done} block to be executed -do - (( unmounting_attempts == MAXIMUM_UNMOUNTING_ATTEMPTS )) && exit 16 # patience exhausted, exit with code EBUSY - echo "Wait a moment..." - sleep $(( 1 * (2 ** unmounting_attempts) )) -done -unset unmounting_attempts +hdiutil_detach_retry "${DEV_NAME}" # Compress image echo "Compressing disk image..." diff --git a/src/create-dmg/doc-project/Developer Notes.md b/src/MacVim/create-dmg/doc-project/Developer Notes.md similarity index 100% rename from src/create-dmg/doc-project/Developer Notes.md rename to src/MacVim/create-dmg/doc-project/Developer Notes.md diff --git a/src/create-dmg/doc-project/Release Checklist.md b/src/MacVim/create-dmg/doc-project/Release Checklist.md similarity index 100% rename from src/create-dmg/doc-project/Release Checklist.md rename to src/MacVim/create-dmg/doc-project/Release Checklist.md diff --git a/src/create-dmg/examples/01-main-example/installer_background.png b/src/MacVim/create-dmg/examples/01-main-example/installer_background.png similarity index 100% rename from src/create-dmg/examples/01-main-example/installer_background.png rename to src/MacVim/create-dmg/examples/01-main-example/installer_background.png diff --git a/src/create-dmg/examples/01-main-example/sample b/src/MacVim/create-dmg/examples/01-main-example/sample similarity index 100% rename from src/create-dmg/examples/01-main-example/sample rename to src/MacVim/create-dmg/examples/01-main-example/sample diff --git a/src/create-dmg/examples/01-main-example/source_folder/Application.app b/src/MacVim/create-dmg/examples/01-main-example/source_folder/Application.app similarity index 100% rename from src/create-dmg/examples/01-main-example/source_folder/Application.app rename to src/MacVim/create-dmg/examples/01-main-example/source_folder/Application.app diff --git a/src/create-dmg/support/eula-resources-template.xml b/src/MacVim/create-dmg/support/eula-resources-template.xml similarity index 100% rename from src/create-dmg/support/eula-resources-template.xml rename to src/MacVim/create-dmg/support/eula-resources-template.xml diff --git a/src/create-dmg/support/template.applescript b/src/MacVim/create-dmg/support/template.applescript similarity index 100% rename from src/create-dmg/support/template.applescript rename to src/MacVim/create-dmg/support/template.applescript diff --git a/src/create-dmg/tests/007-space-in-dir-name/my files/hello.txt b/src/MacVim/create-dmg/tests/007-space-in-dir-name/my files/hello.txt similarity index 100% rename from src/create-dmg/tests/007-space-in-dir-name/my files/hello.txt rename to src/MacVim/create-dmg/tests/007-space-in-dir-name/my files/hello.txt diff --git a/src/create-dmg/tests/007-space-in-dir-name/run-test b/src/MacVim/create-dmg/tests/007-space-in-dir-name/run-test similarity index 100% rename from src/create-dmg/tests/007-space-in-dir-name/run-test rename to src/MacVim/create-dmg/tests/007-space-in-dir-name/run-test diff --git a/src/Makefile b/src/Makefile index 4ee0eed8a9..0ed097fb47 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3633,18 +3633,28 @@ DMGDIR = MacVim/build/dmg DMGFILE = MacVim.dmg ENTITLEMENTS = MacVim/MacVim.entitlements +# APFS is supported in 10.13+, ULFO (LZFSE compression) in 10.11+. +DMGFILESYSTEM = APFS +DMGFORMAT = ULFO + macvim: $(VIMTARGET) xcodebuild -project MacVim/MacVim.xcodeproj $(XCODEFLAGS) macvim-signed: MacVim/scripts/sign-developer-id $(RELEASEDIR)/MacVim.app $(ENTITLEMENTS) +macvim-dmg-legacy: DMGFILESYSTEM = HFS+ +macvim-dmg-legacy: DMGFORMAT = UDZO +macvim-dmg-legacy: macvim-dmg + macvim-dmg: rm -rf $(DMGDIR) mkdir -p $(DMGDIR) cp -a $(RELEASEDIR)/MacVim.app $(DMGDIR)/ rm -rf $(RELEASEDIR)/$(DMGFILE) - create-dmg/create-dmg \ + MacVim/create-dmg/create-dmg \ + --filesystem "$(DMGFILESYSTEM)" \ + --format "$(DMGFORMAT)" \ --volname "MacVim" \ --volicon MacVim/icons/MacVim.icns \ --background MacVim/dmg/background.png \ diff --git a/src/create-dmg/README b/src/create-dmg/README deleted file mode 100644 index bf53c3629c..0000000000 --- a/src/create-dmg/README +++ /dev/null @@ -1 +0,0 @@ -Content of this directory is copied from https://github.com/create-dmg/create-dmg (v1.1.0 / 48a4aadb768da76e7903d090f31a2db20c583942).