开发者

How do I get PackageMaker to create the payload's containing folder with correct permissions

I'm creating an installer using PackageMaker v3.0.4.

One of the payloads is a library, which I'm installing to the location /usr/local/lib/

The permissions of the library itself are set up thus:

-rwxr-xr-x  1 root    admin  992180  1 Jun  2009 libxxxx.0.dylib

This works correctly, so long as the lib directory already exists when the installer is run. However, if the lib directory doesn't exist when the installer runs, then it is created with the following permissions:

drwx------   3 username  wheel  102 30 Jun 10:44 lib

And subsequently, the application cannot open the l开发者_开发知识库ib when runs the code:

void *theDylib = dlopen("/usr/local/lib/libxxxx.0.dylib",RTLD_NOW);

How can I get PackageMaker to install the directory with the correct permissions?


If the directory doesn't exist PackageMaker will make it with it's defaults default.

Use a preinstall script to create the lib directory and chown on the directory to set the ownership properly.

You can do something like this. This is untested.

#!/bin/bash

libpath=/usr/local/lib

if [ ! -d "$libpath" ]; then
    mkdir -m 775 "$libpath"
    chown root:admin "$libpath"
fi


N.B. Kevin Green's answer looks like a better solution, but this is what I ended up doing.

If you set the payload to be a single directory containing just the library instead of the library itself, and tick Include root in package then the Installer will create the directory with the correct permissions if it doesn't already exist.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜