Skip to content

Using Script2Pkg

rtrouton edited this page Jun 27, 2023 · 5 revisions

Create a payload-free package

To create a payload-free package using this app, you will need two things:

  • The app
  • A script

Once you have both of those items available, please use the procedure to create a payload-free package.

  1. Launch the app.

mainwindow_disabled

  1. Click the Select scripts button.

  2. In the window which appears, select the script(s) you want to use and click the Build button.

mainwindow_choosescript

  1. Installer package(s) will be created and stored in the same location as the script(s) which were selected. Each installer package will have the same name as the source script.

finder_package.png

Creating signed packages

To create a signed payload-free package using this app, you will need these things:

Once you have all items available, please use the procedure to create a signed payload-free package:

  1. Launch the app.

mainwindow_noselection

  1. Select the Sign packages option.

mainwindow_signing.png

  1. Click the Select scriptsbutton.

  2. In the window which appears, select the script(s) you want to use and click the Build button.

mainwindow_choosescript

  1. Installer package(s) will be created and stored in the same location as the script(s) which were selected. Each installer package will have the same name as the source script.

finder_package

Signing existing packages

The app is able to sign existing packages. This allows you to sign an existing package that not has been signed or to resign a package with an expired signature. Once you have an installer package you want to sign, please use the procedure below:

  1. Launch the app.

mainwindow_noselection

  1. Make sure the Sign packages option is selected.

mainwindow_signing.png

  1. Under the File menu, choose Sign Existing Package…

menu_file_sign

  1. Select the package you want to sign and click the Sign button.

menu_file_sign_select

  1. If the package is already signed, the app asks you if the existing signature should be replaced. Click the Replace button to continue.

sign_existing_replace

  1. The app will report back if signing was successful.

sign_existing_success

Creating notarized packages

To create a notarized payload-free package using this app, you will need these things:

Once you have all items available, please use the procedure to create a signed and notarized payload-free package:

  1. Launch the app.

mainwindow_noselection

  1. Select the Sign packages option.

mainwindow_signing

  1. Select the Notarize packages option.

mainwindow_notarizing

  1. Click the Select scripts button.

  2. In the window which appears, select the script(s) you want to use and click the Build button.

mainwindow_choosescript

  1. Installer package(s) will be created and stored in the same location as the script(s) which were selected. Each installer package will have the same name as the source script.

finder_package

Notarizing existing packages

The app is able to notarize existing packages. Once you have an installer package you want to notarize, please use the procedure below:

  1. Launch the app.

mainwindow_noselection

  1. Make sure the Sign packages and the Notarize packages options are selected.

mainwindow_notarizing

  1. Under the File menu, choose Notarize Existing Package…

menu_file_notarize

  1. Select the package you want to notarize and click the Notarize button.

menu_file_notarize_select

Notarizing a package (especially very large ones) may take a while…

notarize_exisiting_wait

  1. The app will report back if notarization was successful.

notarize_existing_success

Creating folder-based packages

You may need to create an installer package where you need to provide additional resources to the script you're trying to package into an installer package. These resources may be an additional script, an application binary, or even another installer package. This tool provides an option for doing so, with the following requirements:

You must create a folder. Inside the folder, you must have at least one script named exactly as follows:

  • preinstall
  • postinstall

These scripts must also be set as executable files. The reason is that two categories of scripts have been defined for use with installer packages:

  • preinstall: The preinstall script is run before files are being installed. If the script does not return an exit status of zero, Installer will cancel the installation.
  • postinstall: The postinstall script is run after files have been installed. If the script does not return an exit status of zero, Installer will declare the installation failed.

The names of the scripts must also be exactly as described, as the Installer application can only use executable files with those names as scripts which can run pre-installation and post-installation actions. If the file names are different, Installer will not recognize or use them.

Once you have all items available, please use the procedure to create the package:

  1. Launch the app.

mainwindow_noselection

  1. If you want to sign the installer package you're creating, make sure at least the Sign packages option is selected. Also select the Notarize packages option if you want the package to be notarized.

mainwindow_signing.png

  1. Click the Select scriptsbutton.

  2. In the window which appears, select the folder containing your components and click the Build button. In this example, the jq binary is included besides the postinstall script, so the postinstall script can run jq right from within the package without installing it.

mainwindow_choosefolder

  1. The installer package will be created and stored in the same location as the folder which was selected. The installer package will have the same name as the source folder.

finder_package

Verifying installer packages

The app is able to check any installer package and report on the following:

  • if the installer package is signed with a valid code signing certificate

  • if the installer package is signed with a valid code signing certificate and notarized

Once you have an installer package that you want to check, please use the procedure below to validate its status:

  1. Launch the app.

  2. Under the File menu, choose Validate Package Signature…

menu_file_validate

  1. Select the package you want to check and click the Validate button.

menu_file_validate_select

The app will report back on the package signing and notarization status.

Package not signed or notarized

validation_unsigned

Package signed with an expired certificate

validation_expired

Package signed with a valid certificate and not notarized

validation_signed

Package signed with a valid certificate and notarized

validation_notarized

Notifying about new packages

To configure notifications about new packages following their creation, use the following procedure:

  1. Go to the Script2Pkg menu and select Settings…

menu_script2pkg_settings

  1. Select the General option.

settings_general_toolsmissing

  1. To enable notifications, select the Show notification when packaging has been finished option.

settings_general_notifications

With the the Show notification when packaging has been finished option enabled, creation of new packages will include a notification from Notification Center similar to the one shown below.

notification

Reverting to Default Settings

To reset back to the default settings, de-select the Show notification when packaging has been finished option.

Choosing a package location

By default, new packages will be stored in the same location as the selected script(s). If you want to choose an alternate storage location, use the following procedure:

  1. Go to the Script2Pkg menu and select Settings…

menu_script2pkg_settings

  1. Select the Locations option.

settings_locations_overwrite_selected

To change the location where packages are stored following their creation, select the Package location: drop-down menu and select a new location.

settings_locations_other

settings_locations_choose

settings_locations_sameasscript

Reverting to Default Settings

To change back to the default location, select the Package location: drop-down menu and select the Same as script option.

menu_script2pkg_settings

Duplicate package name handling

By default, new packages with the same name as an existing package stored in the same location will be re-named to avoid having the same name as the existing package. This behavior can be changed to overwrite the existing package.

To configure new packages to automatically overwrite existing packages as part of the package creation process, use the following procedure:

  1. Go to the Script2Pkg menu and select Settings…

menu_script2pkg_settings

  1. Select the Locations option.

settings_locations

  1. Select the If package exists: drop-down menu and choose Overwrite new package.

settings_locations_overwrite

settings_locations_overwrite_selected

Reverting to Default Settings

To change back to the default setting, select the If package exists: drop-down menu and choose Rename new package.

settings_locations_rename

Setting package identifier

All macOS installer packages need an identifier so that macOS can recognize if a package is a new installation or an upgrade from a previously-installed installer package.

By default, the package identifier used by the app will begin with the following: corp.sap.Script2Pkg

This is referred to in the context of the app as the identifier prefix . The remainder of the identifier will be a UUID. For example, using the default settings will may result in a package with the following package identifier:

corp.sap.Script2Pkg.5BA0E8CB-99B2-4FC2-85AE-0C1CC85ACC05

If you want to choose an alternate identifier prefix, use the following procedure:

  1. Go to the Script2Pkg menu and select Settings…

menu_script2pkg_settings

  1. Select the Packaging option.

settings_packaging

  1. Click in the Package identifier prefix: entry blank and enter whatever you want as the new identifier prefix. Packages created by the app will now use this identifier prefix, followed by a UUID, as the package identifier.

settings_packaging_identifier

If you want to have whatever you entered into the Package identifier prefix: entry blank to be the complete package identifier, enable the Use prefix as fixed package identifier option.

Packages created by the app will now use the identifier prefix as the package identifier. No UUID information will be added to the package identifier.

settings_packaging_identifier_fixed

Reverting to Default Settings

To reset back to the default settings, remove the current entry in the Package identifier prefix: entry blank. If applicable, also uncheck Use prefix as fixed package identifier option.

Setting package receipt creation

Installer package receipt files are used by macOS to maintain a record of what the Installer application has installed. For more information on installer package receipts, please see the FAQ

Normally, a receipt file is created each time you install new software via a package file but there is an exception to this rule: payload-free packages normally do not install any files and do not leave a receipt behind.

By default, installer packages created by this tool will not leave an installer package receipt when the package is installed. If you need to create installer packages which leave package receipts, use the following procedure:

  1. Go to the Script2Pkg menu and select Settings…

menu_script2pkg_settings

  1. Select the Packaging option.

settings_packaging

  1. Enable the Create package receipts option.

settings_packaging_receipts

Reverting to Default Settings

To reset back to the default settings, uncheck the Create package receipts option.

Setting package version

A macOS installation package can have an optional version number. This is most useful if the installer package leaves a receipt, as the package identifier and version information are included in the receipt. For more information on installer package receipts, please see the Glossary.

By default, the package version used by the app will be the following: 1.0.0

If you want to choose an alternate version number, use the following procedure:

  1. Go to the Script2Pkg menu and select Settings…

menu_script2pkg_settings

  1. Select the Packaging option.

settings_packaging

  1. Click in the Default package version: entry blank and enter whatever numeric value you want as the new version number. Packages created by the app will now use this as the package version number.

settings_packaging_version

You can also set the app to try and detect version information from the script’s filename. For example, if the script is named as follows, the app can be set to detect the version information and use it when creating the package: example_3.0.0.sh

  • Go to the Script2Pkg menu and select Settings…

  • Select the Packaging option.

  • Enable the Use package version from script name if possible option. Packages created by the app will now try to identify version information from the script’s name and use that information as the package version number.

settings_packaging_versionfromscript

Reverting to Default Settings

To reset back to the default settings, remove the current entry in the Default package version: entry blank. If applicable, also uncheck the Use package version from script name if possible option.

Creating distribution packages

By default, installer packages created by this tool are component packages, but you can set the tool to create distribution packages instead of component packages. Distribution packages are a special format of installer packages and Apple requires their use in place of using component installer packages in certain circumstances. For more information on component and distribution packages, please see the Glossary.

If you need to create distribution packages, use the following procedure:

  1. Go to the Script2Pkg menu and select Settings…

menu_script2pkg_settings

  1. Select the Packaging option.

settings_packaging

  1. Enable the Create distribution packages option.

settings_packaging_distribution

Reverting to Default Settings

To reset back to the default settings, uncheck the Create distribution packages option.