Repository navigation
Pkg
The pkg format builds a flat product-archive .pkg that installs a file
tree onto a Mac. embala authors the archive directly — the same shape Apple's
productbuild emits — so you can build a .pkg on any OS, no macOS host or
Xcode tooling required.
The honest scope up front: a .pkg here is a file-drop installer. It lays
your files down under an install location, optionally runs a preinstall and
postinstall script you supply, and records a receipt so the system knows the
files are there. macOS ships no uninstaller for it, and embala adds none
either. If you need a double-click uninstall, this format is the wrong tool;
see Limitations.
A single artifact named <name>-<version>.pkg (from [package].name and
[package].version). Installing it copies the payload tree under your
install-location — which must be an absolute path — and writes a receipt
under your [package].identifier so pkgutil can report and later forget it.
Two ways to install:
| How | Command |
|---|---|
| Double-click | Opens the standard macOS Installer.app GUI. |
| Scripted | sudo installer -pkg hello-1.0.0.pkg -target / |
-target / installs into the local system domain (the default), which is why
it needs sudo.
The standard Installer wizard, opened on macOS 26:

Every file in the archive is normalized the same way, regardless of the machine that built it:
| Fact | Behavior |
|---|---|
| Ownership | Fixed root:wheel (uid 0, gid 0) on every file and directory. |
| File mode | The entry's mode if set (e.g. 0o600); otherwise derived from the source file's exec bit: executable source → 0755, otherwise 0644. |
| Directory mode |
0755, unless declared in directories with a mode. |
| Apple Silicon | Installs without Rosetta. The archive declares both x86_64 and arm64 host architectures, so Installer never assumes an Intel-only payload. |
| Relocatable | No — the payload always lands at install-location. |
Because ownership, timestamps, and ordering are all pinned, the build is
deterministic: the same inputs produce a byte-identical .pkg.
By default a .pkg installs into the system domain and needs sudo. Set
enable-user-home = true and the package also becomes installable into the
user's home domain — no sudo required:
installer -pkg hello-1.0.0.pkg -target CurrentUserHomeDirectoryThis adds the CurrentUserHome domain to the package; the system-domain
(-target /) install still works as before. Its primary use is user-scope
and test installs — installing without elevation, e.g. in CI or a throwaway
account, then tearing it back down.
scripts names a directory, relative to the config file, that embala packs the
way pkgbuild --scripts does:
[pkg]
install-location = "/usr/local"
scripts = "scripts"
files = [{ src = "dist/hello", dest = "bin/hello" }]- A top-level
preinstallruns before the payload is laid down, and a top-levelpostinstallruns after. Either or both may be present. Installer gives each one pkgbuild's default 600-second timeout. - Everything else in the directory ships alongside them (helper scripts, subdirectories, data files), so a hook can call or source files next to it.
- Each script keeps its exec bit: an executable source installs
0755, anything else0644. Symlinks are followed. - A
preinstallorpostinstallthat isn't executable fails the build.pkgbuildwould package it anyway, andinstallerwould then fail on the target machine. - On a Windows build host there is no exec bit to read, so embala treats a file
as executable if it starts with
#!or is a Mach-O binary. Give hook scripts a shebang line.
Installer runs the hooks with the usual arguments: $1 is the package path,
$2 the install location (under your home directory for a home install), and
$3 the target volume. They run as root for a system-domain install, and as
you for a CurrentUserHomeDirectory install.
The [pkg] section of embala.toml:
| Field | Required | Meaning |
|---|---|---|
files |
yes | Payload entries. Each is { src, dest, mode }: src is relative to the config file's directory; dest is the /-separated path relative to install-location; mode is optional permission bits such as 0o600. |
directories |
no | Directories to ship with a mode, each { dest, mode }. A declared directory ships even if nothing is under it. mode defaults to 0755. |
install-location |
yes | Absolute path the payload installs under (e.g. /usr/local). Must start with /, or the build fails. |
enable-user-home |
no |
false by default. When true, allows the sudo-free CurrentUserHomeDirectory install described above. |
scripts |
no | Directory of install scripts, relative to the config file. See Install scripts. |
[package]
name = "hello"
version = "1.0.0"
identifier = "com.example.hello"
display-name = "Hello"
# ...
[pkg]
install-location = "/usr/local"
enable-user-home = true
files = [
{ src = "dist/hello", dest = "bin/hello" },
{ src = "dist/README", dest = "share/hello/README" },
]With the config above, dist/hello (executable) installs to
/usr/local/bin/hello mode 0755, owned root:wheel; README to
/usr/local/share/hello/README mode 0644. Intermediate directories
(bin, share, share/hello) are created for you.
A file that must not be world-readable, or a directory only root may enter, gets an explicit mode:
[pkg]
install-location = "/Library/Example"
files = [{ src = "credentials", dest = "app/credentials", mode = 0o600 }]
directories = [{ dest = "keys", mode = 0o700 }]app/credentials installs 0600 and keys/ installs 0700, empty; app/
is implied and stays 0755. Modes come from the config, not the source file on
disk: git keeps only the exec bit, and Windows hosts have none, so this keeps
the result the same on every build host. Only permission bits (0o000-0o777)
are allowed.
Upgrades: Installer applies a file's mode even when the file already
exists, but it leaves an existing directory's mode alone. If keys/ is
already there at 0755, installing this package keeps it 0755 (a
pkgbuild-built package does the same). A fresh install gets 0700. If
existing machines need the tighter mode, chmod it in a postinstall
script.
Payload rules enforced at build time:
-
destmust be a relative path with no empty or..segments. - No two entries (files or directories) may share a
dest, and a filedestcan't also be a declared directory or the parent of anotherdest. -
modemust be0o000-0o777: setuid, setgid and sticky bits are rejected. - At least one file is required.
The Installer window title comes from [package].display-name.
A finished .pkg can be signed by adding a [sign.macos] command — embala
signs the archive after building it. See Code-Signing for the command,
tool notes, and what Gatekeeper actually does with the result.
These are deliberate scope decisions, not defects:
-
Single component, non-relocatable. One payload, one fixed install location. No multi-component choices, no user-relocatable install path.
-
No uninstaller. macOS has no native uninstall for a
.pkg, and embala adds nothing on top. Uninstalling is manual: remove the installed files, then forget the receipt sopkgutilno longer reports the package.System-domain install (
-target /):sudo rm -rf /usr/local/bin/hello /usr/local/share/hello sudo pkgutil --forget com.example.hello
Home-domain install (
-target CurrentUserHomeDirectory) — nosudo. The install prefixesinstall-locationwith your home directory (so the example above lands under~/usr/local), and the receipt lives on the user volume:rm -rf ~/usr/local/bin/hello ~/usr/local/share/hello pkgutil --volume ~ --forget com.example.hello
Adapt the
rmpaths to your owninstall-locationanddestentries.pkgutil --pkg-info <identifier>(add--volume ~for a home install) lists what a receipt covers if you need to check before removing.
- Getting-Started — building your first artifact.
-
Configuration-Reference — the full
embala.tomlschema. -
Code-Signing — signing the finished
.pkg. - App-Bundle and MSI, Setup-Exe, Nupkg — the other output formats.