macos: iterate mdfound packagemakers when spaces are present
authorDerrick Brashear <shadow@dementix.org>
Tue, 27 Mar 2012 16:09:38 +0000 (12:09 -0400)
committerDerrick Brashear <shadow@dementix.org>
Tue, 27 Mar 2012 16:42:15 +0000 (09:42 -0700)
even if we get more than one match, and even if there's a space,
work anyway

Change-Id: I8e71af0cb02fda7ea0fcf1c2f7a0404eca4bc073
Reviewed-on: http://gerrit.openafs.org/6971
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: Derrick Brashear <shadow@dementix.org>

Makefile.in
src/packaging/MacOS/buildpkg.sh.in

index 94de8b3..01891e1 100644 (file)
@@ -94,7 +94,7 @@ dpkg:
 packages: dest
        @case ${SYS_NAME} in \
        *_darwin_* ) \
-               ${COMPILE_PART1} packaging/MacOS && sh ./buildpkg.sh ${DEST} ;; \
+               ${COMPILE_PART1} packaging/MacOS && bash ./buildpkg.sh ${DEST} ;; \
        hp_ux110 ) \
                ${COMPILE_PART1} packaging/HP-UX && swpackage -s  psf-1.2.10-transarc-paths-11.00 ;; \
        hp_ux11i ) \
index 877c0bf..cdd9509 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Portions Copyright (c) 2003, 2006 Apple Computer, Inc.  All rights reserved.
 
 if [ -z "$1" ]; then
@@ -49,24 +49,11 @@ PACKAGEMAKER=""
 if [ -e "/Developer/usr/bin/packagemaker" ]; then
     PACKAGEMAKER="/Developer/usr/bin/packagemaker"
 else
-    PACKAGEMAKERS=$(mdfind "(kMDItemCFBundleIdentifier == 'com.apple.PackageMaker')")
-    if [ -z "$PACKAGEMAKERS" ]; then
-        echo "packagemaker not found"
-        exit 1
-    fi
-    # if there's a space, trying a for blows up
-    if [ -e "$PACKAGEMAKERS/Contents/MacOS/PackageMaker" ]; then
-            PACKAGEMAKER="$PACKAGEMAKERS/Contents/MacOS/PackageMaker"
-    else
-        for TRYAPP in $PACKAGEMAKERS
-        do
-            echo "$TRYAPP/Contents/MacOS/PackageMaker"
-            if [ -e "$TRYAPP/Contents/MacOS/PackageMaker" ]; then
-                PACKAGEMAKER="$TRYAPP/Contents/MacOS/PackageMaker"
-                break
-            fi
-        done
-    fi
+    while IFS= read -d $'\0' -r file ; do
+        if [ -e "$file/Contents/MacOS/PackageMaker" ]; then
+            PACKAGEMAKER="$file/Contents/MacOS/PackageMaker"
+        fi
+    done < <(mdfind -0 "(kMDItemCFBundleIdentifier == 'com.apple.PackageMaker')")
 fi
 if [ -z "$PACKAGEMAKER" ]; then
     echo "packagemaker not found"
@@ -112,6 +99,8 @@ if [ $firstpass = yes ]; then
        exit 1
     fi
 
+    SEP=:
+
     rm -rf $PKGROOT
     mkdir $PKGROOT
 
@@ -234,7 +223,7 @@ if [ $secondpass = yes ]; then
        rm -rf $CURDIR/OpenAFS-debug-extension.pkg
        echo $PACKAGEMAKER -build -p $CURDIR/OpenAFS-debug-extension.pkg -f $DPKGROOT -r $DPKGRES \
            -i OpenAFS-debug.Info.plist -d OpenAFS-debug.Description.plist
-       $PACKAGEMAKER -build -p $CURDIR/OpenAFS-debug-extension.pkg -f $DPKGROOT -r $DPKGRES \
+       "$PACKAGEMAKER" -build -p $CURDIR/OpenAFS-debug-extension.pkg -f $DPKGROOT -r $DPKGRES \
            -i OpenAFS-debug.Info.plist -d OpenAFS-debug.Description.plist
     fi
 
@@ -266,11 +255,11 @@ if [ $secondpass = yes ]; then
     if [ $majorvers -ge 7 ]; then
        echo $PACKAGEMAKER -build -p $CURDIR/OpenAFS.pkg -f $PKGROOT -r $PKGRES \
            -i OpenAFS.Info.plist -d OpenAFS.Description.plist
-       $PACKAGEMAKER -build -p $CURDIR/OpenAFS.pkg -f $PKGROOT -r $PKGRES \
+       "$PACKAGEMAKER" -build -p $CURDIR/OpenAFS.pkg -f $PKGROOT -r $PKGRES \
            -i OpenAFS.Info.plist -d OpenAFS.Description.plist
     else
        echo $PACKAGEMAKER $PKGROOT $RESSRC/OpenAFS.info -r $PKGRES
-       (cd $CURDIR && $PACKAGEMAKER $PKGROOT $RESSRC/OpenAFS.info -r $PKGRES)
+       (cd $CURDIR && "$PACKAGEMAKER" $PKGROOT $RESSRC/OpenAFS.info -r $PKGRES)
        #old versions of package didn't handle this properly
        if [ ! -r $CURDIR/OpenAFS.pkg/Contents ]; then
                mkdir -p $CURDIR/OpenAFS.pkg/Contents/Resources