Creating Synology NAS Store Packages

Introduction

Although there is comprehensive information available on Synology developers website for the building of packages, but I realized that it doesn’t provide quick information so that a reader can understand the package creation process easily.
In this blog I am making an attempt to provide clear and step by step instructions on how you can create a package for Synology NAS devices. Please note that the current version of DSM (Synology OS) is 6 and I have verified all steps in DSM 6.0 only.

Preparation

In this section, I  will guide you how to set up an environment for building a Synology Package. Detailed steps includes:

  • Installing Toolkit
  • Understanding Build Environment
  • Putting our application inside toolkit directories
  • Compiling/Building application
  • Packaging application
  • Package Installation

All instructions are verified on Ubuntu system.
Make sure that you perform all operations as root. I would suggest to switch to root account as soon as you start working in toolkit. Use below command to switch to root user.

root@ubuntu1604:sudo bash

Install Toolkit

First step which you need to perform is to download the toolkit from Synology official github store. Below are the instructions.

root@ubuntu1604:mkdir -p /toolkit
root@ubuntu1604:cd /toolkit
root@ubuntu1604:git clone https://github.com/SynologyOpenSource/pkgscripts-ng.git
root@ubuntu1604:toolkit1# tree -L 1
├── build_env
├── pkgscripts-ng
└──  source

Sometime it happens that the toolkit which you downloaded becomes outdated. Make sure if you face any error, you pull latest content into your toolkit.

root@ubuntu1604:cd pkgscripts-ng
root@ubuntu1604:git pull origin master

Understanding Build Environment

Synology supports several platforms like (arm, x64 etc) on which your package can run. While creating a package it requires to mention on which platform this package will be installed and run.

To list all supported platforms/environments for synology apps.

root@neeraj-ubuntu1604:toolkit# ./pkgscripts-ng/EnvDeploy -v 6.0 --list
======== Available Platforms ========
6.0: 6281 alpine alpine4k armada370 armada375 armada38x armadaxp avoton braswell bromolow cedarview comcerto2k evansport monaco qoriq x64

For example, if you want to create environment for armada38x

root@ubuntu1604:toolkit# ./pkgscripts-ng/EnvDeploy -v 6.0 -p armada38x

To update armada38x Environment

root@ubuntu1604:toolkit#./pkgscripts-ng/EnvDeploy -v 6.0 -p armada38x

To remove environment

 root@ubuntu1604:toolkit#chroot /toolkit/build_env/ds. armada38x -6.0 umount /proc
 root@ubuntu1604:toolkit#rm -rf /toolkit/build_env/ds. armada38x -6.0

Now as you are good with managing environment. The next step is to put your source code/binary inside Synology toolkit.

Putting application inside toolkit

Since mostly developers prefer compilation outside of this toolkit because of obvious reasons like existing source already depended on some other build system. I am assuming that we have our binaries ready with us.
Now you need to do the following things

root@ubuntu1604:toolkit# pkgscripts/PkgCreate.py -x0 -c ${project}

Put your application root folder inside source directory of toolkit. Your app root folder should contains following files and folders.

root@neeraj-ubuntu1604:source/project# tree -L 1
 ├── bin
 ├── conf
 ├── INFO.describe
 ├── INFO.sh
 ├── LICENSE
 ├── Makefile
 ├── PACKAGE_ICON_256.PNG
 ├── PACKAGE_ICON.PNG
 ├── README.md
 ├── scripts|
 ├── SynoBuildConf
 └── ui

Bin
This is the directory where all the executables/shared libs will be kept.

Conf
This directory will contain configuration related to upstart. Synology devices supports upstart scripts for the start/stop of your application services/daemon.This is the folder where you will write your upstart scripts.

INFO* files
This is the file which contains information about your application. Below are the minimum information to provide

package="MyApp"
version="1.0.0000"
displayname="Product name to be displayed in package store"
maintainer="developer name"
arch="$(pkg_get_unified_platform)"
description="some desc"|
dsmappname="SYNO.SDS.MyApp"
dsmuidir="ui"
report_url=”some url"
thirdparty="yes"
firmware="6.0"
[ "$(caller)" != "0 NULL" ] && return 0
pkg_dump_info

ICONS files
Your package icon files should be 256×256 and 72×72 size with names PACKAGE_ICON_256.PNG and PACKAGE_ICON.PNG respectively.

Scripts
Contains following shell script files.

 root@neeraj-ubuntu1604:scripts# tree
 ├── postinst
 ├── postuninst
 ├── postupgrade
 ├── preinst
 ├── preuninst
 ├── preupgrade
 └── start-stop-status

Please refer below link for detailed information on these files.
https://developer.synology.com/developer-guide/synology_package/scripts.html#

SynoBuildConf
This describes the configuration settings of app for build process, dependencies check and create package. Please refer below link for detailed info.
https://developer.synology.com/developer-guide/synology_package/conf.html

UI
As name suggest you need to put all your user interface files here.

Building  Application

Build happened externally as mentioned before. However if you want to build your project you need to use following command. For eg for armada38x

root@ubuntu1604:toolkit# pkgscripts/PkgCreate.py -i -p armada38x ${project}

Remember project name here it refers to the top level folder. In this case it is myapp.

Packaging Application

Once build is done. You are required to pack your files into a package. Use below command.
Remember before packing you need to create a key which will use to sign the package automatically.
The Package Center has a built-in code sign mechanism to ensure the package’s publisher integrity.

Generate the GPG key

gpg --gen-key
cp ~/.gnupg/* /toolkit/build_env/ds.${platform}-6.0/root/.gnupg/

Now create the package. It will be signed automatically.

 root@ubuntu1604:toolkit#pkgscripts/PkgCreate.py -i  -U -p armada38x ${project}

Once you are done you can see your package created in following location.

root@ubuntu1604:toolkit#ls build_env/ds.armada38x-6.0/image/packages

Manual Install of Application

In real scenarios you need to contact Synology and publish your app in their store. However in the mean time you can manually install your app locally in your device and test it.

Please refer the official instructions from Synology.
https://www.synology.com/en-us/knowledgebase/DSM/tutorial/Application/How_to_install_applications_with_Package_Center

That is all. Hope this information will help you in creating packages for Synology Store.

Advertisements

One thought on “Creating Synology NAS Store Packages

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s