Browse files

Merge pull request #9 from makerbot/master

Better escaping; automatic addition of the Application link
  • Loading branch information...
2 parents d0bc2cb + f38b996 commit 3fc33665cabc120027d226a282aa84064aa29173 @andreyvit committed Mar 2, 2012
Showing with 22 additions and 5 deletions.
  1. +20 −5 create-dmg
  2. +2 −0 support/template.applescript
View
25 create-dmg
@@ -41,15 +41,17 @@ function usage() {
echo " set position of the file's icon"
echo " --custom-icon file_name custom_icon_or_sample_file x y"
echo " set position and custom icon"
+ echo " --app-drop-link x y"
+ echo " make a drop link to Applications, at location x,y"
echo " --version show tool version number"
echo " -h, --help display this help"
exit 0
}
WINX=10
WINY=60
-WINW=600
-WINH=400
+WINW=500
+WINH=350
ICON_SIZE=128
while test "${1:0:1}" = "-"; do
@@ -86,6 +88,11 @@ while test "${1:0:1}" = "-"; do
version; exit 0;;
--pure-version)
pure_version; exit 0;;
+ --app-drop-link)
+ APPLICATION_LINK=$2
+ APPLICATION_CLAUSE="set position of item \"Applications\" to {$2, $3}
+"
+ shift; shift; shift;;
-*)
echo "Unknown option $1. Run with --help for help."
exit 1;;
@@ -112,15 +119,15 @@ test -d "$AUX_PATH" || {
exit 1
}
-if [ -f $SRC_FOLDER/.DS_Store ]; then
+if [ -f '$SRC_FOLDER/.DS_Store' ]; then

Single quotes will cause $SRC_FOLDER to be printed literally... this should use double quotes.

@andreyvit
Owner

Right, thanks — fixed that. (Please just send a pull request the next time!)

Sure thing, I just noticed it from taking a quick look passing by. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
echo "Deleting any .DS_Store in source folder"
rm $SRC_FOLDER/.DS_Store
fi
# Create the image
echo "Creating disk image..."
test -f "${DMG_TEMP_NAME}" && rm -f "${DMG_TEMP_NAME}"
-ACTUAL_SIZE=`du -sm $SRC_FOLDER | sed -e 's/ .*//g'`
+ACTUAL_SIZE=`du -sm "$SRC_FOLDER" | sed -e 's/ .*//g'`
DISK_IMAGE_SIZE=$(expr $ACTUAL_SIZE + 20)
hdiutil create -srcfolder "$SRC_FOLDER" -volname "${VOLUME_NAME}" -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW -size ${DISK_IMAGE_SIZE}m "${DMG_TEMP_NAME}"
@@ -137,6 +144,12 @@ if ! test -z "$BACKGROUND_FILE"; then
cp "$BACKGROUND_FILE" "$MOUNT_DIR/.background/$BACKGROUND_FILE_NAME"
fi
+if ! test -z "$APPLICATION_LINK"; then
+ echo "making link to Applications dir"
+ echo $MOUNT_DIR
+ ln -s /Applications "$MOUNT_DIR/Applications"
+fi
+
if ! test -z "$VOLUME_ICON_FILE"; then
echo "Copying volume icon file '$VOLUME_ICON_FILE'..."
cp "$VOLUME_ICON_FILE" "$MOUNT_DIR/.VolumeIcon.icns"
@@ -145,13 +158,15 @@ 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"
+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" | perl -pe "s/APPLICATION_CLAUSE/$APPLICATION_CLAUSE/g" >"$APPLESCRIPT"
echo "Running Applescript: /usr/bin/osascript \"${APPLESCRIPT}\" \"${VOLUME_NAME}\""
"/usr/bin/osascript" "${APPLESCRIPT}" "${VOLUME_NAME}" || true
echo "Done running the applescript..."
sleep 4
+rm "$APPLESCRIPT"
+
# make sure it's not world writeable
echo "Fixing permissions..."
chmod -Rf go-w "${MOUNT_DIR}" &> /dev/null || true
View
2 support/template.applescript
@@ -30,6 +30,8 @@ on run (volumeName)
-- Positioning
POSITION_CLAUSE
+ -- Application Link Clause
+ APPLICATION_CLAUSE
close
open

0 comments on commit 3fc3366

Please sign in to comment.