Use #REF! error in INDEX()
[LibreOffice.git] / bin / create-dmg-from-merged-app-bundle
blob483b1298d7c9fe6419e41302afece36d66c7b87d
1 #!/usr/bin/env bash
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/.
9 # Exit on errors
10 set -e
12 # Use of unset variable is an error
13 set -u
15 # If any part of a pipeline of commands fails, the whole pipeline fails
16 set -o pipefail
18 if [ `uname` != Darwin ]; then
19 echo This is for macOS only >&2
20 exit 1
23 if [ $# != 2 ]; then
24 echo Usage: $0 signed-app-bundle type
25 echo " where type is 'release', 'dev', or 'collabora'"
26 exit 1
29 if [ ! -d "$1" ]; then
30 echo No such directory: $1 >&2
31 exit 1
34 if [[ "$1" != *.app ]]; then
35 echo "signed-app-bundle argument $1 does not end with .app" >&2
36 exit 1
39 DSSTOREFILE=
40 VOLUMEICON=
41 if [ "$2" = "release" ];then
42 DSSTOREFILE=DS_Store
43 elif [ "$2" = "dev" ];then
44 DSSTOREFILE=DS_Store_Dev
45 elif [ "$2" = "collabora" ];then
46 DSSTOREFILE=DS_Store
47 # Collabora is not currently using a volume icon
48 #VOLUMEICON=main.icns
49 else
50 echo "type argument $2 is not equal to 'release', 'dev', or 'collabora'" >&2
51 exit 1
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
65 # assemble assets
67 if [ -f "$OUTFILE" ]; then
68 echo The file $OUTFILE exists already >&2
69 exit 1
72 if [ -d "$OUTFILE" ]; then
73 echo $OUTFILE exists and is a directory >&2
74 exit 1
77 if [ -f "$OUTFILETMP" ]; then
78 echo The file $OUTFILETMP exists already >&2
79 exit 1
82 if [ -d "$OUTFILETMP" ]; then
83 echo $OUTFILETMP exists and is a directory >&2
84 exit 1
87 if [ -d "$OUTTMPDIR" ]; then
88 echo The directory $OUTTMPDIR exists already >&2
89 exit 1
92 if [ -f "$OUTTMPDIR" ]; then
93 echo $OUTTMPDIR exists and is a file >&2
94 exit 1
97 if [ -d "$OUTVOLUMEMOUNT" ]; then
98 echo The directory $OUTVOLUMEMOUNT exists already >&2
99 exit 1
102 if [ -f "$OUTVOLUMEMOUNT" ]; then
103 echo $OUTVOLUMEMOUNT exists and is a file >&2
104 exit 1
107 mkdir "$OUTTMPDIR"
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
119 sync
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
125 else
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
129 sync
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"
137 sync
138 hdiutil convert "$OUTFILETMP" -format ULFO -o "$OUTFILE"
141 sync
143 # Print warning about notarization
144 echo "Successfully created '$OUTFILE'"
145 echo
146 echo "Warning: the .dmg is NOT notarized!"
147 echo
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'"
152 exit 0