2

I'm trying to automate Mac OS X package building via command line interface of PackageMaker. So far i managed to build package and run postinstall script. Tell me is there a way to add choices while building via command line? Because I want user to have an option to run or not to run postinstall script. P.S.: I don't want to use ".pmdoc". This option is awful.

Aleksandr Kravets
  • 5,750
  • 7
  • 53
  • 72
  • I wrote about using [pkgbuild together with productbuild here](http://stackoverflow.com/questions/11487596/making-os-x-installer-packages-like-a-pro-xcode4-developer-id-mountain-lion-re/11487658#11487658). PackageMaker always was buggy has hell, and got deprecated with Mac OS X 10.6 Snow Leopard. – catlan Aug 04 '12 at 09:49

3 Answers3

4

As i have said in comment, PackageMaker makes a list of files i added to project and writes it into it's project. So, if i want to add one single file i need to open project, remove choice containing that file and, finally, add all files again with new file included. OR edit project's XML files directly. It's unbearable to automate building my project's package using PackageMaker. So i've changed a tool. some googling helped me to fing Packages. This tool is not ideal too, but it's so much better than Apple's. Mojca described approximately what i've done so far with PackageMaker. While using Packages i also had to use project file. But this software doesn't collect info about all files you add into project unless you explicitly tell it to do so: this screen is helpful

You can see on picture that i have choice at what depth files shoUld be included to project. All folders beneath .app folder were expanded manually to be sure that folder which can contain new files was not expanded as well. In this case it's Java folder. Next and final step is assembling package using Ant:

 <exec executable="/usr/local/bin/packagesbuild">
            <arg value="-v"/>
            <arg value="${basedir}/Installer/MyProject.pkgproj"/>
 </exec>
Aleksandr Kravets
  • 5,750
  • 7
  • 53
  • 72
  • when I download and install the packages, I can't find it anywhere and when I trying to open the "pkgproj" file, it shows “Packages” is damaged and can’t be opened. You should move it to the Trash." on Catelina! is there any solution? :( – Mo Farhand Mar 05 '20 at 23:09
  • @MoFarhan I suggest you to find another packaging tool. I think things had changed since 2012 and MacOS now has decent tools for packaging. At least I heard so because I never packaged an app for MacOS since 2012 – Aleksandr Kravets Mar 07 '20 at 07:57
  • Thanks for the reply honestly, I couldn't find any decent tools :D I installed on the Mojave and it works ... I would appreciate if anyone mentions a new tools – Mo Farhand Mar 07 '20 at 09:11
  • If Packager doesn’t work on Catalina you can try contacting author. I remember submitting a bug in 2012 and as I remember I got response quite fast. Not sure about now though. – Aleksandr Kravets Mar 08 '20 at 10:04
  • Thanks, they have a trick on readme file but it's common and just showing how we should run the fild, as apple block it! All in all thanks for the feedback. – Mo Farhand Mar 09 '20 at 08:18
4

After struggling for a while with the command line parameters of packagemaker, I found that there are more up-to-date and relevant tools : pkgbuild and productbuild.

I've not used them for the moment since I found a way to do what I wanted torturing packagemaker.

Hope this will help some unfortunate Mac dev.

Clément
  • 81
  • 4
  • Thanks for your answer. For now i'm using third-party tool *Packager*. Maybe i'll try your advice on next mac project. – Aleksandr Kravets Jul 19 '12 at 15:02
  • @AleksandrKravets package? where is the download link? when I download and install the packages, I can't find it anywhere and when I trying to open the pkgproj file, it shows "“Packages” is damaged and can’t be opened. You should move it to the Trash." – Mo Farhand Mar 05 '20 at 23:06
2

It is not exactly the answer to your question, but an experienced Mac developer who spent a lot of time testing and fighting with PackageMaker recently gave me the following tip:

You can call PackageMaker from the command line, but it looks like Apple hasn't spent much effort on that, and lots of things don't work. So use the GUI interface instead.

I decided to take his lesson. What worked for me as a pretty good compromise was using GUI one time only to prepare initial .pmdoc files and doing any subsequent changes to those xml files by hand. We then have a target in Xcode project which calls packagemaker:

packagemaker --doc $SRCROOT/Project.pmdoc --out $BUILT_PRODUCTS_DIR/stage/ProjectInstaller.pkg
hdiutil create $BUILT_PRODUCTS_DIR/Project-$VERSION.dmg -volname \"Project-$VERSION\" -fs HFS+ -srcfolder \"$BUILT_PRODUCTS_DIR/stage

so that all we need to do now (apart from increasing version in .pmdoc files) is to call

xcodebuild -target Package

to get a .dmg image.

I decided to post this answer despite your explicit request not to use .pmdoc mainly to share (someone else's) bad experience with CLI when creating a package from scratch. And also because I first failed to realize that create a package with GUI doesn't mean that I need to use "weird GUI tools" each time when I want to modify something or build a package.

Mojca
  • 304
  • 1
  • 3
  • 14
  • I had a bad experience with *.pmdoc*. Main reason why i don't want to use it - it's impossible to give just one folder to gui PackageMaker. This ugly thing enumerates all files in given folder and writes list of them to it's project file. That's why you can't add a single file to deployment unit without messing with .pmdoc and PackageMaker again. It's very inconvenient. I guess i'll make an answer to describe solution which i use now. – Aleksandr Kravets May 30 '12 at 12:28