LICENSE="This software is distibuted under GNU GPLv3 license.
Visit http://www.gnu.org/licenses/gpl-3.0.txt for more information."
HELP="Usage:
$0 [options...] bundle_name
$0 -v
$0 -h
$0 -l
Available options:
-d <folder> Specify folder with a bundle. Defaults to pwd.
-i <file> Specify icon file to set to resulting dmg, contains absolute or relative path.
-b <file> Specify background image file to set to resulting dmg, contains absolute or relative path.
-c <coordinates> Specify coordinates to set to Applications symlink and Bundle in dmg, should be in format \"ApplicationsX:ApplicationsY:BundleX:BundleY\". If not specified, icons are unarranged.
-s <size> Specify dmg window size in Finder, should be in format \"WindowWidth:WindowHeight\". If not specified, defaults to 640x480.
-n <name> Specify resulting dmg name. If not specified, defaults to BundleName.dmg.
-N <name> Specify resulting dmg's volume name. If not specified, defaults to \"BundleName\".
-t <folder> Specify temporary dir. If not specified, defaults to /tmp.
-S <identity> Codesign bundle with specified identity before making dmg. If this option is not used, no signing performed. Warning! This will replace existing code signature if any!
-V Add bundle version to dmg name as a suffix. Version is read from bundle's Info.plist file.
-v Print version acnd copyright and exit.
-h Print help and exit.
-l Print license info and exit."
ARG_DIR=`pwd`
ARG_ICON=
ARG_BACKGROUND=
ARG_COORDS=
ARG_SIZE="640:480"
ARG_DMG_NAME=
ARG_VOL_NAME=
ARG_TMP_DIR="/tmp/make_dmg"
ARG_ADD_VERSION=
ARG_CODESIGN_ID=
# reading options
whilegetopts":d:i:b:c:s:N:n:t:Vvhl" opt;do
case$opt in
v)
echo"${VERSION}"
exit0
;;
l)
echo"${LICENSE}"
exit0
;;
h)
echo"${HELP}"
exit0
;;
d)
echo"Setting target dir to $OPTARG"
ARG_DIR=$OPTARG
;;
i)
echo"Setting icon to $OPTARG"
ARG_ICON=$OPTARG
;;
b)
echo"Setting background to $OPTARG"
ARG_BACKGROUND=$OPTARG
;;
c)
echo"Setting coordinates to $OPTARG"
ARG_COORDS=$OPTARG
;;
s)
echo"Setting window size to $OPTARG"
ARG_SIZE=$OPTARG
;;
n)
echo"Setting dmg name to $OPTARG"
ARG_DMG_NAME=$OPTARG
;;
N)
echo"Setting dmg volume name to $OPTARG"
ARG_VOL_NAME=$OPTARG
;;
t)
echo"Setting temporary dir to $OPTARG"
ARG_TMP_DIR=$OPTARG
;;
S)
echo"Setting codesign identity to $OPTARG"
ARG_CODESIGN_ID=$OPTARG
;;
V)
echo"Enabling version info in resulting dmg"
ARG_ADD_VERSION=1
;;
\?)
echo"Invalid option: -$OPTARG"
exit1
;;
:)
echo"Error! Option -$OPTARG requires an argument."
exit1
;;
esac
done
shift$(($OPTIND-1))
ARGS=$*
set -- $ARGS
APP_BUNDLE_NAME="$@"
if["$ARGS"];then
echo"Bundle name set to ${APP_BUNDLE_NAME}";
else
echo"Error! Bundle name is not specified."
exit 1;
fi
if[ ! -e "${APP_BUNDLE_NAME}"];then
echo"Error! Bundle \"${APP_BUNDLE_NAME}\" does not exist!"
exit1
fi
TARGET_DIR=${ARG_DIR}
if[ ! "${TARGET_DIR}"];then
TARGET_DIR=`pwd`
fi
if[ ! -e "${TARGET_DIR}"];then
echo"Error! Directory \"${TARGET_DIR}\" does not exist."