macOS: Add /Applications shortcut to generated DMG. (#1206)

* macOS: Add /Applications shortcut to generated DMG.

* Add PR #1206 to changelog.
pull/1208/head
Mooneer Salem 2026-01-31 14:32:00 -08:00 committed by GitHub
parent 5135cd1a8b
commit fe11db9e2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 192 additions and 45 deletions

View File

@ -884,6 +884,7 @@ LDPC | Low Density Parity Check Codes - a family of powerful FEC codes
* FlexRadio: Fix command format for UDP port. (PR #1205; thanks @amcdermond!)
2. Build system:
* macOS: Fix dylibbundler call for compilation. (PR #1204)
* macOS: Add /Applications shortcut to generated DMG. (PR #1206)
## V2.2.0 January 2026

View File

@ -0,0 +1,181 @@
import os.path
import plistlib
#
# Example settings file for dmgbuild
#
# Use like this: dmgbuild -s settings.py "Test Volume" test.dmg
# You can actually use this file for your own application (not just TextEdit)
# by doing e.g.
#
# dmgbuild -s settings.py -D app=/path/to/My.app "My Application" MyApp.dmg
# .. Useful stuff ..............................................................
application = defines.get("app", "src/FreeDV.app") # noqa: F821
appname = os.path.basename(application)
def icon_from_app(app_path):
plist_path = os.path.join(app_path, "Contents", "Info.plist")
with open(plist_path, "rb") as f:
plist = plistlib.load(f)
icon_name = plist["CFBundleIconFile"]
icon_root, icon_ext = os.path.splitext(icon_name)
if not icon_ext:
icon_ext = ".icns"
icon_name = icon_root + icon_ext
return os.path.join(app_path, "Contents", "Resources", icon_name)
# .. Basics ....................................................................
# Uncomment to override the output filename
# filename = 'test.dmg'
# Uncomment to override the output volume name
# volume_name = 'Test'
# Volume format (see hdiutil create -help)
format = defines.get("format", "UDBZ") # noqa: F821
# Compression level (if relevant)
compression_level = 9
# Volume size
size = defines.get("size", None) # noqa: F821
# Files to include
files = [application]
# Symlinks to create
symlinks = {"Applications": "/Applications"}
# Files to hide
# hide = [ 'Secret.data' ]
# Files to hide the extension of
# hide_extension = [ 'README.rst' ]
# Volume icon
#
# You can either define icon, in which case that icon file will be copied to the
# image, *or* you can define badge_icon, in which case the icon file you specify
# will be used to badge the system's Removable Disk icon. Badge icons require
# pyobjc-framework-Quartz.
#
# icon = '/path/to/icon.icns'
badge_icon = icon_from_app(application)
# Where to put the icons
icon_locations = {appname: (140, 120), "Applications": (500, 120)}
# .. Window configuration ......................................................
# Background
#
# This is a STRING containing any of the following:
#
# #3344ff - web-style RGB color
# #34f - web-style RGB color, short form (#34f == #3344ff)
# rgb(1,0,0) - RGB color, each value is between 0 and 1
# hsl(120,1,.5) - HSL (hue saturation lightness) color
# hwb(300,0,0) - HWB (hue whiteness blackness) color
# cmyk(0,1,0,0) - CMYK color
# goldenrod - X11/SVG named color
# builtin-arrow - A simple built-in background with a blue arrow
# /foo/bar/baz.png - The path to an image file
#
# The hue component in hsl() and hwb() may include a unit; it defaults to
# degrees ('deg'), but also supports radians ('rad') and gradians ('grad'
# or 'gon').
#
# Other color components may be expressed either in the range 0 to 1, or
# as percentages (e.g. 60% is equivalent to 0.6).
background = "builtin-arrow"
show_status_bar = False
show_tab_view = False
show_toolbar = False
show_pathbar = False
show_sidebar = False
sidebar_width = 180
# Window position in ((x, y), (w, h)) format
window_rect = ((100, 100), (640, 280))
# Select the default view; must be one of
#
# 'icon-view'
# 'list-view'
# 'column-view'
# 'coverflow'
#
default_view = "icon-view"
# General view configuration
show_icon_preview = False
# Set these to True to force inclusion of icon/list view settings (otherwise
# we only include settings for the default view)
include_icon_view_settings = "auto"
include_list_view_settings = "auto"
# .. Icon view configuration ...................................................
arrange_by = None
grid_offset = (0, 0)
grid_spacing = 100
scroll_position = (0, 0)
label_pos = "bottom" # or 'right'
text_size = 16
icon_size = 128
# .. List view configuration ...................................................
# Column names are as follows:
#
# name
# date-modified
# date-created
# date-added
# date-last-opened
# size
# kind
# label
# version
# comments
#
list_icon_size = 16
list_text_size = 12
list_scroll_position = (0, 0)
list_sort_by = "name"
list_use_relative_dates = True
list_calculate_all_sizes = (False,)
list_columns = ("name", "date-modified", "size", "kind", "date-added")
list_column_widths = {
"name": 300,
"date-modified": 181,
"date-created": 181,
"date-added": 181,
"date-last-opened": 181,
"size": 97,
"kind": 115,
"label": 100,
"version": 75,
"comments": 300,
}
list_column_sort_directions = {
"name": "ascending",
"date-modified": "descending",
"date-created": "descending",
"date-added": "descending",
"date-last-opened": "descending",
"size": "descending",
"kind": "ascending",
"label": "ascending",
"version": "ascending",
"comments": "ascending",
}

View File

@ -1,42 +1,13 @@
#!/bin/sh
SOURCE_FOLDER=$1
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
APP_NAME=$1
# Note: retry logic from https://github.com/darktable-org/darktable/pull/16394/files
# When building on github runner, 'hdiutil create' occasionally fails (resource busy)
# so we make several retries
try_count=0
hdiutil_success=0
while [ $hdiutil_success -ne 1 -a $try_count -lt 8 ]; do
# Create temporary rw image
if hdiutil create -srcfolder $SOURCE_FOLDER/ -volname FreeDV -format UDZO -fs HFS+ ./FreeDV.dmg
then
hdiutil_success=1
break
fi
try_count=$(( $try_count + 1 ))
echo "'hdiutil create' failed (attempt ${try_count}). Retrying..."
sleep 1
done
if [ $hdiutil_success -ne 1 -a -n "${GITHUB_RUN_ID}" ]; then
# Still no success after 8 attempts.
# If we are on github runner, kill the Xprotect service and make one
# final attempt.
# see https://github.com/actions/runner-images/issues/7522
echo "Killing XProtect..."
sudo pkill -9 XProtect >/dev/null || true;
sleep 3
if hdiutil create -srcfolder $SOURCE_FOLDER/ -volname FreeDV -format UDZO -fs HFS+ ./FreeDV.dmg
then
hdiutil_success=1
fi
if [ ! -d dmg-venv ]; then
python3 -m venv dmg-venv
fi
if [ $hdiutil_success -ne 1 ]; then
echo "FATAL: 'hdiutil create' FAILED!"
exit 1
fi
. ./dmg-venv/bin/activate
pip3 install dmgbuild
dmgbuild -s ${SCRIPT_DIR}/dmg_settings.py -D app=$APP_NAME "FreeDV" FreeDV.dmg

View File

@ -180,20 +180,14 @@ if(APPLE)
if (MACOS_CODESIGN_KEYCHAIN_PROFILE)
add_custom_target(release
COMMAND mkdir dist_tmp
COMMAND cp -a FreeDV.app dist_tmp
COMMAND ${CMAKE_SOURCE_DIR}/cmake/macos_build_dmg.sh dist_tmp/
COMMAND rm -rf dist_tmp
COMMAND ${CMAKE_SOURCE_DIR}/cmake/macos_build_dmg.sh ${CMAKE_CURRENT_BINARY_DIR}/FreeDV.app
COMMAND codesign --timestamp -i org.freedv.freedv --sign ${MACOS_CODESIGN_IDENTITY} FreeDV.dmg
COMMAND xcrun notarytool submit ./FreeDV.dmg --keychain-profile ${MACOS_CODESIGN_KEYCHAIN_PROFILE} --wait
COMMAND xcrun stapler staple ./FreeDV.dmg
DEPENDS FreeDV)
else(MACOS_CODESIGN_KEYCHAIN_PROFILE)
add_custom_target(release
COMMAND mkdir dist_tmp
COMMAND cp -a FreeDV.app dist_tmp
COMMAND ${CMAKE_SOURCE_DIR}/cmake/macos_build_dmg.sh dist_tmp/
COMMAND rm -rf dist_tmp
COMMAND ${CMAKE_SOURCE_DIR}/cmake/macos_build_dmg.sh ${CMAKE_CURRENT_BINARY_DIR}/FreeDV.app
DEPENDS FreeDV)
endif (MACOS_CODESIGN_KEYCHAIN_PROFILE)
endif(APPLE)