0

I'm a new Mac user trying to create a *.pkg file which should hold an *.app (let's call it MyApp) and a corresponding sqlite3 database(let's call it MyAppDB.sqlite3). This application has been written in Python and transformed into a Mac application using Pyinstaller . It is hence not a 'native' Mac app.

The *.pkg instalation process should copy the MyApp.app into ~/Applications/MyApp and the related database into ~/Library/Application Support/MyApp/MyAppDB.sqlite3

For this purpose I've used Packages, however the program seems no to copy the db into the ~/Library/Application Support/ folder since no new folders or files are created there after the installation process, only the ~/Applications/MyApp folder is correctly created where the app gets copied.

Without the database the program crashes. I've added a bash script which creates in a post-installation manner the missing folders into ~/Library/Application Support/MyApp/ and copies there the MyAppDB.sqlite3 file. Unfortunately the file has only read persmissions and I cannot change that.

Hence my question:

  • any expierience with Packages and how to sucessfully add files to other folder than ~/Applications ? Maybe I'm doing something wrong... ?

Many thanks in advance for your help!

7
  • Is your application sandboxed? This will become important because sandboxing affects the location of the Application Support folder. Commented Sep 27, 2016 at 12:30
  • 1
    You have multiple questions about the same topic. Is it possible to combine these into 1 question or are they unrelated?
    – fsb
    Commented Sep 27, 2016 at 12:48
  • @fbara - you're right - they are. However, each asks a different question and I thought for the reason to make it clear and help in the future also other users I'd rather keep them separate as different answers may pop-up. Commented Sep 27, 2016 at 12:52
  • @GrahamMiln - I don't know what do you mean with sandboxing my application..?:) It's an app which I will not distribute through the AppStore, if that answers ...?! Commented Sep 27, 2016 at 12:54
  • 1
    It is a duplicate of apple.stackexchange.com/questions/254760/… However this one would be cloded immediately on SO for lack of research - sandboxing is a basic part of Apple develop,ment and is in their intro docs
    – mmmmmm
    Commented Sep 27, 2016 at 14:11

1 Answer 1

0

Check the Installer Log

Have you checked the Installer log file, /var/log/install.log, for errors or problems? Maybe the package is working but not installing where you expect.

A Better Approach

As Mark comments in your other question, try to avoid needing to install files in multiple locations.

Apple's developer tools for creating packages are:

Quick Fix using pkgbuild

Try the following approach for a quick fix. Note this installs to /Applications and not ~/Applications:

  1. Prepare the files for packaging:

    ~/installer/
    ~/installer/Applications/
    ~/installer/Applications/YourApp.app
    ~/installer/Library/
    ~/installer/Library/Application Support/
    ~/installer/Library/Application Support/YourApp/
    ~/installer/Library/Application Support/YourApp/MyAppDB.sqlite3
    
  2. Create the package with pkgbuild using a command like:

    pkgbuild --root ~/installer/ --install-location / ~/Desktop/MyApp.pkg
    

Avoid this approach! Why?

This approach is not recommended because the install-location is root /. A robust installer will never install directly to root.

Problems include, what if the package's Applications, Library, or Application Support permissions differ from the user's permissions or ownership? What happens if the user has symlinked one or more of these files?

Instead a distribution package containing two standard packages should be used. One standard package will have an install-location of /Applications and the other with /Library/Application Support. This approach tells the installer tool to handle all the ownership, permissions, and symlink problems for you.

Ideal Approach

Ideally, a Mac application will be distributed as a self contained application bundle. If the MyAppDB.sqlite3 needs to be modified, a well behaved Mac application should copy a default database file from within the application bundle to the appropriate Application Support folder and use the copy as needed.

Be aware that if your application is sandboxed, the Application Support folder at /Library/Application Support/ will not be visible to the application. The application will be given its own, contained, support folder. This means that installing a database to /Library/Application Support/ will not behave as you expect.

If you can bundle everything in to the application, then a single call to productbuild will create a safe ready-to-distribute outside the Mac App Store installer package. Better yet, you could avoid an installer package entirely and distribute via a disk image or zip file.

2
  • Thanks a lot for this excellent reply! I see a few new things which I was not aware of, which is likely due to the fact that (as I have added to my question) the app is not a native Mac app. I've written it in Python and converted it to a Mac app using PyInstaller. I need to follow-up on sandboxing.... Commented Sep 27, 2016 at 20:22
  • PyInstaller includes support for Mac bundles and codesigning (which includes sandboxing). Bundles are folders such as application bundles. Commented Sep 28, 2016 at 5:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .