Payload-Free Package Creator.app

I do a lot of work with payload-free packages and I’ve looked for a while for a tool that would let me easily create them from existing scripts. While I have a process for creating them as needed with pkgbuild, this approach still requires some setup work.

Payload-Free Package Creator logo

After thinking about it and taking a look at various approaches, I’ve developed Payload-Free Package Creator.app, an Automator application that will allow the selection of an existing script and create a payload-free package that runs the selected script. For more details, see below the jump.

Using Payload-Free Package Creator.app

1. If needed, download the Payload-Free_Package_Creator_Application.zip file from the application directory in my GitHub repo.

2. Once downloaded and unzipped, double-click on the Payload-Free Package Creator application.

Screen Shot 2014-03-07 at 5.35.57 PM

3. You’ll be prompted to select the script that you want to create a payload-free package from.

Screen Shot 2014-03-07 at 7.33.43 PM

4. Once you’ve selected the script, you’ll be prompted to name the payload-free package. By default, the name filled in will be Payload-Free Installer Package.

Screen Shot 2014-03-07 at 5.25.04 PM

This name can be changed as desired.

Screen Shot 2014-03-07 at 5.21.36 PM

5. Once you’ve entered a name for the installer package, you’ll be prompted for a package identifier. By default, the name filled in will be com.github.payload_free

Screen Shot 2014-03-07 at 5.21.48 PM

This name should be changed to be something unique.

Screen Shot 2014-03-07 at 5.22.04 PM

6. Once the package name and package identifier have been set, Payload-Free Package Creator.app will prompt for an administrator’s username and password.

Screen Shot 2014-03-07 at 5.22.17 PM

7. Once the admin username and password are provided, Payload-Free Package Creator.app will create the payload-free package and prompt you when it’s finished.

Screen Shot 2014-03-07 at 5.22.25 PM

8. Click OK at the prompt and a new Finder window will open to display the newly-created payload-free package.

Screen Shot 2014-03-07 at 5.24.04 PM

Screen Shot 2014-03-07 at 5.24.16 PM

9. Payload-Free Package Creator.app will automatically exit once finished.

How Payload-Free Package Creator.app works

Payload-Free Package Creator.app is an Automator application that uses AppleScript, shell scripting and pkgbuild behind the scenes to create payload-free packages. When a script is selected, the following process takes place:

1. The script is copied to /tmp and the file is renamed to postinstall, to match the name that pkgbuild is expecting for a post-installation script.

2. After the package name and package identifier are chosen, /tmp is checked to make sure that there is not an existing directory that is named the same as the chosen name. If a matching directory is found, it is removed.

3. A new directory is created in /tmp that matches the chosen name of the package.

4. Next, a scripts directory is created inside of /tmp/package_name_here.

5. The postinstall script is moved to /tmp/package_name_here/scripts.

6. The payload-free package is built by pkgbuild using the postinstall script stored in /tmp/package_name_here/scripts.

7. The finished payload-free package is stored in /tmp/package_name_here and the user is prompted that the process is finished.

8. Once the user is notified and clicks OK, a new Finder window opens for /tmp/package_name_here.

The total workflow looks like this:

Screen Shot 2014-03-07 at 4.32.02 PM

The AppleScript used to create the payload-free package as part of the Automator work is below:


on run {input, parameters}
— this repeat loop prevents empty strings from being submitted for the package name value
set q to 0
repeat while q is 0
set result to text returned of (display dialog "Enter a Name For Your Payload-Free Installer Package:" default answer "Payload-Free Installer Package")
if result is not "" then
set pkgname to result
set q to 1
end if
end repeat
— this repeat loop prevents empty strings from being submitted for the package identifier value
set q to 0
repeat while q is 0
set result to text returned of (display dialog "Enter a Package Identifier:" default answer "com.github.payload_free")
if result is not "" then
set pkgid to result
set q to 1
end if
end repeat
— Set the postinstall script to be executable
do shell script "chmod a+x /tmp/postinstall" with administrator privileges
— Remove any existing build directories that have the same name as the new payload-free package
do shell script "rm -rf /tmp/" & quoted form of pkgname & "/" with administrator privileges
— Create the build directories for the payload-free package
do shell script "mkdir /tmp/" & quoted form of pkgname & "" with administrator privileges
do shell script "mkdir /tmp/" & quoted form of pkgname & "/scripts" with administrator privileges
— Move the postinstall script into the correct build directory
do shell script "mv /tmp/postinstall /tmp/" & quoted form of pkgname & "/scripts" with administrator privileges
— Build the payload-free package
do shell script "pkgbuild –identifier " & quoted form of pkgid & " –nopayload –scripts /tmp/" & quoted form of pkgname & "/scripts /tmp/" & quoted form of pkgname & "/" & quoted form of pkgname & ".pkg" with administrator privileges
— Display dialog that the payload-free package has been created
display alert ((pkgname) as string) & ".pkg has been created."
— Open a new Finder window that shows the new package
do shell script "open /tmp/" & quoted form of pkgname & ""
return input
end run

All Payload-Free Package Creator components and scripts are available at my GitHub repo:

https://github.com/rtrouton/Payload-Free-Package-Creator

The Automator workflow files and the AppleScript are also available via the link above if you want to build a customized Payload-Free Package Creator for your own environment.

  1. March 8, 2014 at 8:21 pm

    Wow, this looks to be exceptionally handy. Thanks!

  2. Ben Goodstein
    March 10, 2014 at 2:08 pm

    Seconded. Good work!

  3. March 18, 2014 at 7:50 pm

    This is great could you add a section for version number?

  4. March 16, 2015 at 8:54 pm

    when I attempt to import a .pkg built with this tool using munkiimport (2.2.2.2414) I get the following error:

    WARNING: No valid Distribution or PackageInfo found.
    somePayloadFree.pkg doesn’t appear to be a valid installer item!
    Getting package info failed.

    Thoughts?

    • cashxx
      April 16, 2015 at 7:18 pm

      Was just coming in to say the same thing! Haven’t found a fix yet.

  5. April 16, 2015 at 7:44 pm

    Payload-free packages generated with this tool should not be used with Munki. This is because it uses pkgbuild’s method of generating payload-free packages, which does not leave a recipt behind.

  6. sahil rai
    April 8, 2016 at 3:30 am

    but how to install it in kali linux…?

  7. Scott
    April 12, 2020 at 11:17 pm

    Now that PPPC is here, how do we set it to allow writing to 10.15.4 space that is readonly?

  1. No trackbacks yet.

Leave a reply to Scott Cancel reply