Synology Package Developer
Build DSM packages as production software for an appliance, not as ordinary Linux tarballs. Prefer current official Synology documentation and repositories over the bundled guide-derived notes.
Establish the target
- Read the nearest applicable
AGENTS.md. - Run
date. - Determine:
- exact DSM release and build;
- model, CPU architecture, Synology platform, and package architecture family;
- required Package Center providers and minimum package versions;
- whether the package is script-only, native, web, container-backed, or mixed;
- supported install, upgrade, downgrade, repair, move, stop, and uninstall behavior;
- persistent data, configuration, secrets, ports, shares, and recovery requirements.
- Use
nas-context host,nas-context tools, and the narrowest additional mode when targeting the current NAS. - Search current official Synology documentation, the
SynologyOpenSource/pkgscripts-ngbranch for the target DSM,SynologyOpenSource/ExamplePackages, and the matching official toolchain before version-sensitive implementation.
Do not install the Package Toolkit directly onto DSM. Use a dedicated 64-bit Linux build environment or an isolated container/VM. Never run foreign apt instructions directly on the NAS.
Choose the workflow
- Read references/package-format.md for SPK layout, INFO fields, versioning, dependencies, and metadata.
- Read references/build-toolkit.md for
pkgscripts-ng,EnvDeploy,PkgCreate.py, cross-compilation, platforms, and reproducible builds. - Read references/lifecycle-fhs.md for control scripts, environment variables, lifecycle order, FHS storage, upgrade migration, and uninstall safety.
- Read references/security-resources.md for DSM 7 lower privilege, capabilities, resource workers, shares, ports, services, logging, and notifications.
- Read references/integrations.md for DSM desktop UI, localization, help, authentication, web services, nginx, wizard UI, Docker projects, and databases.
- Read references/testing-publishing.md for validation matrices, installation tests, logs, review, publishing, and support.
- Read references/dsm6-migration.md only for DSM 6 support or DSM 6-to-7 migration.
Create or inspect a project
For a new package, use:
scripts/new_package.py PACKAGE_ID OUTPUT_DIR \
--display-name "Display Name" \
--version 1.0.0-0001 \
--arch noarch \
--os-min-ver 7.2-64570
The generator refuses to overwrite an existing target. Review every generated field and replace the placeholder icon files before packing.
For an existing project:
- Locate
AGENTS.md,INFO/INFO.sh,SynoBuildConf, lifecycle scripts,conf/privilege,conf/resource, payload source, lockfiles, and build configuration. - Run
git status --shortbefore editing. - Run the offline validator:
scripts/validate_package.py PROJECT_DIR --target-dsm 7.2.2
Treat validation warnings as review prompts, not as proof of safety or correctness.
Design the package
- Keep immutable application payload in
target. - Keep persistent configuration in
etc, persistent mutable data invar, private package state inhome, and disposable state intmp. - Define
conf/privilegewith"run-as": "package"by default. - Request privileged integration through the narrowest resource worker. Do not grant root merely to make development easier.
- Declare all package and service dependencies explicitly.
- Register ports and check conflicts. Avoid hard-coded public bindings.
- Design upgrades as reversible migrations with version gates and verified backups.
- Design uninstall to preserve user data unless the user explicitly and separately elects deletion.
- Never embed passwords, API tokens, private keys, cookies, production hostnames, or live credentials in INFO, resources, Compose files, scripts, examples, build logs, or SPKs.
- Pin external dependencies and container images to reviewed versions or immutable digests where practical.
Implement safely
- Make preflight scripts side-effect free.
- Quote shell variables, validate paths, use explicit targets, and make lifecycle operations idempotent.
- Never delete an unresolved or empty path.
- Distinguish install, upgrade, repair, replacement, start, stop, shutdown, and uninstall through
SYNOPKG_PKG_STATUSand relevant old/new version variables. - Preserve the previous working version and data schema until post-upgrade verification succeeds.
- Use database-native dumps or application-supported backups before migrations.
- Do not directly edit DSM-managed nginx, firewall, service, account, or share configuration when a supported worker exists.
- Do not mount
/var/run/docker.sockinto package containers without explicit need and a documented security model. - Never use floating database major versions.
- Do not use proprietary DSM UI internals unless the target release and official examples support them.
Build
- Pin the
pkgscripts-ngbranch/commit and toolkit release. - Deploy the exact target DSM/platform environment.
- Build from a clean source tree or recorded commit.
- Generate INFO deterministically.
- Assemble payload and metadata in fresh, validated temporary directories.
- Run
PkgCreate.pyfor the required platform set. - Record source commit, toolkit commit, DSM target, platform, build command, output checksums, and dependency versions.
- Inspect the finished SPK without installing it:
scripts/inspect_spk.py RESULT.spk
Test on DSM
Do not treat successful packing as successful packaging.
Test on a non-production DSM instance or explicitly designated test NAS:
- clean install and optional wizard branches;
- start, status, stop, restart, and boot behavior;
- dependency startup and failure behavior;
- ports, firewall registration, authentication, permissions, UI, localization, and logs;
- upgrade from every supported predecessor and interrupted migration recovery;
- repair and package move if supported;
- uninstall with data-retention and any explicit data-removal choice;
- reinstall after uninstall;
- offline installation if claimed;
- least privilege, AppArmor/security logs, coredumps, leftover processes/files, and unintended outbound connections.
Protect the current SSH/Codex session. Do not test network, authentication, firewall, reverse-proxy, or package uninstall behavior on this production-like NAS without an explicit safe test plan and rollback.
Completion gate
Claim completion only when:
- source and staged/SPK validation pass;
- required platform builds succeed;
- install, lifecycle, upgrade, rollback, and uninstall tests match the declared support matrix;
- persistent user data survives normal uninstall unless deletion was explicitly chosen;
- no secret is embedded;
- no unexpected listener, privilege, process, file, database, container, volume, or network exposure remains;
- documentation states supported DSM/platform/provider versions and recovery steps;
- checksums and exact build provenance are recorded.