-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tools and configs for osx dmg packaging
- Loading branch information
Showing
12 changed files
with
291 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
OS X Packaging | ||
============== | ||
|
||
Packing for OS X is bit interesting. | ||
Here are utilities to manage packaging configuration and to create final disk image. | ||
|
||
Finder background | ||
----------------- | ||
|
||
Disk image is oppened with a Finder window and we use background image to render information texts. | ||
Source file is in `res/dmg-background.svg` and 72DPI and 144DPI renders in `res/dmg-background.png` and `res/[email protected]` respectively. | ||
|
||
.DS_Store | ||
--------- | ||
|
||
DMG installer contains Finder window layout and background in a binary file `.DS_Store`. | ||
Apple has not documented this format. | ||
|
||
Tool `setup_volume.sh` is used to create test volume for modifying DS_Store file. | ||
It uses an applescript to create layout. | ||
You can edit the script to test new layout parameters. | ||
Though, resulting DS_Store contains volume mounts and other irrelevant information and thus can not be used for distributing. | ||
For distributable version, there is node script in `createdbstore` directory. | ||
|
||
So, first play with the `setup_volume.sh` and applescript to get window that looks correct and then recreate the configuration with `createdbstore`. | ||
Finally, copy `.DS_Store` to `res/DS_store`. | ||
|
||
Creating final image | ||
-------------------- | ||
|
||
Script `create_dmg.sh` creates compressed read-only disk image. | ||
It uses resources from `res` directory. | ||
It requires the destination as parameter. | ||
|
||
For example `./packaging/osx/create_dmg.sh dist/roman.dmg`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/sh -e | ||
|
||
scripts=$(dirname "$0") | ||
res=$scripts/res/ | ||
|
||
out=$1 | ||
[ "$out" ] || { echo "ERROR: missing output file"; exit 1; } | ||
dist=$(dirname "$out") | ||
|
||
name=Roman | ||
bg1=$res/dmg-background.png | ||
bg2=$res/[email protected] | ||
dss=$res/DS_Store | ||
|
||
require_dpi() { | ||
f=$1 | ||
i=$2 | ||
if [ ! -e "$f" ]; then | ||
echo "ERROR: missing image $f" | ||
exit 1 | ||
fi | ||
dpi=$(sips -g dpiHeight "$f" | egrep '^\s*dpiHeight' | awk '{print $2}') | ||
if [ "$dpi" != "$i" ]; then | ||
echo "ERROR: wrong dpi $dpi expected $i, file $f" | ||
exit 1 | ||
fi | ||
} | ||
|
||
require_dpi "$bg1" "72.000" | ||
require_dpi "$bg2" "144.000" | ||
|
||
d=$dist/$name | ||
|
||
rm -rf $d | ||
mkdir -p $d/.background/ | ||
|
||
cp -r $dist/$name.app $d/ | ||
cp "$bg1" $d/.background/dmg-background.png | ||
cp "$bg2" $d/.background/[email protected] | ||
cp "$dss" $d/.DS_Store | ||
|
||
SetFile -a icnv $d/.background $d/.DS_Store | ||
ln -s /Applications $d/Applications | ||
|
||
hdiutil create $out \ | ||
-format UDZO -imagekey zlib-level=9 \ | ||
-volname $name -srcfolder $d/ -ov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
DS_Store creator | ||
================ | ||
|
||
This trivial script creates simple .DS_Store file to be used for a disk image layout. | ||
It tool is only needed when size or icon positions of the Finder window changes. | ||
If that happens, then edit the `cli.js` with the new information. | ||
Execute it to obtain a new .DS_Store file. | ||
|
||
To install, run `npm install` and to execute run `./cli.js`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
const fs = require('fs') | ||
const path = require('path') | ||
const DSStore = require('ds-store') | ||
|
||
const exit_with_error = (err) => { | ||
console.error(err); | ||
process.exit(1) | ||
} | ||
|
||
const create_ds_store = () => { | ||
const ds = new DSStore() | ||
|
||
const w = 760 | ||
const h = 480 | ||
const x = 300 | ||
const y = 200 | ||
const ixpos = 200 | ||
const iypos = 200 | ||
|
||
ds.vSrn(1) | ||
ds.setIconSize(128) | ||
ds.setBackgroundColor(1, 1, 1) | ||
ds.setBackgroundPath('/Volumes/Roman/.background/dmg-background.png') | ||
ds.setWindowSize(w, h) | ||
ds.setWindowPos(x, y) | ||
ds.setIconPos('Roman.app', ixpos, iypos) | ||
ds.setIconPos('Applications', w-ixpos, iypos) | ||
|
||
ds.write('/Volumes/Roman/.DS_Store', (err) => { | ||
if (err) | ||
exit_with_error(err) | ||
else | ||
console.info("Done") | ||
}) | ||
} | ||
|
||
create_ds_store() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "createdsstore", | ||
"version": "1.0.0", | ||
"description": "Creates .DS_Store file with hard coded values", | ||
"bin": "./cli.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "Jaakko Kantojärvi <[email protected]>", | ||
"license": "ISC", | ||
"dependencies": { | ||
"ds-store": "^0.1.6" | ||
} | ||
} |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
tell application "Finder" | ||
tell disk "Roman" | ||
open | ||
|
||
set theX to 300 | ||
set theY to 200 | ||
set theW to 760 | ||
set theH to 480 | ||
set theX2 to (theX + theW) | ||
set theY2 to (theY + theH) | ||
set theI1X to 200 | ||
set theI2X to (theW - theI1X) | ||
set theIY to 200 | ||
|
||
tell container window | ||
set current view to icon view | ||
set toolbar visible to false | ||
set statusbar visible to false | ||
set the bounds to {theX, theY, theX2, theY2} | ||
end tell | ||
|
||
set viewOptions to the icon view options of container window | ||
tell viewOptions | ||
set arrangement to not arranged | ||
set icon size to 128 | ||
set text size to 14 | ||
end tell | ||
|
||
set background picture of viewOptions to file ".background:dmg-background.png" | ||
set position of item "Roman.app" of container window to {theI1X, theIY} | ||
set position of item "Applications" of container window to {theI2X, theIY} | ||
|
||
close | ||
open | ||
update without registering applications | ||
delay 2 | ||
end tell | ||
end tell |
Oops, something went wrong.