 |
 |
pop up EULA and dmg window
|
 |
|
 |
|
Mac Enthusiast
Join Date: Oct 2001
Status:
Offline
|
|
we are putting the final touches on our first cocoa application. I am working its packaging. I have noticed that apple and omnigroup both have a EULA pop up when the dmg mounts. I know that DMG maker does this, but it crashes when run on my machine. Is there another way other than DMG maker to do this? How does DMG maker accomplish this?
Also both apple and omnigroup cause a window to pop up that shows the contents of the mounted volume. I understand that this is accomplished by setting word 2 of the finder info field in the HFS+ volume header. How can I do this?
If I can figure this out, I will write an app which will do ALL these things as well as set the background image of the dmg window.(I have this part figured out)
|
3R1C
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status:
Offline
|
|
Here's the part for getting the window to automatically open:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
<font color = brown>/*
* Copyright (c) <font color = blue>2001</font> Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version <font color = blue>1.1</font> (the
* <font color = red>"License"</font>). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* <A HREF=<font color = red>"http:<font color = brown>//www.apple.com/publicsource"</font> TARGET=_blank>http://www.apple.com/publicsource</A> and read it before using this file.</font>
*
* This Original Code and all software distributed under the License are
* distributed on an <font color = red>"AS IS"</font> basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/</font>
<font color = brown>/*
* Shantonu Sen <ssen@apple.com>
* openUp.c - program to set the <font color = red>"first-open-window"</font> field of a volume
*
* Get the directory ID for the first argument, and set it as word <font color = blue>2</font>
* of the Finder Info fields for the volume it lives on
*
* cc -o openUp openUp.c
* Usage: openUp /Volumes/Foo/OpenMe/
*
*/</font>
#include <stdio.h>
#include <unistd.h>
#include <sys/attr.h>
#include <sys/stat.h>
#include <sys/mount.h>
struct directoryinfo {
unsigned long length;
u_int32_t dirid;
};
struct volumeinfo {
unsigned long length;
u_int32_t finderinfo[<font color = blue>8</font>];
};
int main(int argc, char *argv[]) {
char *path = NULL;
struct attrlist alist;
struct directoryinfo dirinfo;
struct volumeinfo volinfo;
struct statfs sfs;
path = argv[<font color = blue>1</font>];
bzero(&alist, sizeof(alist));
alist.bitmapcount = <font color = blue>5</font>;
alist.commonattr = ATTR_CMN_OBJID;
getattrlist(path, &alist, &dirinfo, sizeof(dirinfo), <font color = blue>0</font>);
printf(<font color = red>"directory id: %lu\n"</font>, dirinfo.dirid);
statfs(path, &sfs);
printf(<font color = red>"mountpoint: %s\n"</font>, sfs.f_mntonname);
alist.commonattr = ATTR_CMN_FNDRINFO;
alist.volattr = ATTR_VOL_INFO;
getattrlist(sfs.f_mntonname, &alist, &volinfo, sizeof(volinfo), <font color = blue>0</font>);
volinfo.finderinfo[<font color = blue>2</font>] = dirinfo.dirid;
setattrlist(sfs.f_mntonname, &alist, volinfo.finderinfo,
sizeof(volinfo.finderinfo), <font color = blue>0</font>);
}
</font>[/code]
So, when constructing our OmniWeb disk image, we do <font face = "courier">sudo openUp /Volumes/OmniWeb</font> to make the root directory of the disk image open up when you mount it.
Adding a EULA is trickier. You'll need a resource editor (like ResEdit in Classic or Resorceror), and you'll need a DMG that already has a EULA to start from (feel free to use ours). Here's the procedure:[list=1][*]Start with your finalized (read-only) disk image.[*]In the terminal, type <font face = "courier">hdiutil unflatten MyDiskImage.dmg</font>. Also do this for the image with a EULA.[*]Open both disk images in your resource editor.[*]Copy over all the <font face = "courier">LPic</font>, <font face = "courier">TEXT</font>, <font face = "courier">styl</font>, and <font face = "courier">STR#</font> from the disk image with the EULA into yours.[*]Edit the <font face = "courier">STR#</font> resource to change the button labels in the EULA window, or the instructional text ("this is legally binding if you click Agree", etc.) that appears on the left side of the EULA window. Keep the <font face = "courier">STR#</font> resources for all the languages, even if your license is only in English.[*]Edit the <font face = "courier">TEXT</font> resource (most editors will edit the corresponding <font face = "courier">styl</font> resource at the same time) to write or paste your license. Include one <font face = "courier">TEXT/styl</font> pair for every language your EULA is in, with IDs matching those of the <font face = "courier">STR#</font> resources.[*]Save and close the disk image in the resource editor.[*]In the terminal, type <font face = "courier">hdiutil flatten MyDiskImage.dmg</font>, and you're done.[/list=a]
The flattening and unflattening steps are important. The UDIF disk image format contains a Classic/Carbon-style resource fork that's serialized into the data fork, so that disk images can be single-fork files suitable for Internet distribution. Unflattening the image makes those resources editable, and flattening it again makes it so those resource sill will be there after you transmit the DMG file.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Oct 2001
Status:
Offline
|
|
I assume that I need to make a new project in project builder of type Tool-Standard Tool. I copied the supplied code into this new project. The project compiles fine. I then mounted my dmg (I assume I need to mount the dmg since the argument that openUp takes is /volumes/nameOfDMG). I executed the following:
sudo /Users/xaos01/Projects/Builds/openUp /Volumes/nameOfDMG
Password:
directory id: 2
mountpoint: /Volumes/nameOfDMG
I then unmount my dmg. When I try to again mount my dmg, the window does not open.
How have I strayed sir?
as an aside I must say that omnigroup and apple are our heroes.  We are modelling our new company (Bearded Llama) after Omnigroup.
I am currently using omni's chasing arrows in our project. Is this ok? what do we need to do be allowed to use your chassing arrows?
I just noticed that although openUp builds, I do get warnings:
warning: implicit declaration of function `bzero'
warning: long unsigned int format, u_int32_t arg (arg 2)
warning: control reaches end of non-void function
sorry to be so dense. I am an utter newbie.
[ 04-18-2002: Message edited by: 3R1C ]
|
3R1C
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status:
Offline
|
|
Don't involve PB - just use the cc compiler directly as illustrated in the comment at the top of the file.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Oct 2001
Status:
Offline
|
|
Thanx rick. you da man!
could I be allowed to make a freeware front end for the code you provided me with?
|
3R1C
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status:
Offline
|
|
I'm not the one to ask... that's Apple's code, as the license header states. However, it appears that making a forntend is quite permissible under the license.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Feb 2003
Status:
Offline
|
|
I come across this thread 2 years after its publication ... and I thank you! It's been quite helpful but I have additional questions on the same topic.
Here's what I'm trying to *automate*:
1. create a dmg with the right Finder info (icon size & position, background image)
2. attach a licence dialog to that dmg.
This thread has helped me resolve the "open first window on mount" issue (thanks to Rickster!) but I'm still looking for way to accomplish these 2 tasks *programmatically*, using a shell script preferably.
Note that hdiutil (built-in command line tool to create and manipulate disk images) seems to have hidden features such as the 'internet-enable' argument (used to have the content of the dmg copied to the desktop and the image unmounted automatically).
Maybe there is such an option to attach a EULA?
the only technique I've found so far is to use rez (part of the developer tools) but this forces to have the EULA in a .r format, which is not my preference:
% hdiutil unflatten disk.dmg
% /Developer/Tools/Rez -a eula.r -o disk.dmg
% hdiutil flatten disk.dmg
(note: other resources mentioned in that thread are not necessary, they're part of the OS/DiskCopy)
Ultimately, I'd like to use a text file format (rtf or plain ascii) as an argument to a tool I can call from the command line.
Does such tool exist exist?
As to the background image, how can it be set programmatically? The quick and dirty way to do this is to do it once by hand using a read/write disk image, then unmount it, convert it to read-only, mount it again, then extract the top level .DS_Store file and copy it into any new disk image created programatically. It works now but this is probably not recommended as the DS_Store format could change in future revisions of the OS (as it has between 10.1 and 10.2) so I'd rather be able to access these options from the script that creates the disk image, instead of using a pre-built .DS_Store.
Any help or pointer in that direction would be highly appreciated.
Thanks!
-- jj.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status:
Offline
|
|
We've been trying to better automate this process for, well, the last two years. Unfortunately, the Finder info part is still a screw, as you've described, but we've got a process that works decently now... at least for us.
The EULA doesn't change between releases, so when we write it the first time, we stash the necessary resources in a .rsrc file (created using Resorceror, which has a decent TEXT/styl editor). When we do a new release, our build scripts use /Developer/Tools/ResMerger to copy those resources into the (unflattened) DMG.
Likewise, we only need to do Finder window setup once, since all we change between releases is the contents of the OmniWeb.app package on the disk image -- the other files at the top level of the DMG can be carried over from one release to the next, preserving the window layout and background. Our build scripts use basically the following steps:
1. make a read/write copy of the DMG from a prior release and mount it
2. remove all of /Volumes/OmniWeb/OmniWeb.app/Contents
3. use /usr/bin/ditto to copy in the contents of the new OmniWeb. ditto is good because unlike cp and rsync and the like, it can preserve resource forks, mod dates, and HFS metadata.
HTH,
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Dec 2001
Status:
Offline
|
|
So, do I read this correctly that, in order for the license thing to work, it is necessary for the dmg file to have a resource fork?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status:
Offline
|
|
Yes and no.  The DMG format is a single-fork format in which two forks are serialized into one. So normally, it's a single-fork file which can be safely copied to any filesystem without needing a MacBinary or BinHex wrapper. When you run hdiutil unflatten, it will deserialize the DMG and make it a two-fork file which you can easily edit using Resorceror or other resource-editing tools. Once you're done with this editing, you should run hdiutil flatten to make it a single-fork file again so that you can post it to the web.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|