2023-03-01 08:23:12 -06:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# This file is part of the LibreOffice project.
|
|
|
|
#
|
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
# Exit on errors
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Use of unset variable is an error
|
|
|
|
set -u
|
|
|
|
|
|
|
|
# If any part of a pipeline of commands fails, the whole pipeline fails
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
if [ `uname` != Darwin ]; then
|
|
|
|
echo This is for macOS only >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-03-08 13:59:59 -06:00
|
|
|
if [ $# != 2 ]; then
|
|
|
|
echo Usage: $0 signed-app-bundle type
|
|
|
|
echo " where type is 'release', 'dev', or 'collabora'"
|
2023-03-01 08:23:12 -06:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "$1" ]; then
|
|
|
|
echo No such directory: $1 >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$1" != *.app ]]; then
|
|
|
|
echo "signed-app-bundle argument $1 does not end with .app" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-03-08 13:59:59 -06:00
|
|
|
DSSTOREFILE=
|
|
|
|
VOLUMEICON=
|
|
|
|
if [ "$2" = "release" ];then
|
|
|
|
DSSTOREFILE=DS_Store
|
|
|
|
elif [ "$2" = "dev" ];then
|
|
|
|
DSSTOREFILE=DS_Store_Dev
|
|
|
|
elif [ "$2" = "collabora" ];then
|
|
|
|
DSSTOREFILE=DS_Store
|
|
|
|
# Collabora is not currently using a volume icon
|
|
|
|
#VOLUMEICON=main.icns
|
|
|
|
else
|
|
|
|
echo "type argument $2 is not equal to 'release', 'dev', or 'collabora'" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-03-01 08:23:12 -06:00
|
|
|
IN=$(cd "$1" && /bin/pwd)
|
|
|
|
INAPP=$(basename "$IN")
|
|
|
|
INDIR=$(dirname "$IN")
|
|
|
|
OUTVOLUME=$(basename "$IN" .app)
|
2023-03-08 13:59:59 -06:00
|
|
|
OUTVOLUMEMOUNT=/Volumes/"$OUTVOLUME"
|
2023-03-01 08:23:12 -06:00
|
|
|
OUTTMPDIR=$(dirname "$IN")/"$OUTVOLUME"
|
|
|
|
OUTFILE="$OUTTMPDIR".dmg
|
2023-03-08 13:59:59 -06:00
|
|
|
OUTFILETMP="$OUTTMPDIR".tmp.dmg
|
2023-03-01 08:23:12 -06:00
|
|
|
SRCDIR=$(cd `dirname "$0"`/.. && /bin/pwd)
|
|
|
|
|
|
|
|
# Create $OUTTMPDIR directory in the same directory as the output .dmg and
|
|
|
|
# assemble assets
|
|
|
|
|
|
|
|
if [ -f "$OUTFILE" ]; then
|
|
|
|
echo The file $OUTFILE exists already >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d "$OUTFILE" ]; then
|
|
|
|
echo $OUTFILE exists and is a directory >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-03-08 13:59:59 -06:00
|
|
|
if [ -f "$OUTFILETMP" ]; then
|
|
|
|
echo The file $OUTFILETMP exists already >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d "$OUTFILETMP" ]; then
|
|
|
|
echo $OUTFILETMP exists and is a directory >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-03-01 08:23:12 -06:00
|
|
|
if [ -d "$OUTTMPDIR" ]; then
|
|
|
|
echo The directory $OUTTMPDIR exists already >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "$OUTTMPDIR" ]; then
|
|
|
|
echo $OUTTMPDIR exists and is a file >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-03-08 13:59:59 -06:00
|
|
|
if [ -d "$OUTVOLUMEMOUNT" ]; then
|
|
|
|
echo The directory $OUTVOLUMEMOUNT exists already >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "$OUTVOLUMEMOUNT" ]; then
|
|
|
|
echo $OUTVOLUMEMOUNT exists and is a file >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-03-01 08:23:12 -06:00
|
|
|
mkdir "$OUTTMPDIR"
|
|
|
|
mkdir "$OUTTMPDIR"/.background
|
|
|
|
tar cf - "$INAPP" -C "$INDIR" | tar xvpf - -C "$OUTTMPDIR"
|
|
|
|
ln -s /Applications "$OUTTMPDIR"/Applications
|
|
|
|
cp "$SRCDIR"/setup_native/source/packinfo/DS_Store "$OUTTMPDIR"/.DS_Store
|
2023-03-08 13:59:59 -06:00
|
|
|
if [ ! -z "$VOLUMEICON" ]; then
|
|
|
|
cp "$SRCDIR"/sysui/desktop/icons/"$VOLUMEICON" "$OUTTMPDIR"/.VolumeIcon.icns
|
|
|
|
fi
|
2023-03-01 08:23:12 -06:00
|
|
|
cp "$SRCDIR"/setup_native/source/packinfo/osxdndinstall.png "$OUTTMPDIR"/.background/background.png
|
|
|
|
|
|
|
|
# Create and mount empty .dmg
|
|
|
|
|
2023-03-08 13:59:59 -06:00
|
|
|
sync
|
|
|
|
|
|
|
|
if [ -z "$VOLUMEICON" ]; then
|
2023-03-01 08:23:12 -06:00
|
|
|
# Copied and adapted to bash from solenv/bin/modules/installer/simplepackage.pm
|
|
|
|
# tdf#151341 Use lzfse compression instead of bzip2
|
|
|
|
hdiutil create -srcfolder "$OUTTMPDIR" "$OUTFILE" -ov -fs HFS+ -volname "$OUTVOLUME" -format ULFO
|
2023-03-08 13:59:59 -06:00
|
|
|
else
|
|
|
|
# To set a volume icon, we need to create a writable .dmg, mount it, set the
|
|
|
|
# volume icon, unmount it, and then convert it to a read-only .dmg
|
|
|
|
hdiutil create -srcfolder "$OUTTMPDIR" "$OUTFILETMP" -ov -fs HFS+ -volname "$OUTVOLUME" -format UDRW
|
|
|
|
sync
|
|
|
|
hdiutil attach "$OUTFILETMP"
|
|
|
|
if [ -f "$OUTVOLUMEMOUNT"/.VolumeIcon.icns ]; then
|
|
|
|
# TODO: SetFile is deprecated so we will eventually need to find another
|
|
|
|
# way to set the volume icon or stop trying to set the volume icon
|
|
|
|
SetFile -a C "$OUTVOLUMEMOUNT"
|
|
|
|
fi
|
|
|
|
hdiutil detach "$OUTVOLUMEMOUNT"
|
|
|
|
sync
|
|
|
|
hdiutil convert "$OUTFILETMP" -format ULFO -o "$OUTFILE"
|
|
|
|
fi
|
|
|
|
|
|
|
|
sync
|
|
|
|
|
|
|
|
# Print warning about notarization
|
|
|
|
echo "Successfully created '$OUTFILE'"
|
|
|
|
echo
|
|
|
|
echo "Warning: the .dmg is NOT notarized!"
|
|
|
|
echo
|
|
|
|
echo "You can manually notarize the .dmg using the following commands:"
|
|
|
|
echo " xcrun notarytool submit '$OUTFILE' ... [--wait]"
|
|
|
|
echo " xcrun stapler staple '$OUTFILE'"
|
|
|
|
echo " xcrun stapler validate '$OUTFILE'"
|
|
|
|
exit 0
|