Turning on the Advanced User Options mode is easy and will reveal new options in the user interface of Packages.
When the Advanced User Options mode is on, you should have access to the following new options in the user interface:
Pane | Feature | |
---|---|---|
Project > Settings | Advanced Options | |
Project > Presentation > License | Custom License Template | |
& Raw Package | Package > Settings | HFS+ compression |
Package > Payload | Build Options | |
Elastic Folders | ||
Destination name |
The advanced options for the settings of a distribution project lets you edit options that are useful in a limited number of cases. You can find a list of these options in the Packages documentation.
There are 3 main cases where you may need to use theses advanced options:
This topic is covered in the Q&A 03 article.
By default, after you have installed a .pkg distribution, only the name of the distribution is displayed in the Software > Installations pane of System Information.app.
You can use the 'product' advanced option to make the version of the main application/component be visible in that pane.
The 'hostArchitectures; advanced option can be used to define which architectures (PowerPC, Intel, Apple Silicon) are supported by a distribution.
By default, when the 'hostArchitectures' advanced option is not set, the distribution is assumed to support the PowerPC and Intel architectures. So if you install the distribution on an Apple Silicon based Mac, macOS will strongly suggest to install Rosetta to translate the Intel instructions to ARM ones.
If you know that the binaries in the payloads and additional resources, and the installer plugins support the Apple Silicon architecture:
Starting with Packages 1.2.10, in most cases, you won't have to do this as Packages will determine during the build process which architectures are supported by all the binaries and Installer Plugins in your distribution.
You may still want/need to set the value manually for complex cases such as a distribution with a package for the Intel architecture only and another one for the Apple Silicon architecture only and with OS requirements determining which one will be installed.
When the advanced options are on, the Presentation editor will allow you to select a custom license template in additions to text files and license templates.
Check the Packages License.pkglic document used by Packages to see an example of a custom license template.
This feature is only useful for macOS 10.6 (and later) devices when the targeted volumes is formatted in HFS+.
There are 3 advanced options:
Elastic folders are similar to custom folders. The difference is that the name of an elastic folder can include '/' characters.
As you probably already know, '/' is the path file separator on macOS. And as you may have guessed, this allows an elastic folder to represent a series of enclosed folders.
For example, an elastic folder named "myFolder/mySubfolder" will be transformed to a folder named "myFolder" that contains a folder named "mySubfolder" inside the payload archive of your installation package.
The name of an elastic folder (or a custom folder) can be set to a user defined settings. See User defined settings to learn more about this.
Let's say the payload of your package needs to include a configuration text file whose name is '.configuration'.
Adding this file to the payload hierarchy can be annoying as files starting with '.' are by default invisible in the Finder and the standard open panels.
To show this file in the open panels of Packages, you can:
The remaining problem is that it's still annoying to edit that file as it is still not visible by default in the Finder and your favorite text editor will by default not show the file in the standard open panel (unless you use vi or emacs).
Enters the destination name. It is possible in Packages to set a destination name for a file system item. This name will be the one the file/folder will have in the payload archive of the installation package. This way, the name of you configuration text file can be 'configuration' and its destination name can be '.configuration'. You will be able to add it easily to the payload hierarchy and edit this file with your favorite text editor.
To set a '.configuration' destination name for a file named configuration:
The destination name can be set to a user defined settings. See User defined settings to learn more about this.
User defined settings let you use keywords inside or instead of the string values used for the settings of your Packages projects. You can then define a default value for each keyword.
A keyword is a string that looks like this: ${keyword}.
Here's an example to illustrate how this can be useful:
If a new version of your product requires macOS 10.15 or later, you will need to edit each localization of the error message.
With user defined settings, you can have a user defined setting named MIN_OS_VERSION and then replace each occurrences of "10.14" in your error messages with ${MIN_OS_VERSION}. You can then define the value of MIN_OS_VERSION to be "10.14".
When you need to bump the minimum OS requirement for your distribution project, you now just need to change the value of the MIN_OS_VERSION user defined settings.
If you are building your projects using the packagesbuild command line tool in a build script, you can also set the values of user defined settings using arguments.
For instance, here's an extract of the build.sh script to build the installation package for Packages.
#!/bin/sh
[...]
# Retrieve the version
VERSION="1.0"
if [ -f distribution/Version ];
then
VERSION=`cat distribution/Version`
fi
# Get the current year
CURRENT_YEAR=`date "+%Y"`
[...]
/usr/local/bin/packagesbuild --verbose \
--project Packages.pkgproj \
DISTRIBUTION_PRODUCT_VERSION="${VERSION}" \
COPYRIGHT_END_YEAR="${CURRENT_YEAR}"
[...]
The .pkgproj for Packages includes 2 user defined settings:
This way, no need to to manually update the copyright each year. And the product version for the distribution will always match the version used in the .app.
The list of settings that support user defined settings is available in the user guide.
Copyright 2021-2022 Stéphane Sudre. All rights reserved.