3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 # Use of unset variable is an error
15 # If any part of a pipeline of commands fails, the whole pipeline fails
18 if [ `uname` != Darwin
]; then
19 echo This is
for macOS only
>&2
24 echo Usage
: $0 signed-app-bundle
type
25 echo " where type is 'release', 'dev', or 'collabora'"
29 if [ ! -d "$1" ]; then
30 echo No such directory
: $1 >&2
34 if [[ "$1" != *.app
]]; then
35 echo "signed-app-bundle argument $1 does not end with .app" >&2
41 if [ "$2" = "release" ];then
43 elif [ "$2" = "dev" ];then
44 DSSTOREFILE
=DS_Store_Dev
45 elif [ "$2" = "collabora" ];then
47 # Collabora is not currently using a volume icon
50 echo "type argument $2 is not equal to 'release', 'dev', or 'collabora'" >&2
54 IN
=$
(cd "$1" && /bin
/pwd)
55 INAPP
=$
(basename "$IN")
56 INDIR
=$
(dirname "$IN")
57 OUTVOLUME
=$
(basename "$IN" .app
)
58 OUTVOLUMEMOUNT
=/Volumes
/"$OUTVOLUME"
59 OUTTMPDIR
=$
(dirname "$IN")/"$OUTVOLUME"
60 OUTFILE
="$OUTTMPDIR".dmg
61 OUTFILETMP
="$OUTTMPDIR".tmp.dmg
62 SRCDIR
=$
(cd `dirname "$0"`/..
&& /bin
/pwd)
64 # Create $OUTTMPDIR directory in the same directory as the output .dmg and
67 if [ -f "$OUTFILE" ]; then
68 echo The
file $OUTFILE exists already
>&2
72 if [ -d "$OUTFILE" ]; then
73 echo $OUTFILE exists and is a directory
>&2
77 if [ -f "$OUTFILETMP" ]; then
78 echo The
file $OUTFILETMP exists already
>&2
82 if [ -d "$OUTFILETMP" ]; then
83 echo $OUTFILETMP exists and is a directory
>&2
87 if [ -d "$OUTTMPDIR" ]; then
88 echo The directory
$OUTTMPDIR exists already
>&2
92 if [ -f "$OUTTMPDIR" ]; then
93 echo $OUTTMPDIR exists and is a
file >&2
97 if [ -d "$OUTVOLUMEMOUNT" ]; then
98 echo The directory
$OUTVOLUMEMOUNT exists already
>&2
102 if [ -f "$OUTVOLUMEMOUNT" ]; then
103 echo $OUTVOLUMEMOUNT exists and is a
file >&2
108 mkdir
"$OUTTMPDIR"/.background
109 tar cf
- "$INAPP" -C "$INDIR" |
tar xvpf
- -C "$OUTTMPDIR"
110 ln -s /Applications
"$OUTTMPDIR"/Applications
111 cp "$SRCDIR"/setup_native
/source
/packinfo
/DS_Store
"$OUTTMPDIR"/.DS_Store
112 if [ ! -z "$VOLUMEICON" ]; then
113 cp "$SRCDIR"/sysui
/desktop
/icons
/"$VOLUMEICON" "$OUTTMPDIR"/.VolumeIcon.icns
115 cp "$SRCDIR"/setup_native
/source
/packinfo
/osxdndinstall.png
"$OUTTMPDIR"/.background
/background.png
117 # Create and mount empty .dmg
121 if [ -z "$VOLUMEICON" ]; then
122 # Copied and adapted to bash from solenv/bin/modules/installer/simplepackage.pm
123 # tdf#151341 Use lzfse compression instead of bzip2
124 hdiutil create
-srcfolder "$OUTTMPDIR" "$OUTFILE" -ov -fs HFS
+ -volname "$OUTVOLUME" -format ULFO
126 # To set a volume icon, we need to create a writable .dmg, mount it, set the
127 # volume icon, unmount it, and then convert it to a read-only .dmg
128 hdiutil create
-srcfolder "$OUTTMPDIR" "$OUTFILETMP" -ov -fs HFS
+ -volname "$OUTVOLUME" -format UDRW
130 hdiutil attach
"$OUTFILETMP"
131 if [ -f "$OUTVOLUMEMOUNT"/.VolumeIcon.icns
]; then
132 # TODO: SetFile is deprecated so we will eventually need to find another
133 # way to set the volume icon or stop trying to set the volume icon
134 SetFile
-a C
"$OUTVOLUMEMOUNT"
136 hdiutil detach
"$OUTVOLUMEMOUNT"
138 hdiutil convert
"$OUTFILETMP" -format ULFO
-o "$OUTFILE"
143 # Print warning about notarization
144 echo "Successfully created '$OUTFILE'"
146 echo "Warning: the .dmg is NOT notarized!"
148 echo "You can manually notarize the .dmg using the following commands:"
149 echo " xcrun notarytool submit '$OUTFILE' ... [--wait]"
150 echo " xcrun stapler staple '$OUTFILE'"
151 echo " xcrun stapler validate '$OUTFILE'"