From 53ec756373c44e6dfa10f13f9f9788a6914bf7ea Mon Sep 17 00:00:00 2001 From: Matthew Duggan Date: Wed, 21 Apr 2010 12:22:54 +1000 Subject: [PATCH] Change the method for creating DMG to use some applescript to configure background etc --- mac/make-dmg.sh | 78 ++++++++++++++++++++++++++++++++++++++ mac/set-dmg-settings.scpt | Bin 0 -> 2302 bytes mac/setup.py | 15 +------- 3 files changed, 80 insertions(+), 13 deletions(-) create mode 100755 mac/make-dmg.sh create mode 100644 mac/set-dmg-settings.scpt diff --git a/mac/make-dmg.sh b/mac/make-dmg.sh new file mode 100755 index 000000000..be69f60b5 --- /dev/null +++ b/mac/make-dmg.sh @@ -0,0 +1,78 @@ +#!/bin/sh + +# Makes the DMG with all the nice things already setup. +# Most of the Finder window twiddling is done by an applescript, this just does +# the DMG manipulations. + +# This script should be run with the working directory as the top level (where +# the dist folder appears) + +if [ ! -d "dist" ] +then + echo "This must be run in the same directory as 'dist'." + exit 1 +fi + +if [ -d "/Volues/Anki" ] +then + echo "You already have one Anki mounted, unmount it first!" + exit 1 +fi + +echo --- Configuring 'dist' folder... + +if [ ! -e "dist/Applications" ] +then + ln -s /Applications dist/Applications +fi + +if [ ! -d "dist/.background" ] +then + mkdir dist/.background + cp ankiqt/mac/anki-logo-bg.png dist/.background +fi + +if [ ! -f "dist/.DS_Store" ] +then + cp ankiqt/mac/dmg_ds_store dist/.DS_Store +fi + +echo --- Creating writable DMG... +hdiutil create -attach -ov -format UDRW -volname Anki -srcfolder dist -o Anki-rw.dmg + +RESULT=$? + +if [ $RESULT != 0 ] +then + echo "Creating RW DMG failed! ($RESULT)" + exit 1 +fi + +echo --- Running applescript to configure view settings... +osascript "ankiqt/mac/set-dmg-settings.scpt" + +echo --- Unmounting and converting to RO DMG... +hdiutil detach "/Volumes/Anki" +if [ -d "/Volumes/Anki" ] +then + echo "+++ Waiting for drive to detach..." + sleep 5 + hdiutil detach "/Volumes/Anki" +fi + +if [ -d "/Volumes/Anki" ] +then + echo "!!! Warning: Drive didn't detach cleanly forcing it to detach.." + sleep 5 + hdiutil detach -force "/Volumes/Anki" +fi + +echo --- Making final compressed DMG... + +hdiutil convert "Anki-rw.dmg" -ov -format UDZO -imagekey zlib-level=9 -o Anki.dmg + +RESULT=$? + +rm Anki-rw.dmg + +exit $RESULT diff --git a/mac/set-dmg-settings.scpt b/mac/set-dmg-settings.scpt new file mode 100644 index 0000000000000000000000000000000000000000..e4eb09076e0410a0ce95c4d9d755b2e95f42bfc5 GIT binary patch literal 2302 zcmb_dNmEo;6#m}pR`E8snKWV?g5nTcpam5aA&LwFMv0+VX3;bawzS<;H$u5f{z0m; z@dvndk!`A+qH)$ZMB|79PB`H_>&bWD1JhbAvdHVYU*C7{dEfcY9nNV8r8?SbS_?`` zN*9>s2jI;Tfdv~Liydh8t!|E+$7{pOnK2lv37#1Hz&ebR_wr6-9PAdyY#lN%UK5;m zFTR6A6k%UBabr+Yb9@yUlNM+^(HzJ;rOOl4ET|}*$Bm= zDNEh}w!9|5&z6O3O>jKrU>Fe^Y)x>q6eB3ZN`^@p4JUduX1lHeD3%9G9*nrM(7$V-bzTu8w*%qTG*iSihno2NhVtklGPK7~SYX5(#WV9380S zSe#=~u0o8XU2Mg)?4o@SXSy^NxtnO#ehHRpf)h?N*2;Ay*G)L>-LzZkM$&|48T83u zdL(kwgz9rudyyg6P^kz!QXNqq>PlDjSl;_(er^j@SLL9J*S^M8r!n3&;ekMP7OJh| z8Aj0m`>d&{ZG~+)$-yvNNp66Zxh52j#(NW~^#zS}pE%qzIQ(1Vd=9q%uuU~Y;~kM? zNvNmi6RZFD+CG%GZ_C-AMy-VpFuq{)edIs0Hj#|9Mv{Hea3sac$aUB=*rqs}WBU8H ztiH;=#iU40Y#Z33jALPX7?rJ?Q@xRmmET6&lcD71%5=`k^f>&?YzhrLALg_~cyda3 zVtV+?Vw%dt8s|)z*nyTY2k+dTUvfbfR9g3 zr=5R4KOdJZf1yE6$w{n2qnuED9Vtzp`CfC$M@r>7G}$m!ZHyeZ<+u@f%7{E^#H=#V z$kncvKe0@X$x%5XhvkqQlmoI~_Q@ZzSN6#7D3{%eChmn(a%|N1XUd|IqsET8UdfTP zLZ;*}$4%){a)>=sca$7t&lC+M2iP;|+$a0fV)w{CY*q3HCrt`fvNtU^D%oQ`Vm4IN z=;kmbyUiF=N{*bs_g8YUHgNS?Fc%Gh4Vmz?1g;n5BJW1vW>G^+XW*8Dw~HFu%*0Sp z{rQ$dxzKk5_c(Ds@W7cE4k0^uD1;oowPpEH4{HLN{b+_g5vygFAFJV=%r)F8J7l|( rofOcXO!RwXhyF#$b}H`fOm1wdD=1L1%cx_R2&KYF-ZTArU|`!nGGZj! literal 0 HcmV?d00001 diff --git a/mac/setup.py b/mac/setup.py index 5049c8b41..1cf60a9f2 100644 --- a/mac/setup.py +++ b/mac/setup.py @@ -37,19 +37,8 @@ python2.6/pyconfig.h") chmod a+x dist/Anki.app/Contents/Resources/audio/mplayer") if 'debug' in os.environ: return - os.system("\ -ln -s /Applications dist/Applications") - os.system("\ -mkdir dist/.background") - os.system("\ -cp ankiqt/mac/anki-logo-bg.png dist/.background") - os.system("\ -cp ankiqt/mac/dmg_ds_store dist/.DS_Store") - # zlib - result = os.spawnvp(os.P_WAIT, 'hdiutil', ( - 'hdiutil create -ov -format UDZO ' + - '-volname Anki -srcfolder dist ' + - '-o Anki.dmg -imagekey zlib-level=9').split()) + # make the dmg with the shell script + result = os.system('ankiqt/mac/make-dmg.sh') if result is not 0: raise Exception('dmg creation failed %d' % result)