/admin/mac/create-dmg.sh

http://github.com/tomahawk-player/tomahawk · Shell · 59 lines · 22 code · 12 blank · 25 comment · 1 complexity · b33bde83c6858e7c42daf7c50fe5b633 MD5 · raw file

  1. #!/bin/sh
  2. # author: max@last.fm, muesli@tomahawk-player.org
  3. # brief: Produces a compressed DMG from a bundle directory
  4. # usage: Pass the bundle directory as the only parameter
  5. # note: This script depends on the Tomahawk build system, and must be run from
  6. # the build directory
  7. ################################################################################
  8. #if [ -z $VERSION ]
  9. #then
  10. # echo VERSION must be set
  11. # exit 2
  12. #fi
  13. if [ -z "$1" ]
  14. then
  15. echo "Please pass the bundle.app directory as the first parameter."
  16. exit 3
  17. fi
  18. ################################################################################
  19. NAME=$(basename "$1" | perl -pe 's/(.*).app/\1/')
  20. IN="$1"
  21. TMP="dmg/$NAME"
  22. OUT="$NAME.dmg"
  23. mkdir -p "$TMP"
  24. ################################################################################
  25. # clean up
  26. rm -rf "$TMP"
  27. rm -f "$OUT"
  28. # create DMG contents and copy files
  29. mkdir -p "$TMP/.background"
  30. cp ../admin/mac/dmg_background.png "$TMP/.background/background.png"
  31. cp ../admin/mac/DS_Store.in "$TMP/.DS_Store"
  32. chmod go-rwx "$TMP/.DS_Store"
  33. ln -s /Applications "$TMP/Applications"
  34. # copies the prepared bundle into the dir that will become the DMG
  35. cp -R "$IN" "$TMP"
  36. # create
  37. hdiutil makehybrid -hfs -hfs-volume-name "$NAME" -hfs-openfolder "$TMP" "$TMP" -o tmp.dmg
  38. hdiutil convert -format UDZO -imagekey zlib-level=9 tmp.dmg -o "$OUT"
  39. # cleanup
  40. rm tmp.dmg
  41. #hdiutil create -srcfolder "$TMP" \
  42. # -format UDZO -imagekey zlib-level=9 \
  43. # -scrub \
  44. # "$OUT" \
  45. # || die "Error creating DMG :("
  46. # done !
  47. echo 'DMG size:' `du -hs "$OUT" | awk '{print $1}'`