Permalink
Browse files

Merge pull request #1 from jaeggir/master

Add support for a volume icon
  • Loading branch information...
2 parents ae28022 + a22ac11 commit da94f0ef70d74f5cbd22fb2c5d6d985ca8dedeb2 @andreyvit committed Dec 5, 2011
Showing with 16 additions and 0 deletions.
  1. +16 −0 create-dmg
View
@@ -27,6 +27,8 @@ function usage() {
echo "Options:"
echo " --volname name"
echo " set volume name (displayed in the Finder sidebar and window title)"
+ echo " --volicon icon.icns"
+ echo " set volume icon"
echo " --background pic.png"
echo " set folder background image (provide png, gif, jpg)"
echo " --window-pos x y"
@@ -55,6 +57,9 @@ while test "${1:0:1}" = "-"; do
--volname)
VOLUME_NAME="$2"
shift; shift;;
+ --volicon)
+ VOLUME_ICON_FILE="$2"
+ shift; shift;;
--background)
BACKGROUND_FILE="$2"
BACKGROUND_FILE_NAME="$(basename $BACKGROUND_FILE)"
@@ -130,6 +135,12 @@ if ! test -z "$BACKGROUND_FILE"; then
cp "$BACKGROUND_FILE" "$MOUNT_DIR/.background/$BACKGROUND_FILE_NAME"
fi
+if ! test -z "$VOLUME_ICON_FILE"; then
+ echo "Copying volume icon file '$VOLUME_ICON_FILE'..."
+ cp "$VOLUME_ICON_FILE" "$MOUNT_DIR/.VolumeIcon.icns"
+ SetFile -c icnC "$MOUNT_DIR/.VolumeIcon.icns"
+fi
+
# run applescript
APPLESCRIPT=$(mktemp -t createdmg)
cat "$AUX_PATH/template.applescript" | sed -e "s/WINX/$WINX/g" -e "s/WINY/$WINY/g" -e "s/WINW/$WINW/g" -e "s/WINH/$WINH/g" -e "s/BACKGROUND_CLAUSE/$BACKGROUND_CLAUSE/g" -e "s/ICON_SIZE/$ICON_SIZE/g" | perl -pe "s/POSITION_CLAUSE/$POSITION_CLAUSE/g" >"$APPLESCRIPT"
@@ -150,6 +161,11 @@ if [ -x /usr/local/bin/openUp ]; then
/usr/local/bin/openUp "${MOUNT_DIR}"
fi
+if ! test -z "$VOLUME_ICON_FILE"; then
+ # tell the volume that it has a special file attribute
+ SetFile -a C "$MOUNT_DIR"
+fi
+
# unmount
echo "Unmounting disk image..."
hdiutil detach "${DEV_NAME}"

0 comments on commit da94f0e

Please sign in to comment.