简体   繁体   中英

Mac OS X PackageMaker

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. PS: I don't want to use ".pmdoc". This option is awful.

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.

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: 这个屏幕很有帮助

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>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM