So from what little I understand about packaging for Macs, I see that the actual program that launches is the one defined under the CFBundleExecutable key in Info.plist.
<key>CFBundleExecutable</key>
<string>JavaApplicationStub</string>
Now, my app doesnt work if /APP/Content/MacOS/JavaApplicationStub is not chmodded +x (It just fails silently without doing anything, which is a pain!).
Fair enough, its not executable I guess. But its a big problem if you are copying the app from somewhere that dosent support +x properties on files; such as windows, fat32 USB keys, CDROMs, websites, zip files, etc...
What can I do in these instances to make the app able to run? Manually setting the execute bit is not an option.
There's got to be people who run Mac apps off CD, at the very least!
I think your only option is to package the APP bundle into a DMG file, or tar.
DMG is more standard and just as easy to do as using tar or zipping. The command line we use is:
hdiutil create -srcfolder Last.fm.app -format UDZO -imagekey zlib-level=9 -scrub Last.fm.dmg
You can tar from any platform, (even Windows, if you install cygwin, or use the GNU standalone, http://gnuwin32.sourceforge.net/packages/gtar.htm)
tar cf app.tar app_directory
With gzip compression:
tar czf app.tar.gz app_directory
#mxcl, that works, sort of, thanks. However, you need to be on a Mac to run hdiutil :(.
Also, it mucks up the paths of the app... there were some files(like the db file) that were not inside the .app folder, and thus are not included in the .DMG file.
Im building on windows, and the app is getting deployed to removable media. The whole point is to avoid installing anything.
The app runs on windows aswell, so there is a windows .exe alongside the mac.app on the root of the disk. There is also a sqllite.db file that both versions of the application share. Multi-platform is hard :/
Related
To where a pkg installer package on MacOS should install global application data ? All users of this specific system as well as the app itself should have read and write access to this data. Atm I install it to /Library/Application Support/"mycompany"/"MyApp" and modify the permissions. Is this a good practise for all MacOS versions ?
Thank you !
EDIT:
Meanwhile I have tested to r/w access files in this directory on Sierra and Mojave. It works like a charm when I set the permissions in my custom library folder recursively with chmod -R 777 (well, less would be enough).
BTW I do this with a batch post installation shell script in the packages app here. It's a great UI based app (instead of using a bunch of command line tools). Building the pkg can be automated by a single command line: /usr/local/bin/packagesbuild /path/to/the/project.pkgproj, so integration into a flawless workflow is easy.
Yes. The only change I'm aware of related to this was in 10.7 when Apple changed the /Library folder to a hidden directory. (unlisted in finder unless specified) The path remains unchanged.
https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html
Is it possible to get Firefox in a portable format?
The only "portable" version of FireFox I can find is on portableapps.com and it is just an installer, and from what I hear you cannot package that in your own application.
How do you get a portable version of Firefox for Windows, Mac or Linux?
For windows, just download the installer and run the Exe to completion then zip the result. This seems to work fine for use with Automated browser testing which is what I was using the portable zip for.
For Linux, you can just literally use the tar.bz2 file. It is basically portable in the default distribution already.
And for Mac you can mount the DMG file then just copy the zip contents.
One thing I also needed to do was to manually go through each file that started as executable and re-make them executable. Because the process of zipping up the files made the files non-executable.
I build my Qt application on Mac (Mavericks), using CMake. It creates a bundle file in the build directory called SquiggleMark.app.
Next I run a script that copies libraries into the bundle, just Qt framework and libqcocoa.dylib files.
Finally I use iDMG to create a dmg file.
Now if I mount this dmg file and run my app from the mount, it runs fine. But if I move the dmg to /Applications and run it from Finder > Applications, it takes very long time, couple of minutes to launch.
How can I debug this?
I suspect it is taking too long to find the libraries in Finder, but I am not sure.
When I run the app from terminal, by typing "/Applications/SquiggleMark/Contents/MacOS/SquiggleMark", it also works fine.
The dmg is here You can try it out and tell me if you are seeing the same long load time as I am.
My bundling script has commands like this:
install_name_tool -id #executable_path/../Frameworks/QtWidgets $BUNDLE/Contents/Frameworks/QtWidgets
install_name_tool -change $QTDIR/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets #executable_path/../Frameworks/QtWidgets $BUNDLE/Contents/MacOS/$APP
I am not posting the whole script because it is too long, however if someone wants it, I can put it up here.
I have a program (created by a colleague, ported from Linux but successfully compiles on Mac) that I need to deploy to lots of Mac workstations. Currently we do so by pushing out pkg files (not ones we created).
My general question (that others may find the answers to useful) is how do I go about packaging a command line program/script into a pkg file that installs the program? The usual method to package an .app file seems documented well enough, but there is scant details about taking an arbitrary program and wrapping it in a pkg installer.
The man pages for pkgbuild (etc) make a lot of assumptions - that you've already built an app with xcode, that you're intending to use an .app and can generate plists, etc. All we want to do is let the mac server install a non-app program, and it wants to use pkgs.
It would be best if the solution were scriptable so that every time we update the program we can easily create a new pkg file. If a decent resource already explaining this process can be linked that of course would also work great. The question here: Making OS X Installer Packages like a Pro - Xcode Developer ID ready pkg doesn't match the need to simply install a basic cli program.
I would recommend Packages.
It's scriptable so it can become part of your build process and generates a nice mpkg for you.
We are using it to automate the download of third-party libraries, and then the invocation of make to compile, as well as the installation of compiled files.
As a note, although this will generate a mpkg, most distributions are done with disk images, so we also use hdiutil to create a sparse image, copy the mpkg into it, convert it to a compressed read-only dmg and then distribute that.
An example of this procedure would be:
1) Create Sparse RW DMG file.
hdiutil create -size 100M -type SPARSE -volname "MyInstaller" -fs HFS+ MyInstaller.dmg.sparseimage
2) Attach to image. Note disk and mounted volume name from output (ex. /dev/disk2s1 and /Volumes/MyInstaller)
hdiutil attach MyInstaller.dmg.sparseimage
3) Copy in mpkg installer
cp -R Packages/build/My_Packages.mpkg /Volumes/MyInstaller/
4) Detech from image.
hdiutil detach -force {mounted disk} (ex. hdiutil detach -force /dev/disk2s1)
5) Create compressed read only image from writable sparse image.
hdiutil convert "MyInstaller.dmg.sparseimage" -format UDZO -o "MyInstaller.dmg" -ov -imagekey zlib-level=9
Is it possible to build a .dmg file (for distributing apps) from a non-Mac platform?
And if yes, how?
Yep, mkfs.hfsplus does it.
dd if=/dev/zero of=/tmp/foo.dmg bs=1M count=64
mkfs.hfsplus -v ThisIsFoo /tmp/foo.dmg
This creates a dmg file (in this case 64M) that can be mounted on a mac. It can also be mounted on linux, with something like
mount -o loop /tmp/foo.dmg /mnt/foo
after wich you just copy the content you want to it (in /mnt/foo). Unmount it, and the dmg can be copied over to a mac and mounted there.
A project I work on creates DMG files on Linux using genisoimage:
mkdir -p dmgdir/progname.app/Contents/{MacOS,Resources}
...copy your PkgInfo, Info.plist to Contents...
...copy your .icns to Resources...
...copy your other things to where you expect them to go...
genisoimage -V progname -D -R -apple -no-pad -o progname.dmg dmgdir
If you want to be really fancy, you can steal the .DS_Store file from a DMG made on a Mac with a volume name progname and app bundle called progname.app (i.e., matching what you want to create off the Mac) where you've put a background in .background/background.png and a symbolic link to /Applications in the root dir, and put that in dmgdir along with your own a symbolic link to /Applications.
Finally, if you want to create a compressed DMG, get the dmg tool from libdmg-hfsplus:
dmg uncompressed.dmg compressed.dmg
git clone https://github.com/hamstergene/libdmg-hfsplus
cd libdmg-hfsplus && cmake . && make && cd dmg
./dmg --help
Makefile:
dmg:
genisoimage -D -V "$(PROJECT) $(VERSION)" -no-pad -r -apple -o project-$(VERSION)-uncompressed.dmg $(DARWIN_DIR)
./dmg dmg project-$(VERSION)-uncompressed.dmg project-$(VERSION).dmg
uncompressed works out of the box, compression may cause problems - the origin/master at least produces a 'checksum' error on snow-leopard
It does seem possible to create DMG files with some third party tools. A quick google search reveals at least a few commercial tools:
TransMac
MagicISO
Not sure about any OSS/freeware options, but it does at least seem possible if you are so inclined.
Edit: I also forgot about MacDrive, which is another great tool for working with HFS+ filesystems under windows. Since a DMG is basically just a HFS+ filesystem snapshot, it is probably possible with MacDrive to create DMG's as well.
I'm not sure if anyone is still watching this thread, but I tried TransMac as recommended by Nik Reiman.
Using this tool I was able to, running on Windows 7, create dmg files which were mountable on OSX 10.8.3.
Downside
The only downside for us is that this tool doesn't appear to be command-line friendly; for us that's a deal-breaker as we need to be able to have an automated tool which our build server (Windows based) can use to build dmg files on-the-fly.
See mkfs.hfsplus
If you're distributing Mac apps, then surely you have a Mac to write and test them. Why not simply use that same Mac to create the disk image?
[Edit] Alternatively, if you're distributing a portable app, for example a Java .jar file, why bother with a disk image? Macs understand .zip and .tar.gz archives just fine.
I guess what I'm getting at is, I don't understand how one might need a DMG disk image, but not have a Mac with which to create it.