Creating Scripts Using the Requirements Editor

The Requirements Editor provided by PackageMaker allows you to write JavaScript for your distribution using a rules interface as seen in Mail.app. The editor is accessed through the editor drop-down menu in the script-editing sheet.

To create or edit a script using the Requirements Editor, take the following steps:

  1. Specify a wrapper function name. This is will be the root function for your script and is the function you should call to execute the script.
  2. Create one or more clauses and specify the boolean operators used to combine the clauses.
    More Info…
  3. Optionally specify the failure message for each clause.
    More Info…
  4. Add one or more rules to each clause and specify the boolean operator used to combine the rule results.
    More Info…

The Requirements Editor will create its JavaScript output as follows:

Clauses

Clauses are the organizing groups for requirements scripts. A clause is made up of a title, one or more rules, a failure message, and specifies how to combine the rules (a clause can succeed if all or any rules succeed). Clauses will be evaluated in order from top-to-bottom. They can be reordered via drag-n-drop. After two or more clauses are added, PackageMaker will expose radio buttons allowing you to specify how to combine that clause with its neighbors.

Clause Failure

If the clause fails, it will set the my.result object as specified in the PackageMaker user interface. Fatal will cause the Installer to exit, Warn will display the message to the user, but allow installation to continue, and None will act like a Warn.

Rules

You can add one-or-more rules to a clause. A rule specifies a condition you want met. The built-in rules expose almost all of the options available to distribution scripts. The rules editor will warn you if a certain rule only works in certain types of scripts.