Revision: 3181
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3181&view=rev
Author:   hofman
Date:     2007-11-08 13:32:40 -0800 (Thu, 08 Nov 2007)

Log Message:
-----------
Use an included script instead of a bunch of tasks to create a disk image for 
archiving. This script could also be used externally by users.

Modified Paths:
--------------
    trunk/SKDocument.m
    trunk/Skim.xcodeproj/project.pbxproj

Added Paths:
-----------
    trunk/archivedmg.sh

Modified: trunk/SKDocument.m
===================================================================
--- trunk/SKDocument.m  2007-11-08 15:58:41 UTC (rev 3180)
+++ trunk/SKDocument.m  2007-11-08 21:32:40 UTC (rev 3181)
@@ -875,62 +875,16 @@
         
         NSAutoreleasePool *pool = [NSAutoreleasePool new];
         
-        NSString *tmpDir = SKUniqueDirectoryCreating(NSTemporaryDirectory(), 
YES);
-        BOOL success = tmpDir != nil;
-        
         NSString *sourcePath = [[[info objectForKey:@"sourcePath"] copy] 
autorelease];
         NSString *targetPath = [[[info objectForKey:@"targetPath"] copy] 
autorelease];
-        NSString *name = [[targetPath lastPathComponent] 
stringByDeletingPathExtension];
-        NSString *tmpImagePath1 = [[tmpDir 
stringByAppendingPathComponent:name] 
stringByAppendingPathExtension:@"sparseimage"];
-        NSString *tmpImagePath2 = [[tmpDir 
stringByAppendingPathComponent:name] stringByAppendingPathExtension:@"dmg"];
-        NSString *tmpMountPath = SKUniqueDirectoryCreating(@"/tmp", NO); // we 
don't use tmpDir because the mountpath has a maximum length of 90
-        BOOL didAttach = NO;
+        NSString *scriptPath = [[[NSBundle mainBundle] sharedSupportPath] 
stringByAppendingPathComponent:@"archivedmg.sh"];
+        NSTask *task = [NSTask launchedTaskWithLaunchPath:scriptPath 
arguments:[NSArray arrayWithObjects:sourcePath, targetPath, nil]];
         
+        if ([task isRunning])
+            [task waitUntilExit];
+        if ([task isRunning])
+            [task terminate];
         
-        
-        @try {            
-            if (success) {
-                success = [NSTask runTaskWithLaunchPath:@"/usr/bin/hdiutil"
-                                              arguments:[NSArray 
arrayWithObjects:@"create", @"-type", @"SPARSE", @"-fs", @"HFS+", @"-volname", 
name, tmpImagePath1, nil]
-                                   currentDirectoryPath:tmpDir];
-            }
-            
-            // asr (used by "hdiutil create") has a bug in Tiger: it loses the 
EAs, so we need to copy another version with the EAs
-            
-            if (success) {
-                success = [NSTask runTaskWithLaunchPath:@"/usr/bin/hdiutil"
-                                              arguments:[NSArray 
arrayWithObjects:@"attach", @"-nobrowse", @"-mountpoint", tmpMountPath, 
tmpImagePath1, nil]
-                                   currentDirectoryPath:tmpDir];
-                didAttach = success;
-            }
-            
-            if (success) {
-                success = noErr == FSPathCopyObjectSync((const char 
*)[sourcePath fileSystemRepresentation], (const char *)[tmpMountPath 
fileSystemRepresentation], (CFStringRef)[sourcePath lastPathComponent], NULL, 
kFSFileOperationOverwrite);
-            }
-            
-            if (didAttach) {
-                success = [NSTask runTaskWithLaunchPath:@"/usr/bin/hdiutil"
-                                              arguments:[NSArray 
arrayWithObjects:@"detach", tmpMountPath, nil]
-                                   currentDirectoryPath:tmpDir] && success;
-            }
-            
-            if (success) {
-                success = [NSTask runTaskWithLaunchPath:@"/usr/bin/hdiutil"
-                                              arguments:[NSArray 
arrayWithObjects:@"convert", @"-format", @"UDZO", @"-o", tmpImagePath2, 
tmpImagePath1, nil]
-                                   currentDirectoryPath:tmpDir];
-            }
-            
-            if (success) {
-                success = noErr == FSPathCopyObjectSync((const char 
*)[tmpImagePath2 fileSystemRepresentation], (const char *)[[targetPath 
stringByDeletingLastPathComponent] fileSystemRepresentation], 
(CFStringRef)[targetPath lastPathComponent], NULL, kFSFileOperationOverwrite);
-            }
-            
-            FSPathDeleteContainer((const UInt8 *)[tmpDir 
fileSystemRepresentation]);
-                    
-        }
-        @catch(id exception) {
-            NSLog(@"caught exception %@ while archiving %@ to %@", exception, 
sourcePath, targetPath);
-        }
-        
         [[self progressController] performSelectorOnMainThread:@selector(hide) 
withObject:nil waitUntilDone:NO];
         
         [pool release];

Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj        2007-11-08 15:58:41 UTC (rev 
3180)
+++ trunk/Skim.xcodeproj/project.pbxproj        2007-11-08 21:32:40 UTC (rev 
3181)
@@ -66,6 +66,7 @@
                CE20AC9C0C9EF2F9007C72F9 /* notesTemplate.rtfd in Resources */ 
= {isa = PBXBuildFile; fileRef = CE20AC990C9EF2F9007C72F9 /* notesTemplate.rtfd 
*/; };
                CE20B1600C9EFC29007C72F9 /* notesTemplate.rtfd in CopyFiles */ 
= {isa = PBXBuildFile; fileRef = CE20AC990C9EF2F9007C72F9 /* notesTemplate.rtfd 
*/; };
                CE20B1950C9F23CC007C72F9 /* NSView_SKExtensions.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CE20B1930C9F23CC007C72F9 /* 
NSView_SKExtensions.m */; };
+               CE2A11670CE3B51600A0499B /* archivedmg.sh in Resources */ = 
{isa = PBXBuildFile; fileRef = CE2A11660CE3B51600A0499B /* archivedmg.sh */; };
                CE2BD83E0BD4132B00A5F4DB /* Sparkle.framework in Frameworks */ 
= {isa = PBXBuildFile; fileRef = CE2BD82A0BD4132B00A5F4DB /* Sparkle.framework 
*/; };
                CE2BD8450BD4135600A5F4DB /* Sparkle.framework in CopyFiles */ = 
{isa = PBXBuildFile; fileRef = CE2BD82A0BD4132B00A5F4DB /* Sparkle.framework 
*/; };
                CE2DE4920B85D48F00D0DA12 /* SKThumbnail.m in Sources */ = {isa 
= PBXBuildFile; fileRef = CE2DE4910B85D48F00D0DA12 /* SKThumbnail.m */; };
@@ -402,6 +403,7 @@
                CE20AC990C9EF2F9007C72F9 /* notesTemplate.rtfd */ = {isa = 
PBXFileReference; lastKnownFileType = wrapper.rtfd; path = notesTemplate.rtfd; 
sourceTree = "<group>"; };
                CE20B1920C9F23CC007C72F9 /* NSView_SKExtensions.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
NSView_SKExtensions.h; sourceTree = "<group>"; };
                CE20B1930C9F23CC007C72F9 /* NSView_SKExtensions.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= NSView_SKExtensions.m; sourceTree = "<group>"; };
+               CE2A11660CE3B51600A0499B /* archivedmg.sh */ = {isa = 
PBXFileReference; fileEncoding = 30; lastKnownFileType = text.script.sh; path = 
archivedmg.sh; sourceTree = "<group>"; };
                CE2BD8170BD4127A00A5F4DB /* Sparkle.xcodeproj */ = {isa = 
PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = 
Sparkle.xcodeproj; path = vendorsrc/andymatuschak/Sparkle/Sparkle.xcodeproj; 
sourceTree = "<group>"; };
                CE2BD82A0BD4132B00A5F4DB /* Sparkle.framework */ = {isa = 
PBXFileReference; lastKnownFileType = wrapper.framework; path = 
Sparkle.framework; sourceTree = BUILT_PRODUCTS_DIR; };
                CE2DE4900B85D48F00D0DA12 /* SKThumbnail.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
SKThumbnail.h; sourceTree = "<group>"; };
@@ -1214,6 +1216,7 @@
                        isa = PBXGroup;
                        children = (
                                CE1E2F120BDB86A10011D9DD /* displayline */,
+                               CE2A11660CE3B51600A0499B /* archivedmg.sh */,
                                CE48BBB40C08AD7000A166C6 /* notesTemplate.txt 
*/,
                                CE48BBB50C08AD7000A166C6 /* notesTemplate.rtf 
*/,
                                CE20AC990C9EF2F9007C72F9 /* notesTemplate.rtfd 
*/,
@@ -1435,6 +1438,7 @@
                                CEAE39350CA4429A00849B0F /* BookmarkSheet.nib 
in Resources */,
                                CE7B85FD0CCF4AA800793F46 /* SmallMenu.tiff in 
Resources */,
                                CE6C96A90CD924C70022D69F /* NotesPanel.nib in 
Resources */,
+                               CE2A11670CE3B51600A0499B /* archivedmg.sh in 
Resources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };

Added: trunk/archivedmg.sh
===================================================================
--- trunk/archivedmg.sh                         (rev 0)
+++ trunk/archivedmg.sh 2007-11-08 21:32:40 UTC (rev 3181)
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+# archivedmg (Skim)
+#
+# Usage: archivedmg SOURCE TARGET
+
+source="$1"
+target="$2"
+[ "${source:0:1}" == "/" ] || source="${PWD}/${source}"
+[ "${target:0:1}" == "/" ] || target="${PWD}/${target}"
+name="${target##*/}"
+name="${name%.*}"
+tmpdir=`/usr/bin/mktemp -d /tmp/net.sourceforge.skim-app.XXXX`
+
+cd "$tmpdir"
+/usr/bin/hdiutil create -type SPARSE -fs "HFS+" -volname "$name" 
"${name}.sparseimage" && \
+/usr/bin/hdiutil attach -nobrowse -mountpoint "$name" "${name}.sparseimage" && 
\
+/bin/cp -R "$source" "$name"
+/usr/bin/hdiutil detach "$name"
+/usr/bin/hdiutil convert -format UDZO -o "${name}.dmg" "${name}.sparseimage" 
&& \
+/bin/cp "${name}.dmg" "$target"
+/bin/rm -rf "$tmpdir"


Property changes on: trunk/archivedmg.sh
___________________________________________________________________
Name: svn:executable
   + *


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to