Permalink
Browse files

Merge pull request #144 from stefanha/update-create-dmg

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
  • Loading branch information...
stefanha committed Dec 10, 2016
2 parents 6e7b4a3 + 508bfdb commit 347f843cca8ec24b1eb61920bb9ed2f65f7b9194
@@ -26,7 +26,7 @@ then
background_opts="--window-size 800 600 --background background-$1.png --icon $1 200 351 --app-drop-link 596 351"
fi
yoursway-create-dmg/create-dmg \
create-dmg/create-dmg \
--volname $1 \
--eula license.txt \
$background_opts \
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2008-2014 Andrey Tarantsov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1 @@
From https://github.com/andreyvit/create-dmg.git, commit 5acf22fa87e1b751701f377efddc7429877ecb0a
@@ -0,0 +1,77 @@
create-dmg
==========
A shell script to build fancy DMGs.
Status and contribution policy
------------------------------
This project is maintained thanks to the contributors who send pull requests. The original author has no use for the project, so his only role is reviewing and merging pull requests.
I will merge any pull request that adds something useful and does not break existing things.
Starting in January 2015, everyone who gets a pull request merged gets commit access to the repository.
Installation
------------
By being a shell script, yoursway-create-dmg installation is very simple. Simply download and run.
> git clone https://github.com/andreyvit/yoursway-create-dmg.git
> cd yoursway-create-dmg
> ./create-dmg [options]
Usage
-----
> create-dmg [options...] [output\_name.dmg] [source\_folder]
All contents of source\_folder will be copied into the disk image.
**Options:**
* **--volname [name]:** set volume name (displayed in the Finder sidebar and window title)
* **--volicon [icon.icns]:** set volume icon
* **--background [pic.png]:** set folder background image (provide png, gif, jpg)
* **--window-pos [x y]:** set position the folder window
* **--window-size [width height]:** set size of the folder window
* **--text-size [text size]:** set window text size (10-16)
* **--icon-size [icon size]:** set window icons size (up to 128)
* **--icon [file name] [x y]:** set position of the file's icon
* **--hide-extension [file name]:** hide the extension of file
* **--custom-icon [file name]/[custom icon]/[sample file] [x y]:** set position and custom icon
* **--app-drop-link [x y]:** make a drop link to Applications, at location x, y
* **--eula [eula file]:** attach a license file to the dmg
* **--no-internet-enable:** disable automatic mount&copy
* **--version:** show tool version number
* **-h, --help:** display the help
Example
-------
> \#!/bin/sh
> test -f Application-Installer.dmg && rm Application-Installer.dmg
> create-dmg \
> --volname "Application Installer" \
> --volicon "application\_icon.icns" \
> --background "installer\_background.png" \
> --window-pos 200 120 \
> --window-size 800 400 \
> --icon-size 100 \
> --icon Application.app 200 190 \
> --hide-extension Application.app \
> --app-drop-link 600 185 \
> Application-Installer.dmg \
> source\_folder/
Alternatives
------------
* [node-appdmg](https://github.com/LinusU/node-appdmg)
* [dmgbuild](https://pypi.python.org/pypi/dmgbuild)
* see the [StackOverflow question](http://stackoverflow.com/questions/96882/how-do-i-create-a-nice-looking-dmg-for-mac-os-x-using-command-line-tools)
@@ -0,0 +1,26 @@
SET app_name create-dmg
VERSION create-dmg.cur create-dmg heads/master
NEWDIR build.dir temp %-build -
NEWFILE create-dmg.zip featured %.zip %
COPYTO [build.dir]
INTO create-dmg [create-dmg.cur]/create-dmg
INTO sample [create-dmg.cur]/sample
INTO support [create-dmg.cur]/support
SUBSTVARS [build.dir<alter>]/create-dmg [[]]
ZIP [create-dmg.zip]
INTO [build-files-prefix] [build.dir]
PUT megabox-builds create-dmg.zip
PUT megabox-builds build.log
PUT s3-builds create-dmg.zip
PUT s3-builds build.log
@@ -28,6 +28,8 @@ function usage() {
echo " set position the folder window"
echo " --window-size width height"
echo " set size of the folder window"
echo " --text-size text_size"
echo " set window text size (10-16)"
echo " --icon-size icon_size"
echo " set window icons size (up to 128)"
echo " --icon file_name x y"
@@ -40,6 +42,8 @@ function usage() {
echo " make a drop link to Applications, at location x,y"
echo " --eula eula_file"
echo " attach a license file to the dmg"
echo " --no-internet-enable"
echo " disable automatic mount&copy"
echo " --version show tool version number"
echo " -h, --help display this help"
exit 0
@@ -50,6 +54,7 @@ WINY=60
WINW=500
WINH=350
ICON_SIZE=128
TEXT_SIZE=16
while test "${1:0:1}" = "-"; do
case $1 in
@@ -63,10 +68,14 @@ while test "${1:0:1}" = "-"; do
BACKGROUND_FILE="$2"
BACKGROUND_FILE_NAME="$(basename $BACKGROUND_FILE)"
BACKGROUND_CLAUSE="set background picture of opts to file \".background:$BACKGROUND_FILE_NAME\""
REPOSITION_HIDDEN_FILES_CLAUSE="set position of every item to {theBottomRightX + 100, 100}"
shift; shift;;
--icon-size)
ICON_SIZE="$2"
shift; shift;;
--text-size)
TEXT_SIZE="$2"
shift; shift;;
--window-pos)
WINX=$2; WINY=$3
shift; shift; shift;;
@@ -78,7 +87,8 @@ while test "${1:0:1}" = "-"; do
"
shift; shift; shift; shift;;
--hide-extension)
HIDING_CLAUSE="${HIDING_CLAUSE}set the extension hidden of item \"$2\" to true"
HIDING_CLAUSE="${HIDING_CLAUSE}set the extension hidden of item \"$2\" to true
"
shift; shift;;
--custom-icon)
shift; shift; shift; shift; shift;;
@@ -96,6 +106,9 @@ while test "${1:0:1}" = "-"; do
--eula)
EULA_RSRC=$2
shift; shift;;
--no-internet-enable)
NOINTERNET=1
shift;;
-*)
echo "Unknown option $1. Run with --help for help."
exit 1;;
@@ -107,15 +120,16 @@ test -z "$2" && {
exit 1
}
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DMG_PATH="$1"
DMG_DIRNAME="$(dirname "$DMG_PATH")"
DMG_DIR="$(cd $DMG_DIRNAME > /dev/null; pwd)"
DMG_DIR="$(cd "$DMG_DIRNAME" > /dev/null; pwd)"
DMG_NAME="$(basename "$DMG_PATH")"
DMG_TEMP_NAME="$DMG_DIR/rw.${DMG_NAME}"
SRC_FOLDER="$(cd "$2" > /dev/null; pwd)"
test -z "$VOLUME_NAME" && VOLUME_NAME="$(basename "$DMG_PATH" .dmg)"
AUX_PATH="$(dirname $0)/support"
AUX_PATH="$SCRIPT_DIR/support"
test -d "$AUX_PATH" || {
echo "Cannot find support directory: $AUX_PATH"
@@ -167,7 +181,7 @@ 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" | perl -pe "s/APPLICATION_CLAUSE/$APPLICATION_CLAUSE/g" | perl -pe "s/HIDING_CLAUSE/$HIDING_CLAUSE/" >"$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/REPOSITION_HIDDEN_FILES_CLAUSE/$REPOSITION_HIDDEN_FILES_CLAUSE/g" -e "s/ICON_SIZE/$ICON_SIZE/g" -e "s/TEXT_SIZE/$TEXT_SIZE/g" | perl -pe "s/POSITION_CLAUSE/$POSITION_CLAUSE/g" | perl -pe "s/APPLICATION_CLAUSE/$APPLICATION_CLAUSE/g" | perl -pe "s/HIDING_CLAUSE/$HIDING_CLAUSE/" >"$APPLESCRIPT"
echo "Running Applescript: /usr/bin/osascript \"${APPLESCRIPT}\" \"${VOLUME_NAME}\""
"/usr/bin/osascript" "${APPLESCRIPT}" "${VOLUME_NAME}" || true
@@ -206,5 +220,11 @@ if [ ! -z "${EULA_RSRC}" -a "${EULA_RSRC}" != "-null-" ]; then
"${AUX_PATH}/dmg-license.py" "${DMG_DIR}/${DMG_NAME}" "${EULA_RSRC}"
fi
if [ ! -z "${NOINTERNET}" -a "${NOINTERNET}" == 1 ]; then
echo "not setting 'internet-enable' on the dmg"
else
hdiutil internet-enable -yes "${DMG_DIR}/${DMG_NAME}"
fi
echo "Disk image done"
exit 0
@@ -0,0 +1,3 @@
#! /bin/bash
test -f test2.dmg && rm test2.dmg
./create-dmg --window-size 500 300 --background ~/Projects/eclipse-osx-repackager/build/background.gif --icon-size 96 --volname "Hyper Foo" --app-drop-link 380 205 --icon "Eclipse OS X Repackager" 110 205 test2.dmg /Users/andreyvit/Projects/eclipse-osx-repackager/temp/Eclipse\ OS\ X\ Repackager\ r10/
Oops, something went wrong.

0 comments on commit 347f843

Please sign in to comment.