ddmg.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/bash
  2. set -e
  3. [% SET src = c('dmg_src', { error_if_undef => 1 }) -%]
  4. find [% src %] -executable -exec chmod 0755 {} \;
  5. find [% src %] ! -executable -exec chmod 0644 {} \;
  6. find [% src %] -exec [% c("touch") %] {} \;
  7. dmg_tmpdir=\$(mktemp -d)
  8. hfsfile="\$dmg_tmpdir/tbb-uncompressed.dmg"
  9. # hfsplus sets all the times to time(NULL)
  10. export LD_PRELOAD=[% c("var/faketime_path") %]
  11. export FAKETIME="[% USE date; GET date.format(c('timestamp'), format = '%Y-%m-%d %H:%M:%S') %]"
  12. # Use a similar strategy to Mozilla (they have 1.02, we have 1.1)
  13. size=\$(du -ms [% src %] | awk '{ print int( \$1 * 1.1 ) }')
  14. dd if=/dev/zero of="\$hfsfile" bs=1M count=\$size
  15. newfs_hfs -v "[% c("var/Project_Name") %]" "\$hfsfile"
  16. pushd [% src %]
  17. find -type d -mindepth 1 | sed -e 's/^\.\///' | sort | while read dirname; do
  18. hfsplus "\$hfsfile" mkdir "/\$dirname"
  19. hfsplus "\$hfsfile" chmod 0755 "/\$dirname"
  20. done
  21. find -type f | sed -e 's/^\.\///' | sort | while read filename; do
  22. hfsplus "\$hfsfile" add "\$filename" "/\$filename"
  23. hfsplus "\$hfsfile" chmod \$(stat --format '0%a' "\$filename") "/\$filename"
  24. done
  25. # hfsplus does not play well with dangling links
  26. hfsplus "\$hfsfile" symlink /Applications /Applications
  27. # Show the volume icon
  28. hfsplus "\$hfsfile" attr / C
  29. dmg dmg "\$hfsfile" [% c('dmg_out', { error_if_undef => 1 }) %]
  30. popd
  31. rm -Rf "\$dmg_tmpdir"