aboutsummaryrefslogtreecommitdiffstats
path: root/packaging/macosx/osx-dmg.sh.in
blob: c81cc37d629a83ada8676070ecc3a35f0f13e414 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
#
# The script creates a disk image using the dmgbuild utility and signs it.

set -e

# Defaults
app_name="Wireshark"
dmgbuild="@DMGBUILD_EXECUTABLE@"
version="@PROJECT_VERSION@"
log_version="@LOG_PROJECT_VERSION@"
app_settings_file="@CMAKE_BINARY_DIR@/packaging/macosx/wireshark-app.dmgbuild"
dsym_settings_file="@CMAKE_BINARY_DIR@/packaging/macosx/wireshark-dsym.dmgbuild"
architecture=""

# Help message
#----------------------------------------------------------
help()
{
echo -e "
Create a custom dmg file to distribute Wireshark

USAGE
	$0

OPTIONS
	-h,--help
		Display this help message.

Icons are positioned and the background image is set in wireshark-app.dmgbuild.in
and wireshark-dsym.dmgbuild.in.
"
}

if [ ! -x "$dmgbuild" ] ; then
	echo "Error: \"$dmgbuild\" not found."
	exit 1
fi

# Parse command line arguments
while [ "$1" != "" ]
do
	case $1 in
		-a|--app-name)
			shift 1
			app_name="$1"
			;;
		-h|--help)
			help
			exit 0 ;;
		*)
			echo "Invalid command line option"
			exit 2 ;;
	esac
	shift 1
done

if lipo "$app_name.app/Contents/MacOS/$app_name" -verify_arch arm64 ; then
	architecture="Arm 64"
elif lipo "$app_name.app/Contents/MacOS/$app_name" -verify_arch x86_64 ; then
	architecture="Intel 64"
else
	echo "Error: $app_name.app missing or has unknown architecture."
	lipo "$app_name.app/Contents/MacOS/$app_name" -detailed_info
	exit 1
fi

if [[ $app_name = Log* ]] ; then
	version=$log_version
	app_settings_file="@CMAKE_BINARY_DIR@/packaging/macosx/logwolf-app.dmgbuild"
	dsym_settings_file="@CMAKE_BINARY_DIR@/packaging/macosx/logwolf-dsym.dmgbuild"
fi

app_vol_name="$app_name ${version}"
app_img_name="$app_vol_name $architecture.dmg"

printf "\nCreating application disk image %s\n" "$app_img_name"

"$dmgbuild" \
	--no-hidpi \
	-s "$app_settings_file" \
	"$app_vol_name" \
	"$app_img_name" || exit 1

dsym_vol_name="$app_name dSYM ${version}"
dsym_img_name="$dsym_vol_name $architecture.dmg"

printf "\nCreating debugging symbols disk image %s\n" "$dsym_img_name"

"$dmgbuild" \
	--no-hidpi \
	-s "$dsym_settings_file" \
	"$dsym_vol_name" \
	"$dsym_img_name" || exit 1

printf "\nSigning disk images\n"

# TN2206, "Signing Disk Images"
if [ -n "$CODE_SIGN_IDENTITY" ] ; then
	echo -e "Signing $app_img_name and $dsym_img_name"
	codesign \
		--sign "Developer ID Application: $CODE_SIGN_IDENTITY" \
		--timestamp \
		--verbose \
		"$app_img_name" "$dsym_img_name"
fi

exit 0