Packaging Guide¶
This section covers the details of creating and configuring spksrc packages.
Overview¶
Creating a package involves:
- Writing Makefiles that describe how to build the software
- Configuring package metadata and dependencies
- Setting up services and installation wizards
- Testing and validating the package
Package Types¶
spksrc supports several package categories:
Cross Packages (cross/)¶
Software compiled for the target NAS architecture:
- Libraries (openssl, zlib, curl)
- Command-line tools (git, screen)
- Server applications (nginx, ffmpeg)
SPK Packages (spk/)¶
Final packages installed via Package Center:
- Bundle one or more cross packages
- Include configuration, services, and UI
- Produce
.spkfiles
Native Packages (native/)¶
Tools built for the build host:
- Used during the build process
- Not included in final packages
- Example: cmake, ninja
In This Section¶
- Makefile Variables - Common variables and their meanings
- Build Rules - Build targets and customization
- PLIST Files - Defining package contents
- Service Scripts - Daemons and services
- Wizards - Installation wizards
- Resource Files - DSM 7 resource configuration
Quick Start: Creating a Package¶
1. Create Cross Package¶
Create cross/mypackage/Makefile:
PKG_NAME = mypackage
PKG_VERS = 1.0.0
PKG_EXT = tar.gz
PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = https://example.com/releases
PKG_DIR = $(PKG_NAME)-$(PKG_VERS)
HOMEPAGE = https://example.com
COMMENT = My awesome package
LICENSE = MIT
GNU_CONFIGURE = 1
include ../../mk/spksrc.cross-cc.mk
Create cross/mypackage/digests:
mypackage-1.0.0.tar.gz SHA1 abc123...
mypackage-1.0.0.tar.gz SHA256 def456...
mypackage-1.0.0.tar.gz MD5 ghi789...
2. Create SPK Package¶
Create spk/mypackage/Makefile:
SPK_NAME = mypackage
SPK_VERS = 1.0.0
SPK_REV = 1
SPK_ICON = src/mypackage.png
DEPENDS = cross/mypackage
MAINTAINER = YourName
DESCRIPTION = My awesome package for Synology
DISPLAY_NAME = MyPackage
CHANGELOG = "Initial release"
HOMEPAGE = https://example.com
LICENSE = MIT
include ../../mk/spksrc.spk.mk
3. Build and Test¶
Common Patterns¶
Adding Dependencies¶
# Cross package dependencies
DEPENDS = cross/zlib cross/openssl
# SPK dependencies (installed packages)
SPK_DEPENDS = "WebStation>=3.0"
Applying Patches¶
Place patches in patches/ directory:
Patches are applied in alphabetical order.
Custom Build Steps¶
# Run before configure
pre_configure_target:
cp myconfig.h $(WORK_DIR)/$(PKG_DIR)/
# Run after install
post_install_target:
@$(MSG) Installing extra files
cp -r extra/* $(STAGING_INSTALL_PREFIX)/
Per-Architecture Settings¶
# Architecture variables require the common include first
include ../../mk/spksrc.common.mk
ifeq ($(findstring $(ARCH),$(ARM_ARCHS)),$(ARCH))
CONFIGURE_ARGS += --enable-arm-optimizations
endif
ifeq ($(findstring $(ARCH),$(x64_ARCHS)),$(ARCH))
CONFIGURE_ARGS += --enable-x86-optimizations
endif
Best Practices¶
- Keep it simple - Use standard build systems when possible
- Document changes - Update CHANGELOG for each release
- Test multiple architectures - Build for at least x64 and aarch64
- Follow naming conventions - Use lowercase, hyphens for package names
- Pin dependencies - Specify minimum versions when needed
- Check licenses - Ensure license compatibility