set theDMG to choose file with prompt "Please select iTunes dmg file:" of type {"dmg"}
do shell script "hdiutil mount " & quoted form of POSIX path of theDMG
do shell script "pkgutil --expand /Volumes/iTunes/Install\\ iTunes.pkg ~/tmp"
do shell script "hdiutil unmount /Volumes/iTunes/"
do shell script "cd ~/tmp/iTunesX.pkg;" & "cat Payload | gunzip -dc |cpio -i;" & "ditto ~/tmp/iTunesX.pkg/Applications/iTunes.app ~/tmp/iTunes.app;"
do shell script "plutil -replace CFBundleGetInfoString -string 'iTunes 13.6.5.3' ~/tmp/iTunes.app/Contents/Info.plist"
do shell script "plutil -replace CFBundleShortVersionString -string 13.6.5 ~/tmp/iTunes.app/Contents/Info.plist"
do shell script "plutil -replace CFBundleVersion -string 13.6.5 ~/tmp/iTunes.app/Contents/Info.plist"
do shell script "plutil -replace CFBundleVersion -string 'iTunes 13.6.5.3' ~/tmp/iTunes.app/Contents/version.plist"
do shell script "plutil -replace CFBundleShortVersionString -string 13.6.5 ~/tmp/iTunes.app/Contents/version.plist"
set question to display dialog "Copy patched iTunes to /Applications?" buttons {"Yes", "No"} default button 1
set answer to button returned of question
if answer is equal to "Yes" then
do shell script "ditto ~/tmp/iTunes.app /Applications/iTunes.app"
display dialog "Patched iTunes.app was copied to /Applications" buttons {"Ok"}
end if
set question to display dialog "Save patched iTunes as dmg?" buttons {"Yes", "No"} default button 1
set answer to button returned of question
if answer is equal to "Yes" then
do shell script "hdiutil create -format UDRO -srcfolder ~/tmp/iTunes.app ~/Desktop/iTunes13.6.5.dmg"
display dialog "iTunes13.6.5.dmg was saved on Desktop" buttons {"Ok"}
end if
set question to display dialog "Save patched iTunes as an installable pkg?" buttons {"Yes", "No"} default button 1
set answer to button returned of question
if answer is equal to "Yes" then
do shell script "pkgbuild --component ~/tmp/iTunes.app --install-location /Applications ~/Desktop/iTunes13.6.5.pkg"
display dialog "iTunes13.6.5.pkg was saved on Desktop" buttons {"Ok"}
end if
set question to display dialog "Save iTunesAccess as an installable pkg?" buttons {"Yes", "No"} default button 1
set answer to button returned of question
if answer is equal to "Yes" then
do shell script "cd ~/tmp/iTunesAccess.pkg;" & "cat Payload | gunzip -dc |cpio -i;" & "mkdir ~/tmp/a;" & "ditto ~/tmp/iTunesAccess.pkg/System ~/tmp/a/System;"
do shell script "pkgbuild --root ~/tmp/a --install-location / ~/Desktop/iTunesAccess.pkg"
display dialog "iTunesAccess.pkg was saved on Desktop" buttons {"Ok"}
end if
set question to display dialog "Delete temporary ~/tmp folder?" buttons {"Yes", "No"} default button 1
set answer to button returned of question
if answer is equal to "Yes" then
do shell script "rm -rf ~/tmp"
display dialog "~/tmp was deleted" buttons {"Ok"}
return
end if