Pack Stage:

In the Pack Stage, packs all the necessary files according to your metadata and creates a final Synology Package in the result_spk folder. If you want to enter the Pack Stage without the Build Stage, simply run with the-i option.

For example, the following command will execute ${project}/SynoBuildConf/install without signing and putting the final package SPK file (if any) to /toolkit/result_spk.

cd /toolkit
pkgscripts/ -i --no-sign ${project}

Pack Stage Work Flow:

The workflow of the Pack Stage is as follows.

  1. will execute the build script SynoBuildConf/install.
    1. Create INFO file by using
    2. Move necessary files to a temporary folder, /tmp/_install, for instance, and create package tgz.
    3. Move necessary metadata and resources to the temporary folder, /tmp/_pkg, for instance, and create the final Synology Package.
  2. will sign the newly created Synology Package file with a gpg key which is placed under /root/.

The following figure shows the work flow of the Pack Stage.



This file must be written in bash and indicates the front-end script on how to pack your project. The current working directory is /source/${project} under chroot environment. If this is the top project of your package, this file will define how to create the final package SPK file, including directory structure and the INFO file in your SPK. (Please refer to INFO chapter)

Define SynoBuildConf/install for installation metadata, resource files and packing your package.

# Copyright (C) 2000-2016 Synology Inc. All rights reserved.

### Use PKG_DIR as working directory.
rm -rf $PKG_DIR
mkdir -p $PKG_DIR

### get spk packing functions
source /pkgscripts/include/

create_inner_tarball() {
    local inner_tarball_dir=/tmp/_inner_tarball

    ### clear destination directory
    rm -rf $inner_tarball_dir && mkdir -p $inner_tarball_dir

    ### install needed file into PKG_DIR
    make install DESTDIR="$inner_tarball_dir"

    ### create package.txz: $1=source_dir, $2=dest_dir
    pkg_make_inner_tarball $inner_tarball_dir "${PKG_DIR}"

    local scripts_dir=$PKG_DIR/scripts

    ### Copy Package Center scripts to PKG_DIR
    mkdir -p $scripts_dir
    cp -av scripts/* $scripts_dir

    ### Copy package icon

    ### Generate INFO file
    ./ > INFO

    ### Create the final spk.
    # pkg_make_spk <source path> <dest path> <spk file name>
    # Please put the result spk into /image/packages
    # spk name functions: pkg_get_spk_name pkg_get_spk_unified_name pkg_get_spk_family_name
    mkdir -p /image/packages
    pkg_make_spk ${PKG_DIR} "/image/packages" $(pkg_get_spk_family_name)


We will briefly explain the scripts above.

In the beginning, the script will call the PrepareDirs function which will prepare the necessary folder for the project.

After creating the folder, the script called SetupPackageFiles will move the necessary resource files to $INST_DIR and $PKG_DIR. In this step, we have called the file to create the INFO file. Although you may put the codes that will generate the INFO file in the SynoBuildConf/install script, we highly recommend that you create the INFO seperately. Generally, we name it You can see how to write in the following subsections.

  • INFO
  • scripts
  • binary

After moving the resource file to the proper location, we will call the MakePackage function to create the package for us. We have included/sourced a helper script called which is located in /pkgscripts/include. This script creates the final package SPK file in the correct format. The pkg_make_package and pkg_make_spk, which are defined in *, create the Synology Package. You can see how to use this helper function below.

  • pkg_make_inner_tarball $1 $2: Create $2/packages.tgz from files in $1.
  • pkg_make_spk $1 $2: Create $2/spk from files in $1.

As mentioned earlier, is just an optional script. You can create the INFO file by hand or move the code to SynoBuildConf/install. However, we strongly recommend that you utilize so that you can create the INFO file separately from SynoBuildConf/install.

# Copyright (c) 2000-2016 Synology Inc. All rights reserved.

source /pkgscripts/include/

displayname="Minimal Package"
maintainer="Synology Inc."
description="this is a minimal package"
[ "$(caller)" != "0 NULL" ] && return 0

Note: The above code is just an example to show some important variables for pkg_dump_info. If you want to know more details about the INFO file and each of the fields, please refer to INFO.

Similar to SynoBuildConf/install, we must first include After that, we can set up the proper variables and call the pkg_dump_info to create the INFO file correctly.

As you may have noticed, we used another helper function called pkg_get_platform to set the arch variable. This variable indicates the current platform we are building.

The following statements indicate how to use the helper functions.

  • pkg_get_spk_platform: Return platform for “arch” in INFO.
  • pkg_dump_info: Dump INFO according to given variables.

After creating the file, remember to add executable bit in

chmod +x

Pack util functions

Synology package framework provides several functions and and increases efficiency of packing packages. The functions such as generating arch information in the INFO file, separating spk name and creating spk will be enable after executing /pkgscripts/include/ undefined.

Platform functions

A spk can be installed on one or more platforms. You can decide which platforms can install this spk via spk INFO file.

function name Values Description
(No function) noarch Package only contain scripts. spk can be run on all synology models.
pkg_get_platform_family (DSM6.0 only) x86_64 i686 armv7 armv5 ppc... Unify platforms with same kernel into a platform family. spk can run on same family synology models.
pkg_get_spk_platform bromolow cedarview qoriq armadaxp... Directly output the platform where the toolkit environment is used. spk only can be run on the specific platform.
  • First, if your package doesn't have any binary, you can use noarch as the platfrom and write the scripts for your package. Package with arch=noarch can be installed onto any synology model.
  • Second, if your package doesn’t have any kernel related functions, the package can run on the same architecture platforms. Use function pkg_get_platform_family to get platform family. Package can be installed on the models which are included in the same platform family. For example, package with arch=x86_64 can be install onto bromolow x64 cedarview dockerx64 broadwell models. Please refer to the platform family map at github. (Note: Platform family only support DSM6.0 or upper version)
  • Third, if your package contain kernel related functions, every platforms will need a specific spk. Please use function pkg_get_spk_platform to get the platform(s) which be compatiable with your toolkit environment.

spk name functions

After spk generated, we need to distinguish spk name from platform. We can use spk name functions:

Function name Corresponding platform function Example Description
pkg_get_spk_name pkg_get_spk_platform minimalPkg-bromolow-1.0.0000.spk / minimalPkg-cedarview-1.0.0000.spk ... spk name depend on which toolkit environment is using.
pkg_get_spk_name noarch minimalPkg-1.0.0000.spk If package platform="noarch", this function will output spk name without platforn info.
pkg_get_spk_family_name pkg_get_platform_family minimalPkg-x86_64-1.0.0000.spk spk name will be unified into platform family. The same platform family will geneate same spk name. i.e bromolow and x64 will has same spk name.

You need to input INFO path as argument. If no path input, the function will get INFO file from $PKG_DIR/INFO automatically without inputting INFO path.

Create spk function

Developer can use pkg_make_spk to create spk.


pkg_make_spk $source_path $dest_path $spk_name

source_path is spk source directory. All spk files must copy into this direcotry before run pkg_make_spk.
dest_path is target spk path.
spk_name is spk name with/without platform info.

pkg_make_spk /tmp/_test_spk "/image/packages" $(pkg_get_spk_family_name)