34 lines
671 B
Bash
Executable File
34 lines
671 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
if [[ $# -ne 2 ]]
|
|
then
|
|
echo "用法:$0 <Commilitia Drop.app> <Commilitia Drop.dmg>" >&2
|
|
exit 2
|
|
fi
|
|
|
|
appPath="$1"
|
|
outputPath="$2"
|
|
|
|
if [[ ! -d "$appPath" ]]
|
|
then
|
|
echo "找不到应用:$appPath" >&2
|
|
exit 1
|
|
fi
|
|
|
|
stagingDirectory="$(mktemp -d /tmp/commilitia-drop-dmg.XXXXXX)"
|
|
trap 'rm -rf "$stagingDirectory"' EXIT
|
|
|
|
ditto "$appPath" "$stagingDirectory/Commilitia Drop.app"
|
|
ln -s /Applications "$stagingDirectory/Applications"
|
|
mkdir -p "$(dirname "$outputPath")"
|
|
rm -f "$outputPath"
|
|
|
|
hdiutil create \
|
|
-volname "Commilitia Drop" \
|
|
-srcfolder "$stagingDirectory" \
|
|
-ov \
|
|
-format UDZO \
|
|
"$outputPath"
|