In this article, we will be understand about how to create packages for QNAP NAS store. These are minimum required steps, which are required for package creation.
Below are the important points, which we need to remember and cover as we move on.
- Generate Environment
- Configure QPKG
- Customize QPKG routines
- Add files to QPKG
- Generate QPKG files
QDK is used to build QPKG files/applications for QNAP Turbo NAS. You will use QDK to develop your own package for QNAP devices.
QDK itself is available in QPK format and to install it you need to go to App center of QNAP and install it in your QNAP device.
Alternatively, you can also download it from below link and then manually install in your device.
If QDK is successfully installed you can find it in below location of your NAS device. First login to your NAS device through SSH and check below location.
Now next step is to create environment for our package. Let us say our package name is MyQPKG.
Now connect to your device using SSH and execute below command.
[~] ln -s /bin/sh /bin/bash [~] cd `getcfg QDK Install_Path -f /etc/config/qpkg.conf` [~] cd /share/CACHEDEV1_DATA/.qpkg/QDK [/share/HDA_DATA/.qpkg/QDK] # qbuild --create-env MyQPKG [/share/HDA_DATA/.qpkg/QDK] # qbuild --create-env MyQPKG
A folder named “MyQPKG” generated
[/share/HDA_DATA/.qpkg/QDK] # ls MyQPKG/ bin/ qdk* scripts/ template/ [/share/HDA_DATA/.qpkg/QDK] # cd MyQPKG/ [/share/HDA_DATA/.qpkg/QDK/MyQPKG] # ls arm-x09/ build/ icons/ qpkg.cfg x86/ arm-x19/ config/ package_routines shared/ x86_64/
Next step is to configure the package details.
Qpkg.cfg is the file where package configuration details are provided.
# Name of the packaged application.
# Version of the packaged application.
# Author or maintainer of the package
Customize QPKG routines
This file package_routines contains methods which will called during the application installation/uninstallation process. The names of function are self explanatory .
Content of file “package_routines”
- pkg_pre_install() : routines before install
- pkg_install() : routines during install
- pkg_post_install() : routines after install
- PKG_PRE_REMOVE : routines before uninstall
- PKG_MAIN_REMOVE : routines during uninstall
- PKG_POST_REMOVE : routines after uninstall
Content of file “shared/MyQPKG.sh”
- Start : routines when starting the QPKG
- Stop : routines when stoping the QPKG
Add files to package
Next step is to put already compiled (in case if you have compiled code) in their respective architecture folder.
Put files in below folders for different purposes:
- shared/: Platform-independent files and folders
- arm-x09/ arm-x19/ arm-x31/ arm-x41(TS-x31+)/ x86/x86_ce53xx/ x86_64/: Platform-dependent files and folders
- icons/: icon files
- config/: config files
[/share/HDA_DATA/.qpkg/QDK/MyQPKG] # ls arm-x09/ build/ icons/ qpkg.cfg x86/ arm-x19/ config/ package_routines shared/ x86_64/
Generate QPKG file
Once all files are kept properly you can generate package. Package will saved in build location.
Use below command to build the QPKG file
The QPKG file will be generated in the build folder
[/share/HDA_DATA/.qpkg/QDK/MyQPKG] # qbuild Creating archive with data files... Creating archive with control files... Creating QPKG package... [/[/share/HDA_DATA/.qpkg/QDK/MyQPKG] # cd build/ [/share/HDA_DATA/.qpkg/QDK/MyQPKG/build] # ls MyQPKG_0.1.qpkg