unifypy 2.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. unifypy/__init__.py +7 -0
  2. unifypy/__main__.py +21 -0
  3. unifypy/cli/__init__.py +10 -0
  4. unifypy/cli/argument_parser.py +209 -0
  5. unifypy/core/__init__.py +8 -0
  6. unifypy/core/config.py +491 -0
  7. unifypy/core/context.py +36 -0
  8. unifypy/core/engine.py +93 -0
  9. unifypy/core/environment.py +509 -0
  10. unifypy/core/event_bus.py +37 -0
  11. unifypy/core/events.py +16 -0
  12. unifypy/core/platforms.py +58 -0
  13. unifypy/core/plugin.py +65 -0
  14. unifypy/core/validators/__init__.py +10 -0
  15. unifypy/core/validators/tool_validator.py +144 -0
  16. unifypy/platforms/__init__.py +10 -0
  17. unifypy/platforms/base.py +127 -0
  18. unifypy/platforms/linux/__init__.py +10 -0
  19. unifypy/platforms/linux/deb_packager.py +289 -0
  20. unifypy/platforms/linux/rpm_packager.py +332 -0
  21. unifypy/platforms/macos/__init__.py +10 -0
  22. unifypy/platforms/macos/dmg_packager.py +477 -0
  23. unifypy/platforms/macos/post_processor.py +272 -0
  24. unifypy/platforms/registry.py +108 -0
  25. unifypy/platforms/windows/__init__.py +9 -0
  26. unifypy/platforms/windows/inno_setup.py +715 -0
  27. unifypy/plugins/__init__.py +3 -0
  28. unifypy/plugins/auto_rollback_plugin.py +156 -0
  29. unifypy/plugins/cleanup_plugin.py +22 -0
  30. unifypy/plugins/config_plugin.py +42 -0
  31. unifypy/plugins/dry_run_plugin.py +22 -0
  32. unifypy/plugins/environment_plugin.py +61 -0
  33. unifypy/plugins/external_plugins_loader.py +42 -0
  34. unifypy/plugins/packaging_plugin.py +125 -0
  35. unifypy/plugins/prepare_plugin.py +89 -0
  36. unifypy/plugins/progress_plugin.py +32 -0
  37. unifypy/plugins/pyinstaller_plugin.py +95 -0
  38. unifypy/plugins/rollback_plugin.py +62 -0
  39. unifypy/plugins/summary_plugin.py +36 -0
  40. unifypy/plugins/windows_language_plugin.py +85 -0
  41. unifypy/pyinstaller/__init__.py +7 -0
  42. unifypy/pyinstaller/config_builder.py +908 -0
  43. unifypy/templates/ChineseSimplified.isl.template +403 -0
  44. unifypy/templates/setup.iss.template +51 -0
  45. unifypy/tools/create-dmg/.this-is-the-create-dmg-repo +3 -0
  46. unifypy/tools/create-dmg/LICENSE +22 -0
  47. unifypy/tools/create-dmg/Makefile +33 -0
  48. unifypy/tools/create-dmg/README.md +126 -0
  49. unifypy/tools/create-dmg/builder/create-dmg.builder +26 -0
  50. unifypy/tools/create-dmg/create-dmg +621 -0
  51. unifypy/tools/create-dmg/doc-project/Developer Notes.md +35 -0
  52. unifypy/tools/create-dmg/doc-project/Release Checklist.md +10 -0
  53. unifypy/tools/create-dmg/examples/01-main-example/installer_background.png +0 -0
  54. unifypy/tools/create-dmg/examples/01-main-example/sample +30 -0
  55. unifypy/tools/create-dmg/examples/01-main-example/source_folder/Application.app +0 -0
  56. unifypy/tools/create-dmg/support/eula-resources-template.xml +105 -0
  57. unifypy/tools/create-dmg/support/template.applescript +74 -0
  58. unifypy/tools/create-dmg/tests/007-space-in-dir-name/my files/hello.txt +1 -0
  59. unifypy/tools/create-dmg/tests/007-space-in-dir-name/run-test +5 -0
  60. unifypy/utils/__init__.py +10 -0
  61. unifypy/utils/cache_manager.py +957 -0
  62. unifypy/utils/command_runner.py +195 -0
  63. unifypy/utils/entitlements_generator.py +450 -0
  64. unifypy/utils/file_ops.py +333 -0
  65. unifypy/utils/icon_converter.py +144 -0
  66. unifypy/utils/info_plist_updater.py +247 -0
  67. unifypy/utils/macos_codesign.py +225 -0
  68. unifypy/utils/parallel_builder.py +355 -0
  69. unifypy/utils/progress.py +371 -0
  70. unifypy/utils/progress_callback_factory.py +56 -0
  71. unifypy/utils/rollback.py +484 -0
  72. unifypy/utils/tool_manager.py +701 -0
  73. unifypy-2.0.2.dist-info/METADATA +609 -0
  74. unifypy-2.0.2.dist-info/RECORD +78 -0
  75. unifypy-2.0.2.dist-info/WHEEL +5 -0
  76. unifypy-2.0.2.dist-info/entry_points.txt +2 -0
  77. unifypy-2.0.2.dist-info/licenses/LICENSE +21 -0
  78. unifypy-2.0.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,621 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Create a read-only disk image of the contents of a folder
4
+
5
+ # Bail out on any unhandled errors
6
+ set -e;
7
+ # Any command that exits with non-zero code will cause the pipeline to fail
8
+ set -o pipefail;
9
+
10
+ CDMG_VERSION='1.2.1'
11
+
12
+ # The full path to the "support/" directory this script is using
13
+ # (This will be set up by code later in the script.)
14
+ CDMG_SUPPORT_DIR=""
15
+
16
+ OS_FULL_VERSION="$(sw_vers | sed -n 2p | cut -d : -f 2 | tr -d '[:space:]' | cut -c1-)"
17
+ OS_MAJOR_VERSION="$(echo $OS_FULL_VERSION | cut -d . -f 1)"
18
+ OS_MINOR_VERSION="$(echo $OS_FULL_VERSION | cut -d . -f 2)"
19
+ WINX=10
20
+ WINY=60
21
+ WINW=500
22
+ WINH=350
23
+ ICON_SIZE=128
24
+ TEXT_SIZE=16
25
+ FORMAT="UDZO"
26
+ FILESYSTEM="HFS+"
27
+ ADD_FILE_SOURCES=()
28
+ ADD_FILE_TARGETS=()
29
+ IMAGEKEY=""
30
+ HDIUTIL_VERBOSITY=""
31
+ SANDBOX_SAFE=0
32
+ BLESS=0
33
+ SKIP_JENKINS=0
34
+ MAXIMUM_UNMOUNTING_ATTEMPTS=3
35
+ SIGNATURE=""
36
+ NOTARIZE=""
37
+
38
+ function pure_version() {
39
+ echo "$CDMG_VERSION"
40
+ }
41
+
42
+ function hdiutil_detach_retry() {
43
+ # Unmount
44
+ unmounting_attempts=0
45
+ until
46
+ echo "Unmounting disk image..."
47
+ (( unmounting_attempts++ ))
48
+ hdiutil detach "$1"
49
+ exit_code=$?
50
+ (( exit_code == 0 )) && break # nothing goes wrong
51
+ (( exit_code != 16 )) && exit $exit_code # exit with the original exit code
52
+ # The above statement returns 1 if test failed (exit_code == 16).
53
+ # It can make the code in the {do... done} block to be executed
54
+ do
55
+ (( unmounting_attempts == MAXIMUM_UNMOUNTING_ATTEMPTS )) && exit 16 # patience exhausted, exit with code EBUSY
56
+ echo "Wait a moment..."
57
+ sleep $(( 1 * (2 ** unmounting_attempts) ))
58
+ done
59
+ unset unmounting_attempts
60
+ }
61
+
62
+ function version() {
63
+ echo "create-dmg $(pure_version)"
64
+ }
65
+
66
+ function usage() {
67
+ version
68
+ cat <<EOHELP
69
+
70
+ Creates a fancy DMG file.
71
+
72
+ Usage: $(basename $0) [options] <output_name.dmg> <source_folder>
73
+
74
+ All contents of <source_folder> will be copied into the disk image.
75
+
76
+ Options:
77
+ --volname <name>
78
+ set volume name (displayed in the Finder sidebar and window title)
79
+ --volicon <icon.icns>
80
+ set volume icon
81
+ --background <pic.png>
82
+ set folder background image (provide png, gif, or jpg)
83
+ --window-pos <x> <y>
84
+ set position the folder window
85
+ --window-size <width> <height>
86
+ set size of the folder window
87
+ --text-size <text_size>
88
+ set window text size (10-16)
89
+ --icon-size <icon_size>
90
+ set window icons size (up to 128)
91
+ --icon file_name <x> <y>
92
+ set position of the file's icon
93
+ --hide-extension <file_name>
94
+ hide the extension of file
95
+ --app-drop-link <x> <y>
96
+ make a drop link to Applications, at location x,y
97
+ --ql-drop-link <x> <y>
98
+ make a drop link to user QuickLook install dir, at location x,y
99
+ --eula <eula_file>
100
+ attach a license file to the dmg (plain text or RTF)
101
+ --no-internet-enable
102
+ disable automatic mount & copy
103
+ --format <format>
104
+ specify the final disk image format (UDZO|UDBZ|ULFO|ULMO) (default is UDZO)
105
+ --filesystem <filesystem>
106
+ specify the disk image filesystem (HFS+|APFS) (default is HFS+, APFS supports macOS 10.13 or newer)
107
+ --encrypt
108
+ enable encryption for the resulting disk image (AES-256 - you will be prompted for password)
109
+ --encrypt-aes128
110
+ enable encryption for the resulting disk image (AES-128 - you will be prompted for password)
111
+ --add-file <target_name> <file>|<folder> <x> <y>
112
+ add additional file or folder (can be used multiple times)
113
+ --disk-image-size <x>
114
+ set the disk image size manually to x MB
115
+ --hdiutil-verbose
116
+ execute hdiutil in verbose mode
117
+ --hdiutil-quiet
118
+ execute hdiutil in quiet mode
119
+ --bless
120
+ bless the mount folder (deprecated, needs macOS 12.2.1 or older)
121
+ --codesign <signature>
122
+ codesign the disk image with the specified signature
123
+ --notarize <credentials>
124
+ notarize the disk image (waits and staples) with the keychain stored credentials
125
+ --sandbox-safe
126
+ execute hdiutil with sandbox compatibility and do not bless (not supported for APFS disk images)
127
+ --version
128
+ show create-dmg version number
129
+ -h, --help
130
+ display this help screen
131
+
132
+ EOHELP
133
+ exit 0
134
+ }
135
+
136
+ # factors can cause interstitial disk images to contain more than a single
137
+ # partition - expand the hunt for the temporary disk image by checking for
138
+ # the path of the volume, versus assuming its the first result (as in pr/152).
139
+ function find_mount_dir() {
140
+ local dev_name="${1}"
141
+
142
+ >&2 echo "Searching for mounted interstitial disk image using ${dev_name}... "
143
+ # enumerate up to 9 partitions
144
+ for i in {1..9}; do
145
+ # attempt to find the partition
146
+ local found_dir
147
+ found_dir=$(hdiutil info | grep -E --color=never "${dev_name}" | head -${i} | awk '{print $3}' | xargs)
148
+ if [[ -n "${found_dir}" ]]; then
149
+ echo "${found_dir}"
150
+ return 0
151
+ fi
152
+ done
153
+ }
154
+
155
+ # Argument parsing
156
+
157
+ while [[ "${1:0:1}" = "-" ]]; do
158
+ case $1 in
159
+ --volname)
160
+ VOLUME_NAME="$2"
161
+ shift; shift;;
162
+ --volicon)
163
+ VOLUME_ICON_FILE="$2"
164
+ shift; shift;;
165
+ --background)
166
+ BACKGROUND_FILE="$2"
167
+ BACKGROUND_FILE_NAME="$(basename "$BACKGROUND_FILE")"
168
+ BACKGROUND_CLAUSE="set background picture of opts to file \".background:$BACKGROUND_FILE_NAME\""
169
+ REPOSITION_HIDDEN_FILES_CLAUSE="set position of every item to {theBottomRightX + 100, 100}"
170
+ shift; shift;;
171
+ --icon-size)
172
+ ICON_SIZE="$2"
173
+ shift; shift;;
174
+ --text-size)
175
+ TEXT_SIZE="$2"
176
+ shift; shift;;
177
+ --window-pos)
178
+ WINX=$2; WINY=$3
179
+ shift; shift; shift;;
180
+ --window-size)
181
+ WINW=$2; WINH=$3
182
+ shift; shift; shift;;
183
+ --icon)
184
+ POSITION_CLAUSE="${POSITION_CLAUSE}set position of item \"$2\" to {$3, $4}
185
+ "
186
+ shift; shift; shift; shift;;
187
+ --hide-extension)
188
+ HIDING_CLAUSE="${HIDING_CLAUSE}set the extension hidden of item \"$2\" to true
189
+ "
190
+ shift; shift;;
191
+ -h | --help)
192
+ usage;;
193
+ --version)
194
+ version; exit 0;;
195
+ --pure-version)
196
+ pure_version; exit 0;;
197
+ --ql-drop-link)
198
+ QL_LINK=$2
199
+ QL_CLAUSE="set position of item \"QuickLook\" to {$2, $3}
200
+ "
201
+ shift; shift; shift;;
202
+ --app-drop-link)
203
+ APPLICATION_LINK=$2
204
+ APPLICATION_CLAUSE="set position of item \"Applications\" to {$2, $3}
205
+ "
206
+ shift; shift; shift;;
207
+ --eula)
208
+ EULA_RSRC=$2
209
+ shift; shift;;
210
+ --no-internet-enable)
211
+ NOINTERNET=1
212
+ shift;;
213
+ --format)
214
+ FORMAT="$2"
215
+ shift; shift;;
216
+ --filesystem)
217
+ FILESYSTEM="$2"
218
+ shift; shift;;
219
+ --encrypt)
220
+ ENABLE_ENCRYPTION=1
221
+ AESBITS=256
222
+ shift;;
223
+ --encrypt-aes128)
224
+ ENABLE_ENCRYPTION=1
225
+ AESBITS=128
226
+ shift;;
227
+ --add-file | --add-folder)
228
+ ADD_FILE_TARGETS+=("$2")
229
+ ADD_FILE_SOURCES+=("$3")
230
+ POSITION_CLAUSE="${POSITION_CLAUSE}
231
+ set position of item \"$2\" to {$4, $5}
232
+ "
233
+ shift; shift; shift; shift; shift;;
234
+ --disk-image-size)
235
+ DISK_IMAGE_SIZE="$2"
236
+ shift; shift;;
237
+ --hdiutil-verbose)
238
+ HDIUTIL_VERBOSITY='-verbose'
239
+ shift;;
240
+ --hdiutil-quiet)
241
+ HDIUTIL_VERBOSITY='-quiet'
242
+ shift;;
243
+ --codesign)
244
+ SIGNATURE="$2"
245
+ shift; shift;;
246
+ --notarize)
247
+ NOTARIZE="$2"
248
+ shift; shift;;
249
+ --sandbox-safe)
250
+ SANDBOX_SAFE=1
251
+ shift;;
252
+ --bless)
253
+ BLESS=1
254
+ shift;;
255
+ --rez)
256
+ echo "REZ is no more directly used. You can remove the --rez argument."
257
+ shift; shift;;
258
+ --skip-jenkins)
259
+ SKIP_JENKINS=1
260
+ shift;;
261
+ -*)
262
+ echo "Unknown option: $1. Run 'create-dmg --help' for help."
263
+ exit 1;;
264
+ esac
265
+ case $FORMAT in
266
+ UDZO)
267
+ IMAGEKEY="-imagekey zlib-level=9";;
268
+ UDBZ)
269
+ IMAGEKEY="-imagekey bzip2-level=9";;
270
+ ULFO)
271
+ ;;
272
+ ULMO)
273
+ ;;
274
+ *)
275
+ echo >&2 "Unknown disk image format: $FORMAT"
276
+ exit 1;;
277
+ esac
278
+ done
279
+
280
+ if [[ -z "$2" ]]; then
281
+ echo "Not enough arguments. Run 'create-dmg --help' for help."
282
+ exit 1
283
+ fi
284
+
285
+ DMG_PATH="$1"
286
+ SRC_FOLDER="$(cd "$2" > /dev/null; pwd)"
287
+
288
+ # Argument validation checks
289
+
290
+ if [[ "${DMG_PATH: -4}" != ".dmg" ]]; then
291
+ echo "Output file name must end with a .dmg extension. Run 'create-dmg --help' for help."
292
+ exit 1
293
+ fi
294
+
295
+ if [[ "${FILESYSTEM}" != "HFS+" ]] && [[ "${FILESYSTEM}" != "APFS" ]]; then
296
+ echo "Unknown disk image filesystem: ${FILESYSTEM}. Run 'create-dmg --help' for help."
297
+ exit 1
298
+ fi
299
+
300
+ if [[ "${FILESYSTEM}" == "APFS" ]] && [[ ${SANDBOX_SAFE} -eq 1 ]]; then
301
+ echo "Creating an APFS disk image that is sandbox safe is not supported."
302
+ exit 1
303
+ fi
304
+
305
+ # Main script logic
306
+
307
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
308
+ DMG_DIRNAME="$(dirname "$DMG_PATH")"
309
+ DMG_DIR="$(cd "$DMG_DIRNAME" > /dev/null; pwd)"
310
+ DMG_NAME="$(basename "$DMG_PATH")"
311
+ DMG_TEMP_NAME="$DMG_DIR/rw.$$.${DMG_NAME}"
312
+
313
+ # Detect where we're running from
314
+
315
+ sentinel_file="$SCRIPT_DIR/.this-is-the-create-dmg-repo"
316
+ if [[ -f "$sentinel_file" ]]; then
317
+ # We're running from inside a repo
318
+ CDMG_SUPPORT_DIR="$SCRIPT_DIR/support"
319
+ else
320
+ # We're running inside an installed location
321
+ bin_dir="$SCRIPT_DIR"
322
+ prefix_dir=$(dirname "$bin_dir")
323
+ CDMG_SUPPORT_DIR="$prefix_dir/share/create-dmg/support"
324
+ fi
325
+
326
+ if [[ -z "$VOLUME_NAME" ]]; then
327
+ VOLUME_NAME="$(basename "$DMG_PATH" .dmg)"
328
+ fi
329
+
330
+ if [[ ! -d "$CDMG_SUPPORT_DIR" ]]; then
331
+ echo >&2 "Cannot find support/ directory: expected at: $CDMG_SUPPORT_DIR"
332
+ exit 1
333
+ fi
334
+
335
+ if [[ -f "$SRC_FOLDER/.DS_Store" ]]; then
336
+ echo "Deleting .DS_Store found in source folder"
337
+ rm "$SRC_FOLDER/.DS_Store"
338
+ fi
339
+
340
+ # Create the image
341
+ echo "Creating disk image..."
342
+ if [[ -f "${DMG_TEMP_NAME}" ]]; then
343
+ rm -f "${DMG_TEMP_NAME}"
344
+ fi
345
+
346
+ # Use Megabytes since hdiutil fails with very large byte numbers
347
+ function blocks_to_megabytes() {
348
+ # Add 1 extra MB, since there's no decimal retention here
349
+ MB_SIZE=$((($1 * 512 / 1000 / 1000) + 1))
350
+ echo $MB_SIZE
351
+ }
352
+
353
+ function get_size() {
354
+ # Get block size in disk
355
+ if [[ $OS_MAJOR_VERSION -ge 12 ]]; then
356
+ bytes_size=$(du -B 512 -s "$1")
357
+ else
358
+ bytes_size=$(du -s "$1")
359
+ fi
360
+ bytes_size=$(echo $bytes_size | sed -e 's/ .*//g')
361
+ echo $(blocks_to_megabytes $bytes_size)
362
+ }
363
+
364
+ # Create the DMG with the specified size or the hdiutil estimation
365
+ CUSTOM_SIZE=''
366
+ if [[ -n "$DISK_IMAGE_SIZE" ]]; then
367
+ CUSTOM_SIZE="-size ${DISK_IMAGE_SIZE}m"
368
+ fi
369
+
370
+ if [[ $SANDBOX_SAFE -eq 0 ]]; then
371
+ if [[ "$FILESYSTEM" == "APFS" ]]; then
372
+ FILESYSTEM_ARGUMENTS=""
373
+ else
374
+ FILESYSTEM_ARGUMENTS="-c c=64,a=16,e=16"
375
+ fi
376
+ hdiutil create ${HDIUTIL_VERBOSITY} -srcfolder "$SRC_FOLDER" -volname "${VOLUME_NAME}" \
377
+ -fs "${FILESYSTEM}" -fsargs "${FILESYSTEM_ARGUMENTS}" -format UDRW ${CUSTOM_SIZE} "${DMG_TEMP_NAME}"
378
+ else
379
+ hdiutil makehybrid ${HDIUTIL_VERBOSITY} -default-volume-name "${VOLUME_NAME}" -hfs -o "${DMG_TEMP_NAME}" "$SRC_FOLDER"
380
+ hdiutil convert -format UDRW -ov -o "${DMG_TEMP_NAME}" "${DMG_TEMP_NAME}"
381
+ DISK_IMAGE_SIZE_CUSTOM=$DISK_IMAGE_SIZE
382
+ fi
383
+
384
+ # Get the created DMG actual size
385
+ DISK_IMAGE_SIZE=$(get_size "${DMG_TEMP_NAME}")
386
+
387
+ # Use the custom size if bigger
388
+ if [[ $SANDBOX_SAFE -eq 1 ]] && [[ ! -z "$DISK_IMAGE_SIZE_CUSTOM" ]] && [[ $DISK_IMAGE_SIZE_CUSTOM -gt $DISK_IMAGE_SIZE ]]; then
389
+ DISK_IMAGE_SIZE=$DISK_IMAGE_SIZE_CUSTOM
390
+ fi
391
+
392
+ # Estimate the additional sources size
393
+ if [[ -n "$ADD_FILE_SOURCES" ]]; then
394
+ for i in "${!ADD_FILE_SOURCES[@]}"; do
395
+ SOURCE_SIZE=$(get_size "${ADD_FILE_SOURCES[$i]}")
396
+ DISK_IMAGE_SIZE=$(expr $DISK_IMAGE_SIZE + $SOURCE_SIZE)
397
+ done
398
+ fi
399
+
400
+ # Add extra space for additional resources
401
+ DISK_IMAGE_SIZE=$(expr $DISK_IMAGE_SIZE + 20)
402
+
403
+ # Make sure target image size is within limits
404
+ MIN_DISK_IMAGE_SIZE=$(hdiutil resize -limits "${DMG_TEMP_NAME}" | awk 'NR=1{print int($1/2048+1)}')
405
+ if [ $MIN_DISK_IMAGE_SIZE -gt $DISK_IMAGE_SIZE ]; then
406
+ DISK_IMAGE_SIZE=$MIN_DISK_IMAGE_SIZE
407
+ fi
408
+
409
+ # Resize the image for the extra stuff
410
+ hdiutil resize ${HDIUTIL_VERBOSITY} -size ${DISK_IMAGE_SIZE}m "${DMG_TEMP_NAME}"
411
+
412
+ # Mount the new DMG
413
+
414
+ echo "Mounting disk image..."
415
+
416
+ MOUNT_RANDOM_PATH="/Volumes"
417
+ if [[ $SANDBOX_SAFE -eq 1 ]]; then
418
+ MOUNT_RANDOM_PATH="/tmp"
419
+ fi
420
+ if [[ "$FILESYSTEM" == "APFS" ]]; then
421
+ HDIUTIL_FILTER="tail -n 1"
422
+ else
423
+ HDIUTIL_FILTER="sed 1q"
424
+ fi
425
+ DEV_NAME=$(hdiutil attach -mountrandom ${MOUNT_RANDOM_PATH} -readwrite -noverify -noautoopen -nobrowse "${DMG_TEMP_NAME}" | grep -E --color=never '^/dev/' | ${HDIUTIL_FILTER} | awk '{print $1}')
426
+ echo "Device name: $DEV_NAME"
427
+ if [[ "$FILESYSTEM" == "APFS" ]]; then
428
+ MOUNT_DIR=$(find_mount_dir "${DEV_NAME}")
429
+ else
430
+ MOUNT_DIR=$(find_mount_dir "${DEV_NAME}s")
431
+ fi
432
+ if [[ -z "${MOUNT_DIR}" ]]; then
433
+ >&2 echo "ERROR: unable to proceed with final disk image creation because the interstitial disk image was not found."
434
+ >&2 echo "The interstitial disk image will likely be mounted and will need to be cleaned up manually."
435
+ exit 1
436
+ fi
437
+
438
+ echo "Mount dir: $MOUNT_DIR"
439
+
440
+ if [[ -n "$BACKGROUND_FILE" ]]; then
441
+ echo "Copying background file '$BACKGROUND_FILE'..."
442
+ [[ -d "$MOUNT_DIR/.background" ]] || mkdir "$MOUNT_DIR/.background"
443
+ cp "$BACKGROUND_FILE" "$MOUNT_DIR/.background/$BACKGROUND_FILE_NAME"
444
+ fi
445
+
446
+ if [[ -n "$APPLICATION_LINK" ]]; then
447
+ echo "Making link to Applications dir..."
448
+ echo $MOUNT_DIR
449
+ ln -s /Applications "$MOUNT_DIR/Applications"
450
+ fi
451
+
452
+ if [[ -n "$QL_LINK" ]]; then
453
+ echo "Making link to QuickLook install dir..."
454
+ echo $MOUNT_DIR
455
+ ln -s "/Library/QuickLook" "$MOUNT_DIR/QuickLook"
456
+ fi
457
+
458
+ if [[ -n "$VOLUME_ICON_FILE" ]]; then
459
+ echo "Copying volume icon file '$VOLUME_ICON_FILE'..."
460
+ cp "$VOLUME_ICON_FILE" "$MOUNT_DIR/.VolumeIcon.icns"
461
+ SetFile -c icnC "$MOUNT_DIR/.VolumeIcon.icns"
462
+ fi
463
+
464
+ if [[ -n "$ADD_FILE_SOURCES" ]]; then
465
+ echo "Copying custom files..."
466
+ for i in "${!ADD_FILE_SOURCES[@]}"; do
467
+ echo "${ADD_FILE_SOURCES[$i]}"
468
+ cp -a "${ADD_FILE_SOURCES[$i]}" "$MOUNT_DIR/${ADD_FILE_TARGETS[$i]}"
469
+ done
470
+ fi
471
+
472
+ VOLUME_NAME=$(basename $MOUNT_DIR)
473
+
474
+ # Run AppleScript to do all the Finder cosmetic stuff
475
+ APPLESCRIPT_FILE=$(mktemp -t createdmg.tmp.XXXXXXXXXX)
476
+ if [[ $SANDBOX_SAFE -eq 1 ]]; then
477
+ echo "Skipping Finder-prettifying AppleScript because we are in Sandbox..."
478
+ else
479
+ if [[ $SKIP_JENKINS -eq 0 ]]; then
480
+ cat "$CDMG_SUPPORT_DIR/template.applescript" \
481
+ | sed -e "s/WINX/$WINX/g" -e "s/WINY/$WINY/g" -e "s/WINW/$WINW/g" \
482
+ -e "s/WINH/$WINH/g" -e "s/BACKGROUND_CLAUSE/$BACKGROUND_CLAUSE/g" \
483
+ -e "s/REPOSITION_HIDDEN_FILES_CLAUSE/$REPOSITION_HIDDEN_FILES_CLAUSE/g" \
484
+ -e "s/ICON_SIZE/$ICON_SIZE/g" -e "s/TEXT_SIZE/$TEXT_SIZE/g" \
485
+ | perl -pe "s/POSITION_CLAUSE/$POSITION_CLAUSE/g" \
486
+ | perl -pe "s/QL_CLAUSE/$QL_CLAUSE/g" \
487
+ | perl -pe "s/APPLICATION_CLAUSE/$APPLICATION_CLAUSE/g" \
488
+ | perl -pe "s/HIDING_CLAUSE/$HIDING_CLAUSE/" \
489
+ > "$APPLESCRIPT_FILE"
490
+ sleep 2 # pause to workaround occasional "Can’t get disk" (-1728) issues
491
+ echo "Running AppleScript to make Finder stuff pretty: /usr/bin/osascript \"${APPLESCRIPT_FILE}\" \"${VOLUME_NAME}\""
492
+ if /usr/bin/osascript "${APPLESCRIPT_FILE}" "${VOLUME_NAME}"; then
493
+ # Okay, we're cool
494
+ true
495
+ else
496
+ echo >&2 "Failed running AppleScript"
497
+ hdiutil_detach_retry "${DEV_NAME}"
498
+ exit 64
499
+ fi
500
+ echo "Done running the AppleScript..."
501
+ sleep 4
502
+ rm "$APPLESCRIPT_FILE"
503
+ fi
504
+ fi
505
+
506
+ # Make sure it's not world writeable
507
+ echo "Fixing permissions..."
508
+ chmod -Rf go-w "${MOUNT_DIR}" &> /dev/null || true
509
+ echo "Done fixing permissions"
510
+
511
+ # Make the top window open itself on mount:
512
+ if [[ $BLESS -eq 1 && $SANDBOX_SAFE -eq 0 ]]; then
513
+ echo "Blessing started"
514
+ if [ $(uname -m) == "arm64" ]; then
515
+ bless --folder "${MOUNT_DIR}"
516
+ else
517
+ bless --folder "${MOUNT_DIR}" --openfolder "${MOUNT_DIR}"
518
+ fi
519
+ echo "Blessing finished"
520
+ else
521
+ echo "Skipping blessing on sandbox"
522
+ fi
523
+
524
+ if [[ -n "$VOLUME_ICON_FILE" ]]; then
525
+ # Tell the volume that it has a special file attribute
526
+ SetFile -a C "$MOUNT_DIR"
527
+ fi
528
+
529
+ # Delete unnecessary file system events log if possible
530
+ echo "Deleting .fseventsd"
531
+ rm -rf "${MOUNT_DIR}/.fseventsd" || true
532
+
533
+ hdiutil_detach_retry "${DEV_NAME}"
534
+
535
+ # Compress image and optionally encrypt
536
+ if [[ $ENABLE_ENCRYPTION -eq 0 ]]; then
537
+ echo "Compressing disk image..."
538
+ hdiutil convert ${HDIUTIL_VERBOSITY} "${DMG_TEMP_NAME}" -format ${FORMAT} ${IMAGEKEY} -o "${DMG_DIR}/${DMG_NAME}"
539
+ else
540
+ echo "Compressing and encrypting disk image..."
541
+ echo "NOTE: hdiutil will only prompt a single time for a password - ensure entry is correct."
542
+ hdiutil convert ${HDIUTIL_VERBOSITY} "${DMG_TEMP_NAME}" -format ${FORMAT} ${IMAGEKEY} -encryption AES-${AESBITS} -stdinpass -o "${DMG_DIR}/${DMG_NAME}"
543
+ fi
544
+ rm -f "${DMG_TEMP_NAME}"
545
+
546
+ # Adding EULA resources
547
+ if [[ -n "${EULA_RSRC}" && "${EULA_RSRC}" != "-null-" ]]; then
548
+ echo "Adding EULA resources..."
549
+ #
550
+ # Use udifrez instead flatten/rez/unflatten
551
+ # https://github.com/create-dmg/create-dmg/issues/109
552
+ #
553
+ # Based on a thread from dawn2dusk & peterguy
554
+ # https://developer.apple.com/forums/thread/668084
555
+ #
556
+ EULA_RESOURCES_FILE=$(mktemp -t createdmg.tmp.XXXXXXXXXX)
557
+ EULA_FORMAT=$(file -b ${EULA_RSRC})
558
+ if [[ ${EULA_FORMAT} == 'Rich Text Format data'* ]] ; then
559
+ EULA_FORMAT='RTF '
560
+ else
561
+ EULA_FORMAT='TEXT'
562
+ fi
563
+ # Encode the EULA to base64
564
+ # Replace 'openssl base64' with 'base64' if Mac OS X 10.6 support is no more needed
565
+ # EULA_DATA="$(base64 -b 52 "${EULA_RSRC}" | sed s$'/^\(.*\)$/\t\t\t\\1/')"
566
+ EULA_DATA="$(openssl base64 -in "${EULA_RSRC}" | tr -d '\n' | awk '{gsub(/.{52}/,"&\n")}1' | sed s$'/^\(.*\)$/\t\t\t\\1/')"
567
+ # Fill the template with the custom EULA contents
568
+ eval "cat > \"${EULA_RESOURCES_FILE}\" <<EOF
569
+ $(<${CDMG_SUPPORT_DIR}/eula-resources-template.xml)
570
+ EOF
571
+ "
572
+ # Apply the resources
573
+ hdiutil udifrez -xml "${EULA_RESOURCES_FILE}" '' -quiet "${DMG_DIR}/${DMG_NAME}" || {
574
+ echo "Failed to add the EULA license"
575
+ exit 1
576
+ }
577
+ echo "Successfully added the EULA license"
578
+ fi
579
+
580
+ # Enable "internet", whatever that is
581
+ if [[ ! -z "${NOINTERNET}" && "${NOINTERNET}" == 1 ]]; then
582
+ echo "Not setting 'internet-enable' on the dmg, per caller request"
583
+ else
584
+ # Check if hdiutil supports internet-enable
585
+ # Support was removed in macOS 10.15. See https://github.com/andreyvit/create-dmg/issues/76
586
+ if hdiutil internet-enable -help >/dev/null 2>/dev/null; then
587
+ hdiutil internet-enable -yes "${DMG_DIR}/${DMG_NAME}"
588
+ else
589
+ echo "hdiutil does not support internet-enable. Note it was removed in macOS 10.15."
590
+ fi
591
+ fi
592
+
593
+ if [[ -n "${SIGNATURE}" && "${SIGNATURE}" != "-null-" ]]; then
594
+ echo "Codesign started"
595
+ codesign -s "${SIGNATURE}" "${DMG_DIR}/${DMG_NAME}"
596
+ dmgsignaturecheck="$(codesign --verify --deep --verbose=2 --strict "${DMG_DIR}/${DMG_NAME}" 2>&1 >/dev/null)"
597
+ if [ $? -eq 0 ]; then
598
+ echo "The disk image is now codesigned"
599
+ else
600
+ echo "The signature seems invalid${NC}"
601
+ exit 1
602
+ fi
603
+ fi
604
+
605
+ if [[ -n "${NOTARIZE}" && "${NOTARIZE}" != "-null-" ]]; then
606
+ echo "Notarization started"
607
+ xcrun notarytool submit "${DMG_DIR}/${DMG_NAME}" --keychain-profile "${NOTARIZE}" --wait
608
+ echo "Stapling the notarization ticket"
609
+ staple="$(xcrun stapler staple "${DMG_DIR}/${DMG_NAME}")"
610
+ if [ $? -eq 0 ]; then
611
+ echo "The disk image is now notarized"
612
+ else
613
+ echo "$staple"
614
+ echo "The notarization failed with error $?"
615
+ exit 1
616
+ fi
617
+ fi
618
+
619
+ # All done!
620
+ echo "Disk image done"
621
+ exit 0
@@ -0,0 +1,35 @@
1
+ # create-dmg Developer Notes
2
+
3
+ ## Repo layout
4
+
5
+ - `create-dmg` in the root of the repo is the main program
6
+ - `support/` contains auxiliary scripts used by `create-dmg`; it must be at that relative position to `create-dmg`
7
+ - `builder/` contains ????
8
+ - `examples/` contains user-facing examples
9
+ - `tests/` contains regression tests for developers
10
+ - `doc-project/` contains developer-facing documentation about this project
11
+
12
+ ### tests/
13
+
14
+ The `tests/` folder contains regression tests for developers.
15
+
16
+ Each test is in its own subfolder.
17
+ Each subfolder name should start with a 3-digit number that is the number of the corresponding bug report in create-dmg's GitHub issue tracker.
18
+
19
+ The tests are to be run manually, with the results examined manually.
20
+ There's no automated script to run them as a suite and check their results.
21
+ That might be nice to have.
22
+
23
+ ### examples/
24
+
25
+ Each example is in its own subfolder.
26
+ The subfolder prefix number is arbitrary; these numbers should roughly be in order of "advancedness" of examples, so it makes sense for users to go through them in order.
27
+
28
+ ## Versioning
29
+
30
+ As of May 2020, we're using SemVer versioning.
31
+ The old version numbers were 4-parters, like "1.0.0.7".
32
+ Now we use 3-part SemVer versions, like "1.0.8".
33
+ This change happened after version 1.0.0.7; 1.0.8 is the next release after 1.0.0.7.
34
+
35
+ The suffix "-SNAPSHOT" is used to denote a version that is still under development.
@@ -0,0 +1,10 @@
1
+ # Release Checklist
2
+
3
+ - Update the version in `create-dmg`'s `pure_version` function
4
+ - Remove the "-SNAPSHOT" suffix
5
+ - Commit
6
+ - Tag the release as `vX.X.X`
7
+ - `git push --tags`
8
+ - Create a release on the GitHub project page
9
+ - Open development on the next release
10
+ - Bump the version number and add a "-SNAPSHOT" suffix to it
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env bash
2
+
3
+ APP_NAME="Application"
4
+ DMG_FILE_NAME="${APP_NAME}-Installer.dmg"
5
+ VOLUME_NAME="${APP_NAME} Installer"
6
+ SOURCE_FOLDER_PATH="source_folder/"
7
+
8
+ if [[ -e ../../create-dmg ]]; then
9
+ # We're running from the repo
10
+ CREATE_DMG=../../create-dmg
11
+ else
12
+ # We're running from an installation under a prefix
13
+ CREATE_DMG=../../../../bin/create-dmg
14
+ fi
15
+
16
+ # Since create-dmg does not clobber, be sure to delete previous DMG
17
+ [[ -f "${DMG_FILE_NAME}" ]] && rm "${DMG_FILE_NAME}"
18
+
19
+ # Create the DMG
20
+ $CREATE_DMG \
21
+ --volname "${VOLUME_NAME}" \
22
+ --background "installer_background.png" \
23
+ --window-pos 200 120 \
24
+ --window-size 800 400 \
25
+ --icon-size 100 \
26
+ --icon "${APP_NAME}.app" 200 190 \
27
+ --hide-extension "${APP_NAME}.app" \
28
+ --app-drop-link 600 185 \
29
+ "${DMG_FILE_NAME}" \
30
+ "${SOURCE_FOLDER_PATH}"