Create installation packages for macOS using the system

Disclaimer: The methods listed here work well on macOS Mojave, Catalina, and Big Sur, but for combat systems it is recommended to always run your own tests of the compiled packages.





- , macOS, - (.. 500-600 2 , , ). , , macOS Windows, .





, ( - , ). "" – , macOS.





PKG – , Installer, , (, : installer -pkg $pkgfile -target /Applications



). , , .





, DMG-, - ( .app) /Applications. , :





  1. dmg-;





  2. ( , – /Applications);





  3. :

    productbuild --component /path/to/YourApplication.app /Applications/ /path/to/YourApplication.pkg





    ( , , , /Applications, , )





, , . , DMG- , hdiutil , .





- , , , shell-, , , , ( , , , ). .. payload-free ( payload) – postinstall – shell-, .





scripts( , , , ), , (, , .ppd).





, , , scripts pico postinstall



. (, , nano), , , /:





#!/bin/bash
ntp="time.euro.apple.com"
sudo /usr/sbin/systemsetup -setusingnetworktime on
sudo /usr/sbin/systemsetup -setnetworktimeserver "$ntp"
exit 0
      
      



Ctrl+X ( Y , ), . , sudo chmod a+x postinstall



( ).





:

sudo pkgbuild --identifier com.package.name --nopayload --scripts /path/to/scripts/ "/path/to/your_package.pkg"





( -, , ).





, , , , .








All Articles