moved dmgutil (osx) and poppler includes as to make openboard (osx) compile without OpenBoard-ThirdParty + quazip fix headers for osx (clang apparently not searching for system headers with double quotes)
@ -0,0 +1,728 @@ |
||||
#!/usr/bin/perl -w |
||||
#============================================================================ |
||||
# NAME: |
||||
# dmgutil.pl |
||||
# |
||||
# DESCRIPTION: |
||||
# Disk image creation utility. |
||||
# |
||||
# COPYRIGHT: |
||||
# Copyright (c) 2006-2008, refNum Software |
||||
# <http://www.refnum.com/> |
||||
# |
||||
# All rights reserved. |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions |
||||
# are met: |
||||
# |
||||
# o Redistributions of source code must retain the above |
||||
# copyright notice, this list of conditions and the following |
||||
# disclaimer. |
||||
# |
||||
# o Redistributions in binary form must reproduce the above |
||||
# copyright notice, this list of conditions and the following |
||||
# disclaimer in the documentation and/or other materials |
||||
# provided with the distribution. |
||||
# |
||||
# o Neither the name of refNum Software nor the names of its |
||||
# contributors may be used to endorse or promote products derived |
||||
# from this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
#============================================================================ |
||||
# Imports |
||||
#---------------------------------------------------------------------------- |
||||
use strict; |
||||
use Getopt::Long; |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# Constants |
||||
#---------------------------------------------------------------------------- |
||||
my $kLogging = "-quiet"; |
||||
|
||||
my $Rez = "/Developer/Tools/Rez"; |
||||
my $SetFile = "/Developer/Tools/SetFile"; |
||||
|
||||
my $kManPage = <<MANPAGE; |
||||
NAME |
||||
dmgutil -- create, adjust, and compress a distribution disk image |
||||
|
||||
SYNOPSIS |
||||
dmgutil --help |
||||
|
||||
dmgutil --open --volume=name file |
||||
|
||||
dmgutil --set [--x=integer] [--y=integer] |
||||
[--width=integer] [--height=integer] |
||||
[--iconsize=integer] [--icon=file] |
||||
[--background=file] [--bgcol=r,g,b] |
||||
[--toolbar=boolean] file |
||||
|
||||
dmgutil --close --volume=name file |
||||
|
||||
DESCRIPTION |
||||
dmgutil is used to create distribution disk images, and to adjust |
||||
the Finder view settings of these volumes or their contents. |
||||
|
||||
It can be invoked in three modes: open, set, and close. |
||||
|
||||
OPEN MODE |
||||
Open Mode has the following options: |
||||
--open Select open mode. |
||||
|
||||
--volume=name The volume name for the disk image. |
||||
|
||||
file The output path for the .dmg file. |
||||
|
||||
SET MODE |
||||
Set Mode has the following options: |
||||
--set Select set mode. |
||||
|
||||
--x=integer The x coordinate of the item. |
||||
|
||||
--y=integer The y coordinate of the item. |
||||
|
||||
--width=integer The width for a Finder window. |
||||
|
||||
--height=integer The height for a Finder window. |
||||
|
||||
--iconsize=integer The icon size for a Finder window. |
||||
|
||||
--icon=file.icns The icon to apply to the item. |
||||
|
||||
--background=file The background picture for a Finder window. |
||||
|
||||
--bgcol=r,g,b The background color for a Finder window. |
||||
|
||||
--toolbar=boolean The toolbar state for a Finder window. |
||||
|
||||
file The file or folder to be set. |
||||
|
||||
CLOSE MODE |
||||
Close Mode has the following options: |
||||
--close Select close mode. |
||||
|
||||
--volume=name The volume name for the disk image. |
||||
|
||||
file The output path for the .dmg file. |
||||
|
||||
EXAMPLES |
||||
OPEN MODE |
||||
To create a new disk image for "MyApp 1.0": |
||||
|
||||
dmgutil.pl --open --volume="MyApp 1.0" myapp_1.0.dmg |
||||
|
||||
SET MODE |
||||
To set the position of a file or folder: |
||||
|
||||
dmgutil.pl --set --x=100 --y=100 "/Volumes/MyApp 1.0/Read Me.rtf" |
||||
dmgutil.pl --set --x=200 --y=100 "/Volumes/MyApp 1.0/MyApp.app" |
||||
|
||||
To set the window size for the volume: |
||||
|
||||
dmgutil.pl --set --width=300 --height=200 "/Volumes/MyApp 1.0" |
||||
|
||||
To set the icon size for the volume: |
||||
|
||||
dmgutil.pl --set --iconsize=128 "/Volumes/MyApp 1.0" |
||||
|
||||
To set a custom icon for a volume, folder, or file: |
||||
|
||||
dmgutil.pl --set --icon=volume.icns "/Volumes/MyApp 1.0" |
||||
dmgutil.pl --set --icon=folder.icns "/Volumes/MyApp 1.0/Extras" |
||||
dmgutil.pl --set --icon=readme.icns "/Volumes/MyApp 1.0/Read Me.rtf" |
||||
|
||||
To set the background picture for the volume: |
||||
|
||||
dmgutil.pl --set --background=flowers.jpg "/Volumes/MyApp 1.0" |
||||
|
||||
To set the background color for the volume: |
||||
|
||||
dmgutil.pl --set --bgcol=0,65535,0 "/Volumes/MyApp 1.0" |
||||
|
||||
To hide the toolbar for the volume: |
||||
|
||||
dmgutil.pl --set --toolbar=false "/Volumes/MyApp 1.0" |
||||
|
||||
Multiple flags may be combined, to set all of the properties of an |
||||
item simultaneously. |
||||
|
||||
CLOSE MODE |
||||
To unmount and compress the disk image created for "MyApp 1.0": |
||||
|
||||
dmgutil.pl --close --volume="MyApp 1.0" myapp_1.0.dmg |
||||
|
||||
VERSION |
||||
dmgutil 1.1 |
||||
|
||||
COPYRIGHT |
||||
Copyright (c) refNum Software http://www.refnum.com/ |
||||
MANPAGE |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# appleScript : Execute an AppleScript. |
||||
#---------------------------------------------------------------------------- |
||||
sub appleScript |
||||
{ |
||||
|
||||
|
||||
# Retrieve our parameters |
||||
my ($theScript) = @_; |
||||
|
||||
|
||||
|
||||
# Save the script |
||||
my $theFile = "/tmp/dmgutil_applescript.txt"; |
||||
|
||||
open( OUTPUT, ">$theFile") or die "Can't open $theFile for writing: $!\n"; |
||||
print OUTPUT $theScript; |
||||
close(OUTPUT); |
||||
|
||||
|
||||
|
||||
# And execute it |
||||
system("osascript", $theFile); |
||||
unlink($theFile); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# isVolume : Is a path to the root of a volume? |
||||
#---------------------------------------------------------------------------- |
||||
sub isVolume |
||||
{ |
||||
|
||||
|
||||
# Retrieve our parameters |
||||
my ($thePath) = @_; |
||||
|
||||
|
||||
|
||||
# Check the state |
||||
# |
||||
# After stripping out the leading /Volumes, any further slashes |
||||
# indicate we have a folder rather than a volume. |
||||
$thePath =~ s/\/Volumes\///; |
||||
|
||||
my $isVolume = ($thePath =~ /.*\/.*/) ? 0 : 1; |
||||
|
||||
return($isVolume); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# setFolderState : Set the state for a folder. |
||||
#---------------------------------------------------------------------------- |
||||
sub setFolderState |
||||
{ |
||||
|
||||
|
||||
# Retrieve our parameters |
||||
my ($thePath, $iconSize, $flagToolbar, $bgImage, $bgColor) = @_; |
||||
|
||||
|
||||
|
||||
# Initialise ourselves |
||||
my $cmdBackground = ""; |
||||
my $cmdIconSize = ""; |
||||
my $cmdToolbar = ""; |
||||
|
||||
|
||||
|
||||
# Prepare the background |
||||
# |
||||
# As of 10.5, the Finder refuses to manipulate files whose names start with |
||||
# a period (rdar://5582578). As such we need to use an underscore for the |
||||
# image, then make it invisible using SetFile. |
||||
if (-f $bgImage) |
||||
{ |
||||
$bgImage =~ /.*\.(\w+)/; |
||||
my $dstImage = "$thePath/_Background.$1"; |
||||
|
||||
`cp "$bgImage" "$dstImage"`; |
||||
|
||||
$cmdBackground .= "set theImage to posix file \"$dstImage\"\n"; |
||||
$cmdBackground .= " set background picture of theOptions to theImage\n"; |
||||
$cmdBackground .= " do shell script \"/Developer/Tools/SetFile -a V '$dstImage'\"\n"; |
||||
} |
||||
|
||||
elsif ($bgColor ne "") |
||||
{ |
||||
$cmdBackground = "set background color of theOptions to {$bgColor} as RGB color"; |
||||
} |
||||
|
||||
|
||||
|
||||
# Prepare the icon size |
||||
if ($iconSize != 0) |
||||
{ |
||||
$cmdIconSize = "set icon size of theOptions to $iconSize"; |
||||
} |
||||
|
||||
|
||||
|
||||
# Prepare the toolbar |
||||
# |
||||
# The window must be made visible in order to change the toolbar state. |
||||
if ($flagToolbar ne "") |
||||
{ |
||||
$cmdToolbar = " open theWindow \n"; |
||||
$cmdToolbar .= " set toolbar visible of theWindow to $flagToolbar \n"; |
||||
$cmdToolbar .= " close theWindow \n"; |
||||
} |
||||
|
||||
|
||||
|
||||
# Identify the target |
||||
# |
||||
# AppleScript requires the correct nomenclature for the target item. |
||||
my $theTarget = "folder \"$thePath\""; |
||||
|
||||
if (isVolume($thePath)) |
||||
{ |
||||
$theTarget =~ s/folder "\/Volumes\//disk "/; |
||||
} |
||||
|
||||
|
||||
|
||||
# Set the folder state |
||||
# |
||||
# Once a change has been made, it must be flushed to disk with update. |
||||
my $theScript = ""; |
||||
|
||||
$theScript .= "tell application \"Finder\"\n"; |
||||
$theScript .= " set theTarget to $theTarget \n"; |
||||
$theScript .= " set theWindow to window of theTarget \n"; |
||||
$theScript .= "\n"; |
||||
$theScript .= " set current view of theWindow to icon view \n"; |
||||
$theScript .= " set theOptions to icon view options of theWindow \n"; |
||||
$theScript .= " set arrangement of theOptions to not arranged \n"; |
||||
$theScript .= "\n"; |
||||
$theScript .= " $cmdBackground\n"; |
||||
$theScript .= " $cmdIconSize \n"; |
||||
$theScript .= " $cmdToolbar \n"; |
||||
$theScript .= "\n"; |
||||
$theScript .= " update theTarget\n"; |
||||
$theScript .= "end tell"; |
||||
|
||||
appleScript($theScript); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# setCustomIcon : Set a custom icon. |
||||
#---------------------------------------------------------------------------- |
||||
sub setCustomIcon |
||||
{ |
||||
|
||||
|
||||
# Retrieve our parameters |
||||
my ($thePath, $theIcon) = @_; |
||||
|
||||
|
||||
|
||||
# Validate our state |
||||
# |
||||
# We require several tools inside /Developer/Tools. |
||||
die("Setting an icon requires $Rez") if (! -e $Rez); |
||||
die("Setting an icon requires $SetFile") if (! -e $SetFile); |
||||
|
||||
|
||||
|
||||
# Prepare the flags |
||||
# |
||||
# Prior to Mac OS X 10.4, SetFile can only set an attribute if it is |
||||
# first cleared (rdar://3738867). |
||||
my $sysVers = `uname -r`; |
||||
my $setHidden = ($sysVers =~ /^[0-7]\./) ? "vV" : "V"; |
||||
my $setIcon = ($sysVers =~ /^[0-7]\./) ? "cC" : "C"; |
||||
|
||||
|
||||
|
||||
# Set a volume icon |
||||
# |
||||
# Volume custom icons are contained in a .VolumeIcon.icns file. |
||||
if (isVolume($thePath)) |
||||
{ |
||||
my $iconFile = "$thePath/.VolumeIcon.icns"; |
||||
|
||||
`cp "$theIcon" "$iconFile"`; |
||||
|
||||
`$SetFile -a $setHidden "$iconFile"`; |
||||
`$SetFile -a $setIcon "$thePath"`; |
||||
} |
||||
|
||||
|
||||
# Set a folder icon |
||||
# |
||||
# Folder custom icons are contained in an ('icns', -16455) resource, |
||||
# placed in an invisible "Icon\r" file inside the folder. |
||||
elsif (-d $thePath) |
||||
{ |
||||
my $iconFile = "$thePath/Icon\r"; |
||||
my $tmpR = "/tmp/dmgutil.r"; |
||||
|
||||
`echo "read 'icns' (-16455) \\"$theIcon\\";\n" > $tmpR`; |
||||
`cd /tmp; $Rez dmgutil.r -append -o "$iconFile"`; |
||||
|
||||
`$SetFile -a $setHidden "$iconFile"`; |
||||
`$SetFile -a $setIcon "$thePath"`; |
||||
|
||||
unlink($tmpR); |
||||
} |
||||
|
||||
|
||||
# Set a file icon |
||||
# |
||||
# File custom icons are contained in an ('icns', -16455) resource. |
||||
else |
||||
{ |
||||
my $tmpR = "/tmp/dmgutil.r"; |
||||
|
||||
`echo "read 'icns' (-16455) \\"$theIcon\\";\n" > $tmpR`; |
||||
`cd /tmp; $Rez dmgutil.r -append -o "$thePath"`; |
||||
|
||||
`$SetFile -a $setIcon "$thePath"`; |
||||
|
||||
unlink($tmpR); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# setWindowPos : Set the position of a window. |
||||
#---------------------------------------------------------------------------- |
||||
sub setWindowPos |
||||
{ |
||||
|
||||
|
||||
# Retrieve our parameters |
||||
my ($thePath, $posX, $posY, $theWidth, $theHeight) = @_; |
||||
|
||||
|
||||
|
||||
# Initialise ourselves |
||||
my $bottom = $posY + $theHeight; |
||||
my $right = $posX + $theWidth; |
||||
|
||||
|
||||
|
||||
# Identify the target |
||||
# |
||||
# AppleScript requires the correct nomenclature for the target item. |
||||
my $theTarget = "folder \"$thePath\""; |
||||
|
||||
if (isVolume($thePath)) |
||||
{ |
||||
$theTarget =~ s/folder "\/Volumes\//disk "/; |
||||
} |
||||
|
||||
|
||||
|
||||
# Set the window position |
||||
# |
||||
# In theory, the "set bounds" command is all that should be necessary |
||||
# to set the bounds of a Finder window. |
||||
# |
||||
# Unfortunately, under 10.4 this will result in a window that will be |
||||
# taller than the specified size when the window is next opened. |
||||
# |
||||
# To reliably set the bounds of a window we must open the window, show |
||||
# the status bar, and set the window bounds to be 20 pixels taller (the |
||||
# height of the status bar) than necessary. |
||||
# |
||||
# The status bar can then be hidden, the window closed, and the bounds |
||||
# bounds will be the desired size when the window is next opened. |
||||
my $theScript = ""; |
||||
|
||||
$theScript .= "tell application \"Finder\"\n"; |
||||
$theScript .= " set theTarget to $theTarget \n"; |
||||
$theScript .= " set theWindow to window of theTarget \n"; |
||||
$theScript .= "\n"; |
||||
$theScript .= " open theWindow \n"; |
||||
$theScript .= " set statusbar visible of theWindow to true \n"; |
||||
$theScript .= " set bounds of theWindow to {$posX, $posY, $right, $bottom+20} \n"; |
||||
$theScript .= " set statusbar visible of theWindow to false \n"; |
||||
$theScript .= " close theWindow \n"; |
||||
$theScript .= "\n"; |
||||
$theScript .= "end tell"; |
||||
|
||||
appleScript($theScript); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# setIconPos : Set the position of an icon. |
||||
#---------------------------------------------------------------------------- |
||||
sub setIconPos |
||||
{ |
||||
|
||||
|
||||
# Retrieve our parameters |
||||
my ($theFile, $posX, $posY) = @_; |
||||
|
||||
|
||||
|
||||
# Identify the target |
||||
# |
||||
# Since the 'posix file' command follows symlinks, in order to set the |
||||
# position of a symlink (vs its target) we need to use an HFS path and |
||||
# reference it as a file rather than an alias. |
||||
my $theTarget = "alias (posix file \"$theFile\")"; |
||||
|
||||
if (-l $theFile) |
||||
{ |
||||
$theTarget = $theFile; |
||||
|
||||
$theTarget =~ s/\/Volumes\///; |
||||
$theTarget =~ s/\//:/g; |
||||
$theTarget = "file \"$theTarget\""; |
||||
} |
||||
|
||||
|
||||
|
||||
# Set the icon position |
||||
# |
||||
# Once a change has been made, it must be flushed to disk with update. |
||||
my $theScript = ""; |
||||
|
||||
$theScript .= "tell application \"Finder\"\n"; |
||||
$theScript .= " set theTarget to $theTarget \n"; |
||||
$theScript .= "\n"; |
||||
$theScript .= " set position of theTarget to {$posX, $posY} \n"; |
||||
$theScript .= " update theTarget\n"; |
||||
$theScript .= "end tell"; |
||||
|
||||
appleScript($theScript); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# doOpen : Open a new disk image. |
||||
#---------------------------------------------------------------------------- |
||||
sub doOpen |
||||
{ |
||||
|
||||
|
||||
# Retrieve our parameters |
||||
my ($dmgFile, $volName) = @_; |
||||
|
||||
|
||||
|
||||
# Clean up any previous image |
||||
system("rm", "-f", "$dmgFile.sparseimage"); |
||||
system("rm", "-f", "$dmgFile"); |
||||
|
||||
|
||||
|
||||
# Create the image |
||||
# |
||||
# A large sparse disk image is created, which will be shrunk down |
||||
# and compressed when the disk image is finally closed. |
||||
print " creating $dmgFile\n" if ($kLogging eq "-quiet"); |
||||
|
||||
system("hdiutil", "create", $dmgFile, |
||||
"-volname", $volName, |
||||
"-megabytes", "1000", |
||||
"-type", "SPARSE", |
||||
"-fs", "HFS+", |
||||
$kLogging); |
||||
|
||||
system("hdiutil", "mount", $kLogging, "$dmgFile.sparseimage"); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# doClose : Close a disk image. |
||||
#---------------------------------------------------------------------------- |
||||
sub doClose |
||||
{ |
||||
|
||||
|
||||
# Retrieve our parameters |
||||
my ($dmgFile, $volName) = @_; |
||||
|
||||
|
||||
|
||||
# Bless the volume |
||||
# |
||||
# Blessing the volume ensures that the volume always opens in the current |
||||
# view, overriding the user's "Open new windows in column view" preference. |
||||
system("bless", "--openfolder", "/Volumes/$volName"); |
||||
|
||||
|
||||
|
||||
# Compress the image |
||||
# |
||||
# On 10.5, the disk image must be ejected rather than unmounted to allow |
||||
# it to be converted from a sparse image to a compressed image. |
||||
print " compressing $dmgFile\n" if ($kLogging eq "-quiet"); |
||||
|
||||
system("hdiutil", "eject", $kLogging, "/Volumes/$volName"); |
||||
|
||||
system("hdiutil", "convert", "$dmgFile.sparseimage", |
||||
"-format", "UDZO", |
||||
"-o", $dmgFile, |
||||
"-imagekey", "zlib-level=9", |
||||
$kLogging); |
||||
|
||||
|
||||
|
||||
# Clean up |
||||
system("rm", "-f", "$dmgFile.sparseimage"); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# doSet : Set a file/folder state. |
||||
#---------------------------------------------------------------------------- |
||||
sub doSet |
||||
{ |
||||
|
||||
|
||||
# Retrieve our parameters |
||||
my ($thePath, $posX, $posY, $theWidth, $theHeight, $iconSize, $theIcon, $bgImage, $bgColor, $flagToolbar) = @_; |
||||
|
||||
|
||||
|
||||
# Set the custom icon |
||||
if ($theIcon ne "") |
||||
{ |
||||
setCustomIcon($thePath, $theIcon); |
||||
} |
||||
|
||||
|
||||
|
||||
# Set the folder state |
||||
if ($iconSize != 0 || $bgImage ne "" || $bgColor ne "" || $flagToolbar ne "") |
||||
{ |
||||
setFolderState($thePath, $iconSize, $flagToolbar, $bgImage, $bgColor); |
||||
} |
||||
|
||||
|
||||
|
||||
# Set the position |
||||
# |
||||
# Window position must be set after applying the folder state. |
||||
if ($posX != 0 && $posY != 0) |
||||
{ |
||||
if ($theWidth != 0 && $theHeight != 0) |
||||
{ |
||||
setWindowPos($thePath, $posX, $posY, $theWidth, $theHeight); |
||||
} |
||||
else |
||||
{ |
||||
setIconPos($thePath, $posX, $posY); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# dmgUtil : Manipulate a disk image. |
||||
#---------------------------------------------------------------------------- |
||||
sub dmgUtil |
||||
{ |
||||
|
||||
|
||||
# Retrieve our parameters |
||||
my ($doOpen, $doClose, $doSet) = (0, 0, 0); |
||||
my ($posX, $posY, $theWidth, $theHeight, $iconSize) = (0, 0, 0, 0, 0); |
||||
my ($volName, $theIcon, $bgImage, $bgColor, $flagToolbar) = ("", "", "", "", ""); |
||||
|
||||
GetOptions( "--open+", => \$doOpen, |
||||
"--close+", => \$doClose, |
||||
"--set+", => \$doSet, |
||||
"--volume=s", => \$volName, |
||||
"--x=i", => \$posX, |
||||
"--y=i", => \$posY, |
||||
"--width=i", => \$theWidth, |
||||
"--height=i", => \$theHeight, |
||||
"--iconsize=i", => \$iconSize, |
||||
"--icon=s", => \$theIcon, |
||||
"--background=s", => \$bgImage, |
||||
"--bgcol=s", => \$bgColor, |
||||
"--toolbar=s", => \$flagToolbar); |
||||
|
||||
my ($thePath) = @ARGV; |
||||
|
||||
$thePath = "" if (!defined($thePath)); |
||||
|
||||
|
||||
|
||||
# Perform the action |
||||
if ($doOpen && $thePath ne "" && $volName ne "") |
||||
{ |
||||
doOpen($thePath, $volName); |
||||
} |
||||
|
||||
elsif ($doClose && $thePath ne "" && $volName ne "") |
||||
{ |
||||
doClose($thePath, $volName); |
||||
} |
||||
|
||||
elsif ($doSet && $thePath ne "") |
||||
{ |
||||
doSet($thePath, $posX, $posY, $theWidth, $theHeight, $iconSize, $theIcon, $bgImage, $bgColor, $flagToolbar); |
||||
} |
||||
|
||||
else |
||||
{ |
||||
print $kManPage; |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# Script entry point |
||||
#---------------------------------------------------------------------------- |
||||
dmgUtil(); |
@ -0,0 +1,145 @@ |
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> |
||||
<html> |
||||
<head> |
||||
<title>refNum › dmgutil</title> |
||||
<!--HEAD_BEGIN--> |
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF8"> |
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="src/js/refnum.js"></script> |
||||
|
||||
<script type="text/javascript"> |
||||
var _gaq = _gaq || []; |
||||
_gaq.push(['_setAccount', 'UA-19561062-1']); |
||||
_gaq.push(['_trackPageview']); |
||||
|
||||
(function() { |
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; |
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; |
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); |
||||
})(); |
||||
</script> |
||||
|
||||
<link type="text/css" href="src/css/refnum.css" rel=stylesheet> |
||||
<!--HEAD_END--> |
||||
</head> |
||||
<body> |
||||
|
||||
<div id="content"> |
||||
<!--#include virtual="/src/inc/nav.inc" --> |
||||
<script language="javascript">navSelect("dev")</script> |
||||
|
||||
<a href="index.html"> |
||||
<div id="page_strap_frame" style="background:url('src/img/page_strap_dmgutil.png');"> |
||||
<div id="page_strap_content" style="background:url('src/img/page_strap_dmgutil.jpg'); background-repeat: no-repeat; background-position: 22px 16px;"></div></div></a> |
||||
<div id="page_body"> |
||||
<div id="page_content"> |
||||
|
||||
|
||||
|
||||
<table> |
||||
<tr> |
||||
<td valign=top> |
||||
<ul id="menu"> |
||||
<li class="subtitle">dmgutil</li> |
||||
<li><a href="index.html">Home</a></li> |
||||
<li><a href="licence.html">Licence</a></li> |
||||
<li><a href="version.html">Version History</a></li> |
||||
</ul> |
||||
</td> |
||||
<td valign=top> |
||||
|
||||
|
||||
|
||||
<h1>dmgutil</h1> |
||||
<p> |
||||
dmgutil is a command line tool for creating, configuring, and compressing Mac OS X |
||||
disk images for distribution. |
||||
</p> |
||||
|
||||
<p> |
||||
dmgutil allows you to automate your build process, preparing a release without pre-existing |
||||
templates or user interaction. |
||||
</p> |
||||
|
||||
<p> |
||||
dmgutil can adjust the size, position, and appearance of Finder windows. It can also apply |
||||
custom icons to volumes, folders, or files and assign a license agreement. |
||||
</p> |
||||
|
||||
<div class="box_button"> |
||||
<a href="http://www.refnum.com/files/dmgutil.zip" class="button icon_download"><span><span class="icon"></span>Download</span></a> |
||||
<span class="padding20"> </span> |
||||
<a href="http://github.com/refnum/dmgutil" class="button icon_github"><span><span class="icon"></span>GitHub</span></a> |
||||
</div> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h2>Using dmgutil</h2> |
||||
<p> |
||||
To create a new disk image for your "MyApp 1.0" release, invoke dmgutil as: |
||||
</p> |
||||
|
||||
<div class="box_code_yellow">dmgutil.pl --open --volume="MyApp 1.0" myapp_1.0.dmg |
||||
</div> |
||||
|
||||
<p> |
||||
Once the disk image has been populated with files, invoke dmgutil to configure it: |
||||
</p> |
||||
|
||||
<div class="box_code_yellow">dmgutil.pl --set --iconsize=128 --background=flowers.jpg "/Volumes/MyApp 1.0" |
||||
dmgutil.pl --set --x=20 --y=60 --width=300 --height=200 "/Volumes/MyApp 1.0" |
||||
</div> |
||||
|
||||
<p> |
||||
You can also use dmgutil to set the position of file or folder icons within the window: |
||||
</p> |
||||
|
||||
<div class="box_code_yellow">dmgutil.pl --set --x=100 --y=100 "/Volumes/MyApp 1.0/Read Me.rtf" |
||||
dmgutil.pl --set --x=200 --y=100 "/Volumes/MyApp 1.0/MyApp.app" |
||||
</div> |
||||
|
||||
<p> |
||||
dmgutil can also adjust the background color or toolbar visibility of the window, and |
||||
apply custom icons to the volume or its contents. |
||||
</p> |
||||
|
||||
<p> |
||||
Once the volume has been prepared, compress the disk image with: |
||||
</p> |
||||
|
||||
<div class="box_code_yellow">dmgutil.pl --close --volume="MyApp 1.0" myapp_1.0.dmg |
||||
</div> |
||||
|
||||
<p> |
||||
By invoking dmgutil from a post-build shell script, builds can be automatically converted |
||||
into a user-friendly disk image for distribution. |
||||
</p> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</td> |
||||
</tr> |
||||
</table> |
||||
|
||||
|
||||
|
||||
</div> |
||||
</div> |
||||
<div id="page_footer"></div> |
||||
</div> |
||||
|
||||
|
||||
|
||||
<!--FOOTER_BEGIN--> |
||||
<div id="footer"> |
||||
Copyright © 2006-2010 <a href="http://www.refnum.com/">refNum Software</a> |
||||
</div> |
||||
<!--FOOTER_END--> |
||||
</body> |
||||
</html> |
@ -0,0 +1,124 @@ |
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> |
||||
<html> |
||||
<head> |
||||
<title>refNum › dmgutil › Licence</title> |
||||
<!--HEAD_BEGIN--> |
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF8"> |
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="src/js/refnum.js"></script> |
||||
|
||||
<script type="text/javascript"> |
||||
var _gaq = _gaq || []; |
||||
_gaq.push(['_setAccount', 'UA-19561062-1']); |
||||
_gaq.push(['_trackPageview']); |
||||
|
||||
(function() { |
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; |
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; |
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); |
||||
})(); |
||||
</script> |
||||
|
||||
<link type="text/css" href="src/css/refnum.css" rel=stylesheet> |
||||
<!--HEAD_END--> |
||||
</head> |
||||
<body> |
||||
|
||||
<div id="content"> |
||||
<!--#include virtual="/src/inc/nav.inc" --> |
||||
<script language="javascript">navSelect("dev")</script> |
||||
|
||||
<a href="index.html"> |
||||
<div id="page_strap_frame" style="background:url('src/img/page_strap_dmgutil.png');"> |
||||
<div id="page_strap_content" style="background:url('src/img/page_strap_dmgutil.jpg'); background-repeat: no-repeat; background-position: 22px 16px;"></div></div></a> |
||||
<div id="page_body"> |
||||
<div id="page_content"> |
||||
|
||||
|
||||
|
||||
<table> |
||||
<tr> |
||||
<td valign=top> |
||||
<ul id="menu"> |
||||
<li class="subtitle">dmgutil</li> |
||||
<li><a href="index.html">Home</a></li> |
||||
<li><a href="licence.html">Licence</a></li> |
||||
<li><a href="version.html">Version History</a></li> |
||||
</ul> |
||||
</td> |
||||
<td valign=top> |
||||
|
||||
|
||||
|
||||
<h1>Licence</h1> |
||||
<p> |
||||
dmgutil is distributed under the Open Source BSD licence: |
||||
</p> |
||||
|
||||
<div class="box_licence"> |
||||
<p> |
||||
dmgutil is Copyright © 2006-2010, refNum Software<br> |
||||
All rights reserved. |
||||
</p> |
||||
|
||||
<p> |
||||
Redistribution and use in source and binary forms, with or without modification, are permitted |
||||
provided that the following conditions are met: |
||||
</p> |
||||
|
||||
<ul> |
||||
<li>Redistributions of source code must retain the above copyright notice, this list of |
||||
conditions and the following disclaimer.</li> |
||||
|
||||
<li>Redistributions in binary form must reproduce the above copyright notice, this list |
||||
of conditions and the following disclaimer in the documentation and/or other materials |
||||
provided with the distribution.</li> |
||||
|
||||
<li>Neither the name of refNum Software, Nano, nor the names of its contributors may be |
||||
used to endorse or promote products derived from this software without specific prior |
||||
written permission.</li> |
||||
</ul> |
||||
|
||||
<p> |
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR |
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER |
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
||||
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
</p> |
||||
</div> |
||||
|
||||
<p> |
||||
This licence allows usage in both Open Source and commercial software, and does not require any |
||||
reciprocal licencing or release of source code when incorporated into commercial software. |
||||
</p> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</td> |
||||
</tr> |
||||
</table> |
||||
|
||||
|
||||
|
||||
</div> |
||||
</div> |
||||
<div id="page_footer"></div> |
||||
</div> |
||||
|
||||
|
||||
|
||||
<!--FOOTER_BEGIN--> |
||||
<div id="footer"> |
||||
Copyright © 2006-2010 <a href="http://www.refnum.com/">refNum Software</a> |
||||
</div> |
||||
<!--FOOTER_END--> |
||||
</body> |
||||
</html> |
@ -0,0 +1,380 @@ |
||||
/* Global */ |
||||
html { |
||||
overflow-y: scroll; |
||||
} |
||||
body { |
||||
background: #600d0d url("../img/background.jpg") no-repeat fixed center top; |
||||
font: 12px "Lucida Grande", "Arial", sans-serif; |
||||
} |
||||
|
||||
#content { |
||||
width: 820px; |
||||
min-height: 500px; |
||||
margin: 75px auto 10px auto; |
||||
} |
||||
|
||||
#footer { |
||||
color: #eeeeee; |
||||
font: 9px "Monaco", "Courier", monospace; |
||||
text-align: center; |
||||
text-shadow: #444444 0px 2px 2px; |
||||
} |
||||
|
||||
#footer a { |
||||
color: #eeeeee; |
||||
border-bottom: none; |
||||
text-decoration: none; |
||||
} |
||||
|
||||
.caption { |
||||
color: #cccccc; |
||||
font: italic 11px "Lucida Grande", "Arial", sans-serif; |
||||
} |
||||
|
||||
h1, h2, h3, h4, h5 { |
||||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.05); |
||||
} |
||||
|
||||
a img { border: none; } |
||||
a:focus { outline: none; } |
||||
a:link { border-bottom: 1px dotted; text-decoration: none; } |
||||
a:visited { border-bottom: 1px dotted; text-decoration: none; } |
||||
a:active { border-bottom: 1px dotted; text-decoration: none; } |
||||
a:hover { border-bottom: 1px dotted; text-decoration: none; } |
||||
a.plain { border-bottom: none; } |
||||
|
||||
h1 { font-size: x-large; } |
||||
h2 { font-size: large; } |
||||
h3 { font-size: medium; } |
||||
h4 { font-size: small; } |
||||
h5 { font-size: x-small; } |
||||
h6 { font-size: xx-small; } |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Navigation */ |
||||
#nav { |
||||
width: 820px; |
||||
height: 45px; |
||||
margin-top: 20px; |
||||
margin-bottom: 10px; |
||||
} |
||||
|
||||
#nav_bar { |
||||
float: right; |
||||
padding-right: 15px; |
||||
} |
||||
|
||||
#nav a { |
||||
display: -moz-inline-stack; |
||||
display: inline-block; |
||||
height: 45px; |
||||
border-bottom: none; |
||||
} |
||||
|
||||
#nav a#apps { width:78px; } |
||||
#nav a#apps { background-image:url("../img/nav_apps_normal.png"); } |
||||
#nav a#apps:hover { background-image:url("../img/nav_apps_hover.png"); } |
||||
#nav a#apps.selected { background-image:url("../img/nav_apps_selected.png"); } |
||||
|
||||
#nav a#projects { width:90px; } |
||||
#nav a#projects { background-image:url("../img/nav_projects_normal.png"); } |
||||
#nav a#projects:hover { background-image:url("../img/nav_projects_hover.png"); } |
||||
#nav a#projects.selected { background-image:url("../img/nav_projects_selected.png"); } |
||||
|
||||
#nav a#contact { width:86px; } |
||||
#nav a#contact { background-image:url("../img/nav_contact_normal.png"); } |
||||
#nav a#contact:hover { background-image:url("../img/nav_contact_hover.png"); } |
||||
#nav a#contact.selected { background-image:url("../img/nav_contact_selected.png"); } |
||||
|
||||
#nav a#dev { width:78px; } |
||||
#nav a#dev { background-image:url("../img/nav_dev_normal.png"); } |
||||
#nav a#dev:hover { background-image:url("../img/nav_dev_hover.png"); } |
||||
#nav a#dev.selected { background-image:url("../img/nav_dev_selected.png"); } |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Menu */ |
||||
#menu { |
||||
margin: 0px; |
||||
padding: 0px; |
||||
width: 140px; |
||||
font-size: 11px; |
||||
line-height: 17px; |
||||
list-style-type: none; |
||||
} |
||||
|
||||
#menu .subtitle { |
||||
margin-top: 10px; |
||||
font-weight: bold; |
||||
color: #222222; |
||||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.05); |
||||
} |
||||
|
||||
#menu a { |
||||
color: #444444; |
||||
text-decoration: none; |
||||
border-bottom: none; |
||||
} |
||||
|
||||
#menu li a:hover, |
||||
#menu li a:active { |
||||
border-bottom: 1px dotted; |
||||
text-decoration: none; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Page */ |
||||
#page_strap_frame { |
||||
width: 820px; |
||||
height: 215px; |
||||
} |
||||
|
||||
#page_strap_content { |
||||
width: 820px; |
||||
height: 215px; |
||||
} |
||||
|
||||
#page_body { |
||||
background: url("../img/page_body.png") repeat-y; |
||||
width: 820px; |
||||
min-height: 190px; |
||||
} |
||||
|
||||
#page_content { |
||||
padding: 5px 40px; |
||||
} |
||||
|
||||
#page_footer { |
||||
background: url("../img/page_footer.png"); |
||||
width: 820px; |
||||
height: 30px; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Home */ |
||||
#logo { |
||||
width: 440px; |
||||
height: 620px; |
||||
margin: auto; |
||||
} |
||||
|
||||
#logo_offset { |
||||
height: 120px; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Tables */ |
||||
table.icons { |
||||
border-spacing: 40px 5px; |
||||
} |
||||
|
||||
table.icons td { |
||||
vertical-align: top; |
||||
text-align: center; |
||||
width: 128px; |
||||
} |
||||
|
||||
table.icons img { |
||||
width: 128px; |
||||
height: 128px; |
||||
} |
||||
|
||||
table.badges { |
||||
margin: 40px auto 20px auto; |
||||
width: 80%; |
||||
} |
||||
|
||||
table.list_header { |
||||
background: #ddddff; |
||||
font-weight: bold; |
||||
line-height: 200%; |
||||
margin: 20px 10px 0px 10px; |
||||
padding-left: 10px; |
||||
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1); |
||||
width: 95%; |
||||
|
||||
-moz-border-radius-topright: 5px; |
||||
-moz-border-radius-topleft: 5px; |
||||
|
||||
-webkit-border-top-right-radius: 5px; |
||||
-webkit-border-top-left-radius: 5px; |
||||
} |
||||
|
||||
table.list { |
||||
background: #eeeeff; |
||||
background: -webkit-gradient(linear, left top, left bottom, from(#eeeeff), to(#fcfcff)); |
||||
margin: 0px 10px 0px 10px; |
||||
padding-left: 10px; |
||||
width: 95%; |
||||
|
||||
-moz-border-radius-bottomright: 5px; |
||||
-moz-border-radius-bottomleft: 5px; |
||||
|
||||
-webkit-border-bottom-right-radius: 5px; |
||||
-webkit-border-bottom-left-radius: 5px; |
||||
} |
||||
|
||||
table.list th { |
||||
font-weight: normal; |
||||
text-align: left; |
||||
width: 150px; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Boxes */ |
||||
.box { |
||||
-moz-border-radius: 5px; |
||||
-webkit-border-radius: 5px; |
||||
} |
||||
|
||||
.box_image { |
||||
border: 1px solid #888888; |
||||
} |
||||
|
||||
.box_button { |
||||
text-align: center; |
||||
margin: 24px; |
||||
} |
||||
|
||||
.box_code_yellow { |
||||
-moz-border-radius: 5px; |
||||
-webkit-border-radius: 5px; |
||||
font-family: monospace; |
||||
white-space: pre; |
||||
font-size: 12px; |
||||
border: 1px solid #bbbbbb; |
||||
padding: 10px; |
||||
background: #ffffe0; |
||||
background: -webkit-gradient(linear, left top, right top, from(#fffff0), to(#fffffd)); |
||||
} |
||||
|
||||
.box_licence { |
||||
-moz-border-radius: 5px; |
||||
-webkit-border-radius: 5px; |
||||
font-family: monospace; |
||||
font-size: 12px; |
||||
background-color: #eeeeff; |
||||
border: 1px solid #bbbbbb; |
||||
padding: 10px; |
||||
background: -webkit-gradient(linear, left top, right top, from(#eeeeff), to(#fefeff)); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Layout */ |
||||
.padding20 { |
||||
padding: 20px; |
||||
} |
||||
|
||||
.width450 { |
||||
width: 450px; |
||||
height: auto; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Buttons */ |
||||
a.button { |
||||
display: inline-block; |
||||
height: 23px; |
||||
padding: 0 0 0 3px; |
||||
font-size: 11px; |
||||
font-weight: bold; |
||||
color: #333333; |
||||
text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.9); |
||||
background: url('../img/button_thin_cell.png') 0 0 no-repeat; |
||||
white-space: nowrap; |
||||
border: none; |
||||
overflow: visible; |
||||
cursor: pointer; |
||||
text-decoration: none; |
||||
} |
||||
|
||||
a.button>span { |
||||
display: block; |
||||
height: 23px; |
||||
padding: 0 10px 0 8px; |
||||
line-height: 23px; |
||||
background: url('../img/button_thin_cell.png') 100% 0 no-repeat; |
||||
} |
||||
|
||||
a.button:hover, |
||||
a.button:focus { |
||||
color: #ffffff; |
||||
text-decoration: none; |
||||
text-shadow: -1px -1px 0 rgba(0, 0, 0, 0.3); |
||||
background-position: 0 -30px; |
||||
} |
||||
a.button:hover>span, |
||||
a.button:focus>span { |
||||
background-position: 100% -30px; |
||||
} |
||||
|
||||
a.button:active { |
||||
background-position: 0 -60px; |
||||
} |
||||
|
||||
a.button:active>span { |
||||
background-position: 100% -60px; |
||||
} |
||||
|
||||
|
||||
a.icon_download .icon, |
||||
a.icon_github .icon { |
||||
float: left; |
||||
margin-left: -4px; |
||||
width: 18px; |
||||
height: 22px; |
||||
background: url('../img/button_thin_icons.png') 0 0 no-repeat; |
||||
} |
||||
|
||||
|
||||
a.icon_download .icon { |
||||
background-position: -0px 0; |
||||
} |
||||
|
||||
a.icon_download:hover .icon, |
||||
a.icon_download:focus .icon { |
||||
background-position: -0px -25px; |
||||
} |
||||
|
||||
|
||||
a.icon_github .icon { |
||||
background-position: -20px 0; |
||||
} |
||||
|
||||
a.icon_github:hover .icon, |
||||
a.icon_github:focus .icon { |
||||
background-position: -20px -25px; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 437 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 3.6 KiB |
@ -0,0 +1,34 @@ |
||||
function loadImage(theURL) |
||||
{ |
||||
theImage = new Image; |
||||
theImage.src = theURL; |
||||
} |
||||
|
||||
|
||||
function navSelect(theID) |
||||
{ |
||||
document.getElementById(theID).setAttribute("class", "selected"); |
||||
} |
||||
|
||||
|
||||
var prevOnLoad = window.onload; |
||||
window.onload = function() |
||||
{ |
||||
if (prevOnLoad) |
||||
prevOnLoad(); |
||||
|
||||
|
||||
// Preload images
|
||||
if (document.domain != "") |
||||
{ |
||||
loadImage("/src/img/nav_apps_hover.png"); |
||||
loadImage("/src/img/nav_apps_selected.png"); |
||||
loadImage("/src/img/nav_projects_hover.png"); |
||||
loadImage("/src/img/nav_projects_selected.png"); |
||||
loadImage("/src/img/nav_contact_hover.png"); |
||||
loadImage("/src/img/nav_contact_selected.png"); |
||||
loadImage("/src/img/nav_dev_hover.png"); |
||||
loadImage("/src/img/nav_dev_selected.png"); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,109 @@ |
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> |
||||
<html> |
||||
<head> |
||||
<title>refNum › dmgutil › Version History</title> |
||||
<!--HEAD_BEGIN--> |
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF8"> |
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="src/js/refnum.js"></script> |
||||
|
||||
<script type="text/javascript"> |
||||
var _gaq = _gaq || []; |
||||
_gaq.push(['_setAccount', 'UA-19561062-1']); |
||||
_gaq.push(['_trackPageview']); |
||||
|
||||
(function() { |
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; |
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; |
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); |
||||
})(); |
||||
</script> |
||||
|
||||
<link type="text/css" href="src/css/refnum.css" rel=stylesheet> |
||||
<!--HEAD_END--> |
||||
</head> |
||||
<body> |
||||
|
||||
<div id="content"> |
||||
<!--#include virtual="/src/inc/nav.inc" --> |
||||
<script language="javascript">navSelect("dev")</script> |
||||
|
||||
<a href="index.html"> |
||||
<div id="page_strap_frame" style="background:url('src/img/page_strap_dmgutil.png');"> |
||||
<div id="page_strap_content" style="background:url('src/img/page_strap_dmgutil.jpg'); background-repeat: no-repeat; background-position: 22px 16px;"></div></div></a> |
||||
<div id="page_body"> |
||||
<div id="page_content"> |
||||
|
||||
|
||||
|
||||
<table> |
||||
<tr> |
||||
<td valign=top> |
||||
<ul id="menu"> |
||||
<li class="subtitle">dmgutil</li> |
||||
<li><a href="index.html">Home</a></li> |
||||
<li><a href="licence.html">Licence</a></li> |
||||
<li><a href="version.html">Version History</a></li> |
||||
</ul> |
||||
</td> |
||||
<td valign=top> |
||||
|
||||
|
||||
|
||||
<h1>Version History</h1> |
||||
<h2>dmgutil 1.3</h2> |
||||
<ul> |
||||
<li>Released 2008/05/01 |
||||
<li>Added workaround for Finder bug when setting background image on 10.5 |
||||
<li>Added workaround for hdiutil bug when closing disk image on 10.5 |
||||
</ul> |
||||
|
||||
|
||||
<h2>dmgutil 1.2</h2> |
||||
<ul> |
||||
<li>Released 2007/03/07 |
||||
<li>Fixed typo in zlib-level flag, was defaulting to 1 not 9 |
||||
</ul> |
||||
|
||||
|
||||
<h2>dmgutil 1.1</h2> |
||||
<ul> |
||||
<li>Released 2006/07/31 |
||||
<li>Added <tt>--icon</tt> parameter to set custom icons |
||||
<li>Added <tt>--bgcol</tt> parameter to set background color |
||||
<li>Added <tt>--toolbar</tt> flag to control toolbar visibility |
||||
</ul> |
||||
|
||||
|
||||
<h2>dmgutil 1.0</h2> |
||||
<ul> |
||||
<li>Released 2006/07/22 |
||||
<li>Initial release |
||||
</ul> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</td> |
||||
</tr> |
||||
</table> |
||||
|
||||
|
||||
|
||||
</div> |
||||
</div> |
||||
<div id="page_footer"></div> |
||||
</div> |
||||
|
||||
|
||||
|
||||
<!--FOOTER_BEGIN--> |
||||
<div id="footer"> |
||||
Copyright © 2006-2010 <a href="http://www.refnum.com/">refNum Software</a> |
||||
</div> |
||||
<!--FOOTER_END--> |
||||
</body> |
||||
</html> |
@ -0,0 +1,738 @@ |
||||
#!/usr/bin/perl -w |
||||
#============================================================================ |
||||
# NAME: |
||||
# dmgutil.pl |
||||
# |
||||
# DESCRIPTION: |
||||
# Disk image creation utility. |
||||
# |
||||
# COPYRIGHT: |
||||
# Copyright (c) 2006-2009, refNum Software |
||||
# <http://www.refnum.com/> |
||||
# |
||||
# All rights reserved. |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions |
||||
# are met: |
||||
# |
||||
# o Redistributions of source code must retain the above |
||||
# copyright notice, this list of conditions and the following |
||||
# disclaimer. |
||||
# |
||||
# o Redistributions in binary form must reproduce the above |
||||
# copyright notice, this list of conditions and the following |
||||
# disclaimer in the documentation and/or other materials |
||||
# provided with the distribution. |
||||
# |
||||
# o Neither the name of refNum Software nor the names of its |
||||
# contributors may be used to endorse or promote products derived |
||||
# from this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
#============================================================================ |
||||
# Imports |
||||
#---------------------------------------------------------------------------- |
||||
use strict; |
||||
use Getopt::Long; |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# Constants |
||||
#---------------------------------------------------------------------------- |
||||
my $kLogging = "-quiet"; |
||||
|
||||
my $Rez = "/Developer/Tools/Rez"; |
||||
my $SetFile = "/Developer/Tools/SetFile"; |
||||
|
||||
my $kManPage = <<MANPAGE; |
||||
NAME |
||||
dmgutil -- create, adjust, and compress a distribution disk image |
||||
|
||||
SYNOPSIS |
||||
dmgutil --help |
||||
|
||||
dmgutil --open --volume=name file |
||||
|
||||
dmgutil --set [--x=integer] [--y=integer] |
||||
[--width=integer] [--height=integer] |
||||
[--iconsize=integer] [--icon=file] |
||||
[--background=file] [--bgcol=r,g,b] |
||||
[--toolbar=boolean] file |
||||
|
||||
dmgutil --close --volume=name [--license=file] file |
||||
|
||||
DESCRIPTION |
||||
dmgutil is used to create distribution disk images, and to adjust |
||||
the Finder view settings of these volumes or their contents. |
||||
|
||||
It can be invoked in three modes: open, set, and close. |
||||
|
||||
OPEN MODE |
||||
Open Mode has the following options: |
||||
--open Select open mode. |
||||
|
||||
--volume=name The volume name for the disk image. |
||||
|
||||
file The output path for the .dmg file. |
||||
|
||||
SET MODE |
||||
Set Mode has the following options: |
||||
--set Select set mode. |
||||
|
||||
--x=integer The x coordinate of the item. |
||||
|
||||
--y=integer The y coordinate of the item. |
||||
|
||||
--width=integer The width for a Finder window. |
||||
|
||||
--height=integer The height for a Finder window. |
||||
|
||||
--iconsize=integer The icon size for a Finder window. |
||||
|
||||
--icon=file.icns The icon to apply to the item. |
||||
|
||||
--background=file The background picture for a Finder window. |
||||
|
||||
--bgcol=r,g,b The background color for a Finder window. |
||||
|
||||
--toolbar=boolean The toolbar state for a Finder window. |
||||
|
||||
file The file or folder to be set. |
||||
|
||||
CLOSE MODE |
||||
Close Mode has the following options: |
||||
--close Select close mode. |
||||
|
||||
--volume=name The volume name for the disk image. |
||||
|
||||
--license=file The license agreement resource. |
||||
|
||||
file The output path for the .dmg file. |
||||
|
||||
EXAMPLES |
||||
OPEN MODE |
||||
To create a new disk image for "MyApp 1.0": |
||||
|
||||
dmgutil.pl --open --volume="MyApp 1.0" myapp_1.0.dmg |
||||
|
||||
SET MODE |
||||
To set the position of a file or folder: |
||||
|
||||
dmgutil.pl --set --x=100 --y=100 "/Volumes/MyApp 1.0/Read Me.rtf" |
||||
dmgutil.pl --set --x=200 --y=100 "/Volumes/MyApp 1.0/MyApp.app" |
||||
|
||||
To set the window size for the volume: |
||||
|
||||
dmgutil.pl --set --width=300 --height=200 "/Volumes/MyApp 1.0" |
||||
|
||||
To set the icon size for the volume: |
||||
|
||||
dmgutil.pl --set --iconsize=128 "/Volumes/MyApp 1.0" |
||||
|
||||
To set a custom icon for a volume, folder, or file: |
||||
|
||||
dmgutil.pl --set --icon=volume.icns "/Volumes/MyApp 1.0" |
||||
dmgutil.pl --set --icon=folder.icns "/Volumes/MyApp 1.0/Extras" |
||||
dmgutil.pl --set --icon=readme.icns "/Volumes/MyApp 1.0/Read Me.rtf" |
||||
|
||||
To set the background picture for the volume: |
||||
|
||||
dmgutil.pl --set --background=flowers.jpg "/Volumes/MyApp 1.0" |
||||
|
||||
To set the background color for the volume: |
||||
|
||||
dmgutil.pl --set --bgcol=0,65535,0 "/Volumes/MyApp 1.0" |
||||
|
||||
To hide the toolbar for the volume: |
||||
|
||||
dmgutil.pl --set --toolbar=false "/Volumes/MyApp 1.0" |
||||
|
||||
Multiple flags may be combined, to set all of the properties of an |
||||
item simultaneously. |
||||
|
||||
CLOSE MODE |
||||
To unmount and compress the disk image created for "MyApp 1.0": |
||||
|
||||
dmgutil.pl --close --volume="MyApp 1.0" myapp_1.0.dmg |
||||
|
||||
VERSION |
||||
dmgutil 1.1 |
||||
|
||||
COPYRIGHT |
||||
Copyright (c) refNum Software http://www.refnum.com/ |
||||
MANPAGE |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# appleScript : Execute an AppleScript. |
||||
#---------------------------------------------------------------------------- |
||||
sub appleScript |
||||
{ |
||||
|
||||
|
||||
# Retrieve our parameters |
||||
my ($theScript) = @_; |
||||
|
||||
|
||||
|
||||
# Save the script |
||||
my $theFile = "/tmp/dmgutil_applescript.txt"; |
||||
|
||||
open( OUTPUT, ">$theFile") or die "Can't open $theFile for writing: $!\n"; |
||||
print OUTPUT $theScript; |
||||
close(OUTPUT); |
||||
|
||||
|
||||
|
||||
# And execute it |
||||
system("osascript", $theFile); |
||||
unlink($theFile); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# isVolume : Is a path to the root of a volume? |
||||
#---------------------------------------------------------------------------- |
||||
sub isVolume |
||||
{ |
||||
|
||||
|
||||
# Retrieve our parameters |
||||
my ($thePath) = @_; |
||||
|
||||
|
||||
|
||||
# Check the state |
||||
# |
||||
# After stripping out the leading /Volumes, any further slashes |
||||
# indicate we have a folder rather than a volume. |
||||
$thePath =~ s/\/Volumes\///; |
||||
|
||||
my $isVolume = ($thePath =~ /.*\/.*/) ? 0 : 1; |
||||
|
||||
return($isVolume); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# setFolderState : Set the state for a folder. |
||||
#---------------------------------------------------------------------------- |
||||
sub setFolderState |
||||
{ |
||||
|
||||
|
||||
# Retrieve our parameters |
||||
my ($thePath, $iconSize, $flagToolbar, $bgImage, $bgColor) = @_; |
||||
|
||||
|
||||
|
||||
# Initialise ourselves |
||||
my $cmdBackground = ""; |
||||
my $cmdIconSize = ""; |
||||
my $cmdToolbar = ""; |
||||
|
||||
|
||||
|
||||
# Prepare the background |
||||
# |
||||
# As of 10.5, the Finder refuses to manipulate files whose names start with |
||||
# a period (rdar://5582578). As such we need to use an underscore for the |
||||
# image, then make it invisible using SetFile. |
||||
if (-f $bgImage) |
||||
{ |
||||
$bgImage =~ /.*\.(\w+)/; |
||||
my $dstImage = "$thePath/_Background.$1"; |
||||
|
||||
`cp "$bgImage" "$dstImage"`; |
||||
|
||||
$cmdBackground .= "set theImage to posix file \"$dstImage\"\n"; |
||||
$cmdBackground .= " set background picture of theOptions to theImage\n"; |
||||
$cmdBackground .= " do shell script \"/Developer/Tools/SetFile -a V '$dstImage'\"\n"; |
||||
} |
||||
|
||||
elsif ($bgColor ne "") |
||||
{ |
||||
$cmdBackground = "set background color of theOptions to {$bgColor} as RGB color"; |
||||
} |
||||
|
||||
|
||||
|
||||
# Prepare the icon size |
||||
if ($iconSize != 0) |
||||
{ |
||||
$cmdIconSize = "set icon size of theOptions to $iconSize"; |
||||
} |
||||
|
||||
|
||||
|
||||
# Prepare the toolbar |
||||
# |
||||
# The window must be made visible in order to change the toolbar state. |
||||
if ($flagToolbar ne "") |
||||
{ |
||||
$cmdToolbar = " open theWindow \n"; |
||||
$cmdToolbar .= " set toolbar visible of theWindow to $flagToolbar \n"; |
||||
$cmdToolbar .= " close theWindow \n"; |
||||
} |
||||
|
||||
|
||||
|
||||
# Identify the target |
||||
# |
||||
# AppleScript requires the correct nomenclature for the target item. |
||||
my $theTarget = "folder \"$thePath\""; |
||||
|
||||
if (isVolume($thePath)) |
||||
{ |
||||
$theTarget =~ s/folder "\/Volumes\//disk "/; |
||||
} |
||||
|
||||
|
||||
|
||||
# Set the folder state |
||||
# |
||||
# Once a change has been made, it must be flushed to disk with update. |
||||
my $theScript = ""; |
||||
|
||||
$theScript .= "tell application \"Finder\"\n"; |
||||
$theScript .= " set theTarget to $theTarget \n"; |
||||
$theScript .= " set theWindow to window of theTarget \n"; |
||||
$theScript .= "\n"; |
||||
$theScript .= " set current view of theWindow to icon view \n"; |
||||
$theScript .= " set theOptions to icon view options of theWindow \n"; |
||||
$theScript .= " set arrangement of theOptions to not arranged \n"; |
||||
$theScript .= "\n"; |
||||
$theScript .= " $cmdBackground\n"; |
||||
$theScript .= " $cmdIconSize \n"; |
||||
$theScript .= " $cmdToolbar \n"; |
||||
$theScript .= "\n"; |
||||
$theScript .= " update theTarget\n"; |
||||
$theScript .= "end tell"; |
||||
|
||||
appleScript($theScript); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# setCustomIcon : Set a custom icon. |
||||
#---------------------------------------------------------------------------- |
||||
sub setCustomIcon |
||||
{ |
||||
|
||||
|
||||
# Retrieve our parameters |
||||
my ($thePath, $theIcon) = @_; |
||||
|
||||
|
||||
|
||||
# Validate our state |
||||
# |
||||
# We require several tools inside /Developer/Tools. |
||||
die("Setting an icon requires $Rez") if (! -e $Rez); |
||||
die("Setting an icon requires $SetFile") if (! -e $SetFile); |
||||
|
||||
|
||||
|
||||
# Prepare the flags |
||||
# |
||||
# Prior to Mac OS X 10.4, SetFile can only set an attribute if it is |
||||
# first cleared (rdar://3738867). |
||||
my $sysVers = `uname -r`; |
||||
my $setHidden = ($sysVers =~ /^[0-7]\./) ? "vV" : "V"; |
||||
my $setIcon = ($sysVers =~ /^[0-7]\./) ? "cC" : "C"; |
||||
|
||||
|
||||
|
||||
# Set a volume icon |
||||
# |
||||
# Volume custom icons are contained in a .VolumeIcon.icns file. |
||||
if (isVolume($thePath)) |
||||
{ |
||||
my $iconFile = "$thePath/.VolumeIcon.icns"; |
||||
|
||||
`cp "$theIcon" "$iconFile"`; |
||||
|
||||
`$SetFile -a $setHidden "$iconFile"`; |
||||
`$SetFile -a $setIcon "$thePath"`; |
||||
} |
||||
|
||||
|
||||
# Set a folder icon |
||||
# |
||||
# Folder custom icons are contained in an ('icns', -16455) resource, |
||||
# placed in an invisible "Icon\r" file inside the folder. |
||||
elsif (-d $thePath) |
||||
{ |
||||
my $iconFile = "$thePath/Icon\r"; |
||||
my $tmpR = "/tmp/dmgutil.r"; |
||||
|
||||
`echo "read 'icns' (-16455) \\"$theIcon\\";\n" > $tmpR`; |
||||
`cd /tmp; $Rez dmgutil.r -append -o "$iconFile"`; |
||||
|
||||
`$SetFile -a $setHidden "$iconFile"`; |
||||
`$SetFile -a $setIcon "$thePath"`; |
||||
|
||||
unlink($tmpR); |
||||
} |
||||
|
||||
|
||||
# Set a file icon |
||||
# |
||||
# File custom icons are contained in an ('icns', -16455) resource. |
||||
else |
||||
{ |
||||
my $tmpR = "/tmp/dmgutil.r"; |
||||
|
||||
`echo "read 'icns' (-16455) \\"$theIcon\\";\n" > $tmpR`; |
||||
`cd /tmp; $Rez dmgutil.r -append -o "$thePath"`; |
||||
|
||||
`$SetFile -a $setIcon "$thePath"`; |
||||
|
||||
unlink($tmpR); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# setWindowPos : Set the position of a window. |
||||
#---------------------------------------------------------------------------- |
||||
sub setWindowPos |
||||
{ |
||||
|
||||
|
||||
# Retrieve our parameters |
||||
my ($thePath, $posX, $posY, $theWidth, $theHeight) = @_; |
||||
|
||||
|
||||
|
||||
# Initialise ourselves |
||||
my $bottom = $posY + $theHeight; |
||||
my $right = $posX + $theWidth; |
||||
|
||||
|
||||
|
||||
# Identify the target |
||||
# |
||||
# AppleScript requires the correct nomenclature for the target item. |
||||
my $theTarget = "folder \"$thePath\""; |
||||
|
||||
if (isVolume($thePath)) |
||||
{ |
||||
$theTarget =~ s/folder "\/Volumes\//disk "/; |
||||
} |
||||
|
||||
|
||||
|
||||
# Set the window position |
||||
# |
||||
# In theory, the "set bounds" command is all that should be necessary |
||||
# to set the bounds of a Finder window. |
||||
# |
||||
# Unfortunately, under 10.4 this will result in a window that will be |
||||
# taller than the specified size when the window is next opened. |
||||
# |
||||
# To reliably set the bounds of a window we must open the window, show |
||||
# the status bar, and set the window bounds to be 20 pixels taller (the |
||||
# height of the status bar) than necessary. |
||||
# |
||||
# The status bar can then be hidden, the window closed, and the bounds |
||||
# bounds will be the desired size when the window is next opened. |
||||
my $theScript = ""; |
||||
|
||||
$theScript .= "tell application \"Finder\"\n"; |
||||
$theScript .= " set theTarget to $theTarget \n"; |
||||
$theScript .= " set theWindow to window of theTarget \n"; |
||||
$theScript .= "\n"; |
||||
$theScript .= " open theWindow \n"; |
||||
$theScript .= " set statusbar visible of theWindow to true \n"; |
||||
$theScript .= " set bounds of theWindow to {$posX, $posY, $right, $bottom+20} \n"; |
||||
$theScript .= " set statusbar visible of theWindow to false \n"; |
||||
$theScript .= " close theWindow \n"; |
||||
$theScript .= "\n"; |
||||
$theScript .= "end tell"; |
||||
|
||||
appleScript($theScript); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# setIconPos : Set the position of an icon. |
||||
#---------------------------------------------------------------------------- |
||||
sub setIconPos |
||||
{ |
||||
|
||||
|
||||
# Retrieve our parameters |
||||
my ($theFile, $posX, $posY) = @_; |
||||
|
||||
|
||||
|
||||
# Identify the target |
||||
# |
||||
# Since the 'posix file' command follows symlinks, in order to set the |
||||
# position of a symlink (vs its target) we need to use an HFS path and |
||||
# reference it as a file rather than an alias. |
||||
my $theTarget = "alias (posix file \"$theFile\")"; |
||||
|
||||
if (-l $theFile) |
||||
{ |
||||
$theTarget = $theFile; |
||||
|
||||
$theTarget =~ s/\/Volumes\///; |
||||
$theTarget =~ s/\//:/g; |
||||
$theTarget = "file \"$theTarget\""; |
||||
} |
||||
|
||||
|
||||
|
||||
# Set the icon position |
||||
# |
||||
# Once a change has been made, it must be flushed to disk with update. |
||||
my $theScript = ""; |
||||
|
||||
$theScript .= "tell application \"Finder\"\n"; |
||||
$theScript .= " set theTarget to $theTarget \n"; |
||||
$theScript .= "\n"; |
||||
$theScript .= " set position of theTarget to {$posX, $posY} \n"; |
||||
$theScript .= " update theTarget\n"; |
||||
$theScript .= "end tell"; |
||||
|
||||
appleScript($theScript); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# doOpen : Open a new disk image. |
||||
#---------------------------------------------------------------------------- |
||||
sub doOpen |
||||
{ |
||||
|
||||
|
||||
# Retrieve our parameters |
||||
my ($dmgFile, $volName) = @_; |
||||
|
||||
|
||||
|
||||
# Clean up any previous image |
||||
system("rm", "-f", "$dmgFile.sparseimage"); |
||||
system("rm", "-f", "$dmgFile"); |
||||
|
||||
|
||||
|
||||
# Create the image |
||||
# |
||||
# A large sparse disk image is created, which will be shrunk down |
||||
# and compressed when the disk image is finally closed. |
||||
print " creating $dmgFile\n" if ($kLogging eq "-quiet"); |
||||
|
||||
system("hdiutil", "create", $dmgFile, |
||||
"-volname", $volName, |
||||
"-megabytes", "1000", |
||||
"-type", "SPARSE", |
||||
"-fs", "HFS+", |
||||
$kLogging); |
||||
|
||||
system("hdiutil", "mount", $kLogging, "$dmgFile.sparseimage"); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# doClose : Close a disk image. |
||||
#---------------------------------------------------------------------------- |
||||
sub doClose |
||||
{ |
||||
|
||||
|
||||
# Retrieve our parameters |
||||
my ($dmgFile, $volName, $theLicense) = @_; |
||||
|
||||
|
||||
|
||||
# Bless the volume |
||||
# |
||||
# Blessing the volume ensures that the volume always opens in the current |
||||
# view, overriding the user's "Open new windows in column view" preference. |
||||
system("bless", "--openfolder", "/Volumes/$volName"); |
||||
|
||||
|
||||
|
||||
# Compress the image |
||||
# |
||||
# On 10.5, the disk image must be ejected rather than unmounted to allow |
||||
# it to be converted from a sparse image to a compressed image. |
||||
print " compressing $dmgFile\n" if ($kLogging eq "-quiet"); |
||||
|
||||
system("hdiutil", "eject", $kLogging, "/Volumes/$volName"); |
||||
|
||||
if ($theLicense ne "") |
||||
{ |
||||
system("hdiutil", "unflatten", $kLogging, "$dmgFile.sparseimage"); |
||||
`$Rez -a "$theLicense" -o "$dmgFile.sparseimage"`; |
||||
system("hdiutil", "flatten", $kLogging, "$dmgFile.sparseimage"); |
||||
} |
||||
|
||||
system("hdiutil", "convert", "$dmgFile.sparseimage", |
||||
"-format", "UDZO", |
||||
"-o", $dmgFile, |
||||
"-imagekey", "zlib-level=9", |
||||
$kLogging); |
||||
|
||||
|
||||
|
||||
# Clean up |
||||
system("rm", "-f", "$dmgFile.sparseimage"); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# doSet : Set a file/folder state. |
||||
#---------------------------------------------------------------------------- |
||||
sub doSet |
||||
{ |
||||
|
||||
|
||||
# Retrieve our parameters |
||||
my ($thePath, $posX, $posY, $theWidth, $theHeight, $iconSize, $theIcon, $bgImage, $bgColor, $flagToolbar) = @_; |
||||
|
||||
|
||||
|
||||
# Set the custom icon |
||||
if ($theIcon ne "") |
||||
{ |
||||
setCustomIcon($thePath, $theIcon); |
||||
} |
||||
|
||||
|
||||
|
||||
# Set the folder state |
||||
if ($iconSize != 0 || $bgImage ne "" || $bgColor ne "" || $flagToolbar ne "") |
||||
{ |
||||
setFolderState($thePath, $iconSize, $flagToolbar, $bgImage, $bgColor); |
||||
} |
||||
|
||||
|
||||
|
||||
# Set the position |
||||
# |
||||
# Window position must be set after applying the folder state. |
||||
if ($posX != 0 && $posY != 0) |
||||
{ |
||||
if ($theWidth != 0 && $theHeight != 0) |
||||
{ |
||||
setWindowPos($thePath, $posX, $posY, $theWidth, $theHeight); |
||||
} |
||||
else |
||||
{ |
||||
setIconPos($thePath, $posX, $posY); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# dmgUtil : Manipulate a disk image. |
||||
#---------------------------------------------------------------------------- |
||||
sub dmgUtil |
||||
{ |
||||
|
||||
|
||||
# Retrieve our parameters |
||||
my ($doOpen, $doClose, $doSet) = (0, 0, 0); |
||||
my ($posX, $posY, $theWidth, $theHeight, $iconSize) = (0, 0, 0, 0, 0); |
||||
my ($volName, $theIcon, $bgImage, $bgColor, $flagToolbar, $theLicense) = ("", "", "", "", "", ""); |
||||
|
||||
GetOptions( "--open+", => \$doOpen, |
||||
"--close+", => \$doClose, |
||||
"--set+", => \$doSet, |
||||
"--volume=s", => \$volName, |
||||
"--x=i", => \$posX, |
||||
"--y=i", => \$posY, |
||||
"--width=i", => \$theWidth, |
||||
"--height=i", => \$theHeight, |
||||
"--iconsize=i", => \$iconSize, |
||||
"--icon=s", => \$theIcon, |
||||
"--background=s", => \$bgImage, |
||||
"--bgcol=s", => \$bgColor, |
||||
"--toolbar=s", => \$flagToolbar, |
||||
"--license=s", => \$theLicense); |
||||
|
||||
my ($thePath) = @ARGV; |
||||
|
||||
$thePath = "" if (!defined($thePath)); |
||||
|
||||
|
||||
|
||||
# Perform the action |
||||
if ($doOpen && $thePath ne "" && $volName ne "") |
||||
{ |
||||
doOpen($thePath, $volName); |
||||
} |
||||
|
||||
elsif ($doClose && $thePath ne "" && $volName ne "") |
||||
{ |
||||
doClose($thePath, $volName, $theLicense); |
||||
} |
||||
|
||||
elsif ($doSet && $thePath ne "") |
||||
{ |
||||
doSet($thePath, $posX, $posY, $theWidth, $theHeight, $iconSize, $theIcon, $bgImage, $bgColor, $flagToolbar); |
||||
} |
||||
|
||||
else |
||||
{ |
||||
print $kManPage; |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#============================================================================ |
||||
# Script entry point |
||||
#---------------------------------------------------------------------------- |
||||
dmgUtil(); |