Essential Run Time Files


The “scripts” folder contains shell scripts which are executed during the installation, uninstallation, upgrading, starting, and stopping of packages. There are seven script files stored in the “scripts” folder:

  • postinst
  • postuninst
  • postupgrade
  • preinst
  • preuninst
  • preupgrade
  • start-stop-status

Note: Even if you do not provide any of these script files, the package will be created without any errors. However, when you try to install your package on your DSM system, Package Center will not be able to install your package.

For simplicity, the scripts will look like the following example.

exit 0

More details about these scripts will be explained in the scripts section.


You can add an icon to your package so that when Package Center shows the information of your package, it will use the icon you have provided instead of the default one.

To add an icon to your package, put the image your want into your project source folder, then slightly modify your SynoBuildConf/install script. The following is an example of a modified SynoBuildConf/install from the previous example. For further details regarding package icons, please refer to the Package Structure section.

The only difference from the previous example is that we copied our image files into the $PKG_DIR and renamed it to PACKAGE_ICON.PNG and PACKAGE_ICON_256.PNG. inside the SetupPackageFiles function.

Note: Remember to rename your image to PACKAGE_ICON.PNG and PACKAGE_ICON_256.PNG in all CAPS; otherwise, Package Center will not render the icon properly.

# 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)