]> err.no Git - sope/commitdiff
started dmg builder
authorhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Wed, 28 Sep 2005 16:51:59 +0000 (16:51 +0000)
committerhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Wed, 28 Sep 2005 16:51:59 +0000 (16:51 +0000)
git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1137 e4a50df8-12e2-0310-a44c-efbce7f8a7e3

maintenance/ChangeLog
maintenance/make-osxdmg.sh [new file with mode: 0755]

index 432952190b54d55fd0caff34a72774d3edc39db8..511747a850eefdaff01f4a1486827f4ecd55b3bc 100644 (file)
@@ -1,5 +1,7 @@
 2005-09-28  Helge Hess  <helge.hess@opengroupware.org>
 
+       * started make-osxdmg.sh script
+
        * make-osxpkg.sh, make-osxmpkg.sh: fixed some pkg build issues
 
 2005-08-21  Helge Hess  <helge.hess@opengroupware.org>
diff --git a/maintenance/make-osxdmg.sh b/maintenance/make-osxdmg.sh
new file mode 100755 (executable)
index 0000000..4768ca3
--- /dev/null
@@ -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 <dmgname> [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}"