From 5756a8bb95a7d4eafdb53939ab1557971ae5461c Mon Sep 17 00:00:00 2001 From: helge Date: Wed, 28 Sep 2005 16:51:59 +0000 Subject: [PATCH] started dmg builder git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1137 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- maintenance/ChangeLog | 2 + maintenance/make-osxdmg.sh | 115 +++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100755 maintenance/make-osxdmg.sh diff --git a/maintenance/ChangeLog b/maintenance/ChangeLog index 43295219..511747a8 100644 --- a/maintenance/ChangeLog +++ b/maintenance/ChangeLog @@ -1,5 +1,7 @@ 2005-09-28 Helge Hess + * started make-osxdmg.sh script + * make-osxpkg.sh, make-osxmpkg.sh: fixed some pkg build issues 2005-08-21 Helge Hess diff --git a/maintenance/make-osxdmg.sh b/maintenance/make-osxdmg.sh new file mode 100755 index 00000000..4768ca3a --- /dev/null +++ b/maintenance/make-osxdmg.sh @@ -0,0 +1,115 @@ +#!/bin/sh +# +# make-osxdmg.sh +# +# Create a MacOSX dmg (disk image) for a given directory. +# + +DMG_NAME="$1" +BIN_DIR="$2" +VOLUME_NAME="$3" + +ORG_DIR="$PWD" + +EXTRA_SIZE=4096 + + +# ****************************** usage ******************************** + +function usage() { + cat <<_ACEOF +make-osxdmg.sh [dirname] [volumename] +_ACEOF +} + + +# ****************************** validate cmdline args **************** + +function defaultArgs() { + if test "x${BIN_DIR}" = "x"; then + BIN_DIR="$PWD" + fi + if test "x${VOLUME_NAME}" = "x"; then + VOLUME_NAME="$DMG_NAME" + fi +} + +function validateArgs() { + if test "x$DMG_NAME" = "x"; then + usage; + exit 1 + fi +} + + +# ****************************** sizing ******************************* + +function calcSize() { + SIZE_KB=`du -sk ${BIN_DIR} | awk '{print $1}'` + SIZE_KB=`expr $SIZE_KB + ${EXTRA_SIZE}` +} + + +# ****************************** setup disk *************************** + +function setupDisk() { + DST_IMG="$1" + + if test -e "${DST_IMG}"; then + echo " deleting old dmg ..." + rm "${DST_IMG}" + fi + hdiutil create -size ${SIZE_KB}k ${DST_IMG} -layout NONE + + DISK=`hdid -nomount ${DST_IMG} | awk '{print $1}'` + echo " disk (no mount): $DISK" + + newfs_hfs -v "${VOLUME_NAME}" "${DISK}" + ejectDisk; + + DISK=`hdid ${DST_IMG} | awk '{print $1}'` + echo " disk: $DISK" +} + +function ejectDisk() { + hdiutil eject "${DISK}" +} + +function convertToReadOnlyCompressedImage() { + SRC_DMG="$1" + DST_DMG="$2" + # convert .dmg into read-only zlib (-9) compressed release version + hdiutil convert -format UDZO ${SRC_DMG} -o ${DST_DMG} -imagekey zlib-level=9 +} + +function internetEnableDiskImage() { + # internet-enable the release .dmg. for details see + # http://developer.apple.com/ue/files/iedi.html + hdiutil internet-enable -yes "$1" +} + + +# ****************************** running ****************************** + +defaultArgs; +validateArgs; + +echo "Building MacOSX DMG ${DMG_NAME}.dmg for $BIN_DIR .." + +calcSize; +echo " size: ${SIZE_KB}K" + +setupDisk "${DMG_NAME}.dmg" + +echo -n " coping content to disk .." +cd $BIN_DIR +gnutar cf - . | ( cd "/Volumes/${VOLUME_NAME}" ; gnutar xf - ) +cd $ORG_DIR +echo ".. done." + +# once again eject, to synchronize +ejectDisk; + +REL_DMG="${DMG_NAME}-release.dmg" +convertToReadOnlyCompressedImage "${DMG_NAME}.dmg" "${REL_DMG}" +internetEnableDiskImage "${REL_DMG}" -- 2.39.5