Package an existing native product
Use the native layout when the product already builds its own binaries, start script and DSM window; synopkgland runs your hooks, checks the result and writes one SPK per architecture, without generating a backend or UI. For generated code, see Build a native app.
Set it up
Section titled “Set it up”Write dsm-package.yaml by hand; the native layout is not an init template.
schema: 2backend: {kind: native}package: ExampleNativeversion: 1.2.3build: 8displayname: Example Nativedescription: Existing native productmaintainer: Exampleos_min_ver: 7.0-40000arches: [x86_64, armv8, armv7]layout: payload: target/native-layout/{arch}/payload metadata: target/spk-metadata binaries: - {path: bin/app, linkage: static, arches: [x86_64, armv8]} - {path: bin/app, linkage: dynamic, arches: [armv7]}native: prepare: {cwd: ., command: [python3, package/prepare.py]} hook: {cwd: ., command: [python3, package/compile.py]} toolkits: x86_64: - {url: 'https://example.com/toolkit.txz', sha256: '<64 lowercase hex digits>'}Replace the toolkit URL and digest, or remove toolkits if unused.
synopkgland checksynopkgland build --arch x86_64,armv8,armv7synopkgland inspect dist/ExampleNative-1.2.3-0008-x86_64.spkWithout --arch, build covers every entry in arches. deploy --host <nas> builds and installs only the NAS architecture (armv8 for an aarch64 NAS when declared); raise build before each deploy. See Ship.
Manifest fields
Section titled “Manifest fields”Set schema: 2 and backend: {kind: native}. build accepts 1–2147483647 and arches may also use armv8; other identity fields follow the manifest reference.
| Field | Rule |
|---|---|
| Allowed keys | schema, backend, package, version, build, displayname, description, maintainer, metadata, icon, os_min_ver, privilege, arches, layout, native |
layout | payload (files; {arch} allowed), metadata, binaries ({path, linkage, arches?}; one per architecture) and optional anchors (<key>_sha256) |
native | hook (required), prepare (once, before hooks), toolkits (<arch>: [{url, sha256}]) |
reproducible | Optional {inputs?, clean?} for build --verify-reproducible; see reproducible builds. |
Paths are relative, never absolute or containing .. or braces other than {arch}. A compose.yaml beside it is rejected.
A hook is {command: [argv...], cwd?: '.', env?: {...}}, runs without a shell inside the project, and must exit 0. env keys match ^[A-Z_][A-Z0-9_]*$, not SYNOPKGLAND_.
| Variable | Meaning |
|---|---|
SYNOPKGLAND_PACKAGE | Package name |
SYNOPKGLAND_VERSION, SYNOPKGLAND_BUILD, SYNOPKGLAND_SPK_VERSION | Version, build number, and version plus the build padded to 4 digits |
SYNOPKGLAND_PROJECT_DIR | Absolute project root |
SYNOPKGLAND_ARCH, SYNOPKGLAND_TOOLKIT_DIR, SYNOPKGLAND_WORK_DIR | Current architecture, extracted toolkit tree, and empty scratch folder removed after the build. Compile hook only. |
build --jobs <n> runs the compile hook for up to n architectures at once. It needs {arch} in layout.payload (the CLI refuses --jobs above 1 otherwise) and no shared output folder; use SYNOPKGLAND_WORK_DIR for scratch. native.prepare runs once.
Toolkits download over HTTPS and are checked against sha256 each build. SYNOPKGLAND_CACHE_DIR sets the cache (default $XDG_CACHE_HOME/synopkgland or ~/.cache/synopkgland, ~/Library/Caches/synopkgland on macOS), which must not be a symlink or writable by other users. Archives are extracted with the tar on PATH (GNU tar or bsdtar); a later archive can write through a folder symlink an earlier one created.
Layout rules
Section titled “Layout rules”check and build verify both folders.
| Area | Rule |
|---|---|
| Files and size | No symlinks, special files or setuid/setgid bits; each file at most 256 MiB, all files at most 1 GiB. |
| Binaries | Executable ELF for the architecture, with matching linkage. |
metadata top level | Only conf, scripts, WIZARD_UIFILES, PACKAGE_ICON.PNG and PACKAGE_ICON_256.PNG (not both with manifest icon) |
scripts/* | start-stop-status is required; no sudo, chown root or chmod +s. |
| Lifecycle scripts | Executable: preinst, postinst, preuninst, postuninst, preupgrade, postupgrade, start-stop-status, prereplace, postreplace |
conf | privilege uses defaults.run-as: package (optional matching username/groupname); resource takes only an empty systemd-unit; systemd holds top-level *.service with one matching User= and optional Group=. |
| Service units | No line continuations. User, Group and Exec* only in [Service]; no AmbientCapabilities, SupplementaryGroups, PermissionsStartOnly, RootDirectory or RootImage; no +/! on Exec*. |
The native layout has no root option; the package runs as its own account.
Product root helpers and upgrades
Section titled “Product root helpers and upgrades”Bind the grant to the approved capabilities, package account and pinned task command, not to a build, manifest or file-tree digest. Declare each root payload in layout.anchors so a new SPK can change root code without a new approval:
layout: anchors: example_helper_sha256: bin/helper example_bootstrap_sha256: bin/bootstrap| Rule | Value |
|---|---|
| Key and path | ^[a-z][a-z0-9_]{0,48}_sha256$ (not synopkgland_, at most 16 keys) naming a regular payload file without {arch} |
build and inspect | build fails on a missing file or a key that collides with another INFO field; inspect refuses an SPK whose anchor is changed, duplicated, missing or undeclared |
For every architecture, build writes the file’s SHA-256 into the root-owned INFO, for example example_helper_sha256="<64 lowercase hex>". The helper reads one valid line per key, copies the payload into its protected folder, checks the copy and only then runs it; a missing, duplicated or different value keeps the grant inactive until approval. Revoke the grant on upgrade only when the capabilities change, with reason: upgrade_reapproval in authorization.status.
Architectures
Section titled “Architectures”arches value | ELF check | Notes |
|---|---|---|
x86_64 | 64-bit, machine 62 | |
aarch64 | 64-bit, machine 183 | INFO arch lists the aarch64 platforms armada37xx rtd1296 rtd1619 rtd1619b, as native-go and binary packages do. |
armv8 | 64-bit, machine 183 | Same binary format as aarch64; the SPK keeps the armv8 name. |
armv7 | 32-bit, machine 40 |
dynamic linkage depends on the target DSM’s libraries; pin the matching toolkit in native.toolkits.
Limits
Section titled “Limits”logs rejects a native layout; check, build, inspect, deploy and status work. inspect checks the archive without installing it and does not prove the product runs on a device.
Troubleshooting
Section titled “Troubleshooting”| Code or message | Cause | Fix |
|---|---|---|
NATIVE_LAYOUT_INVALID: schema 2 required | schema is not 2, or backend is missing. | Set schema: 2 and backend: {kind: native}. |
NATIVE_LAYOUT_INVALID: ELF architecture mismatch | The binary is not for the architecture being built. | Build the right binary in the hook. |
NATIVE_LAYOUT_INVALID: native hook failed | A hook exited non-zero. | Run the hook command by hand. |
See Errors for every code.