need help with package

Discussion in 'Mac Programming' started by lynkynpark86, Jul 23, 2010.

  1. lynkynpark86 macrumors 6502

    #1
    If this is in the wrong category, I apologize.

    I need to create a package file that, when run, does a unix command. I have my command written, set up, and working properly. However, I can not figure out how to make it run from a pkg file. I already have PackageMaker from Xcode. If anyone knows how to do this, help would be appreciated. Thank you.
     
  2. hiddenpremise macrumors regular

    hiddenpremise

    Joined:
    Jul 25, 2008
    Location:
    Somewhere between my imagination and reality
    #2
    Open package maker and add a blank file of some sort to the payload by dragging and dropping into the list on the left hand side. You can either use the "touch" command in terminal or make a blank text file. Under the configuration tab set the destination to "/tmp" and then under the Scripts tab choose a preflight script and select your script "whatever.sh"
     
  3. larkost macrumors 6502a

    Joined:
    Oct 13, 2007
    #3
    You do not need to have a file in the package, I do "payload free" packages all the time.

    If you are new to packaging on the Mac side I would avoid PackageMaker. There are a few things that are only supported out of PackageMaker, but for the most part the bugs in PackageMaker drive most of us away from it. My favorites are Iceberg (for packages that need to work on 10.4) and Packages (for distribution-style packages).

    But if you feel you need to use PackageMaker, then here are some tips:

    1) You need to make sure you match the name that PackageMaker wants exactly. So preflight scripts must be named exactly 'preflight' (no suffix at all).

    2) You have to make sure you set the executable bit... it won't do it for you.

    3) You have to have workable permissions... tripped over that one once.

    And then some generic advice:

    1) Make sure you are calling everything with full paths, so 'ls' would be '/bin/ls'. Not getting into this habit will come back and bite you.

    2) Be really aware of what user your scripts are going to be run as.

    3) If you are writing things that might go outside your control and be used by others, then you will want to make sure that you write your script to work on the target volume ($3 in bash). Do this even if you have the 'only root volume' checked.

    4) Don't use AppleScript for anything unless you really know what you are doing (and then you won't anyways). Installers can be run at the loginwindow and AppleScript can have some unpredictable side-effects.

    5) Don't try to interact with the user, this is a sign of a badly designed application. Fix that problem, don't plaster over it in the installer.
     

Share This Page