QNAP雖然關往提供開發文件,但說實在的,寫得不怎麼好,完全設定開發者是高手,以這樣的角度做文件。
|
QDK-related directories and files |
bin/qbuild: build the qpkg for you App
[~] # cd /share/MD0_DATA/.qpkg/QDK/[/share/MD0_DATA/.qpkg/QDK] # lsbin/ qdk* scripts/ template/[/share/MD0_DATA/.qpkg/QDK] # ls binqbuild*[/share/MD0_DATA/.qpkg/QDK] #
scripts/qinstall.sh: qinstall.sh包含一般安裝QPKG所需scripts functions,是大多數QPKG共同需要的功能。不要更改到此檔案!需要時copy and modify!倒是可以瞭解qinstall.sh source code,會有幫助的。
[/share/MD0_DATA/.qpkg/QDK] # cd scripts/ [/share/MD0_DATA/.qpkg/QDK/scripts] # lsqinstall.sh*[/share/MD0_DATA/.qpkg/QDK/scripts] # cat qinstall.sh #!/bin/sh############################################################################## $Id: qinstall.sh 358 2011-07-17 08:52:39Z micke $## A QPKG installation script for QDK## Copyright (C) 2009,2010 QNAP Systems, Inc.# Copyright (C) 2010,2011 Michael Nordstrom## This program is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License# as published by the Free Software Foundation; either version 2# of the License, or (at your option) any later version.
template目錄包含各種平台 (ARM, x86, x86_64) build QPKG所需的特殊 (package specific) 環境設定。
template/shared/init.sh
[/share/MD0_DATA/.qpkg/QDK] # cd template
[/share/MD0_DATA/.qpkg/QDK/template] # lsarm-x09/ icons/ shared/arm-x19/ package_routines x86/config/ qpkg.cfg x86_64/[/share/MD0_DATA/.qpkg/QDK/template] #
還有隱藏檔:.uninstall.sh, .qpkg_icon*.gif
[/share/MD0_DATA/.qpkg/QDK] # ls -ladrwxr-xr-x 5 admin administ 4096 Mar 3 17:16 ./drwxrwxrwx 19 admin administ 4096 Mar 3 21:34 ../-rw-r--r-- 1 admin administ 338 Mar 3 17:16 .list-rw-r--r-- 1 admin administ 1752 Dec 11 2010 .qpkg_icon.gif-rw-r--r-- 1 admin administ 2011 Dec 12 2010 .qpkg_icon_80.gif-rw-r--r-- 1 admin administ 1953 Dec 12 2010 .qpkg_icon_gray.gif-rwxr-xr-x 1 admin administ 774 Mar 3 17:16 .uninstall.sh*drwxr-xr-x 2 admin administ 4096 Jul 17 2011 bin/-rwxr-xr-x 1 admin administ 559 Mar 12 2011 qdk*drwxr-xr-x 2 admin administ 4096 Jul 17 2011 scripts/drwxr-xr-x 9 admin administ 4096 Jul 17 2011 template/[/share/MD0_DATA/.qpkg/QDK] #
這樣應該大致清楚「要包裝App成為QPKG,需要哪些資訊內容?」
接下來就要開始打包第一個QNAP App,要注意App可能是platform dependent。例如:包PHP web programs就是platform independent,因為QNAP都可以裝PHP (當然要注意版本)。但是若包裝一個Console App,就要注意是ARM, x86, x86_64。就先包一個platform independent App,以QDK本身為例。
- 先確定QDK路徑,以便讓shell可以執行qbuild。
[~] # cd /share/Public # 程式安裝在此[/share/Public] # echo $PATH/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin/X11:/usr/local/sbin:/opt/bin:/opt/sbin[/share/Public] # cat /etc/config/qdk.conf QDK_VERSION=2.0.1QDK_PATH=/share/MD0_DATA/.qpkg/QDK # qbuild所在路徑[/share/Public] # export PATH=$PATH:/share/MD0_DATA/.qpkg/QDK [/share/Public] # echo $PATH /bin:/sbin:/usr/bin:/usr/sbin:/usr/bin/X11:/usr/local/sbin:/opt/bin:/opt/sbin:/share/MD0_DATA/.qpkg/QDK[/share/Public] #
- 再建立一個打包App的包裝環境,命名為QDK。目錄內容包含如前面所提的目錄架構和檔案,以及隱藏檔。
[/share/Public] # lsCOPYING* QDK_2.0.1.qpkg* QDK_2.0.1.zip bash@[/share/Public] # qbuild --create-env QDK[/share/Public] # cd QDK[/share/Public/QDK] # lsarm-x09/ icons/ shared/arm-x19/ package_routines x86/config/ qpkg.cfg x86_64/[/share/Public/QDK] #
[/share/Public/QDK] # rm shared/QDK.sh[/share/Public/QDK] # cp -pr /share/MD0_DATA/.qpkg/QDK/* shared/[/share/Public/QDK] # cp -p /share/MD0_DATA/.qpkg/QDK/.qpkg_icon*.gif shared/[/share/Public/QDK] # ls -la shareddrwxr-xr-x 5 admin administ 4096 Mar 4 16:11 ./drwxr-xr-x 9 admin administ 4096 Mar 4 16:04 ../-rw-r--r-- 1 admin administ 1752 Dec 11 2010 .qpkg_icon.gif-rw-r--r-- 1 admin administ 2011 Dec 12 2010 .qpkg_icon_80.gif-rw-r--r-- 1 admin administ 1953 Dec 12 2010 .qpkg_icon_gray.gifdrwxr-xr-x 2 admin administ 4096 Jul 17 2011 bin/-rwxr-xr-x 1 admin administ 559 Mar 12 2011 qdk*drwxr-xr-x 2 admin administ 4096 Jul 17 2011 scripts/drwxr-xr-x 9 admin administ 4096 Jul 17 2011 template/[/share/Public/QDK] #
[/share/Public/QDK] # vi qpkg.cfg
QPKG_NAME="QDK"# Version of the packaged application.QPKG_VER="2.0.2"# Author or maintainer of the packageQPKG_AUTHOR="YesIAM"# License for the packaged applicationQPKG_LICENSE="GPLv2+"# One-line description of the packaged applicationQPKG_SUMMARY="QDK 2.0.2 from QDK 2.0.1"# Preferred number in start/stop sequence.QPKG_RC_NUM="131"# Init-script used to control the start and stop of the installed application.QPKG_SERVICE_PROGRAM="qdk"# Specifies any packages required for the current package to operate.#QPKG_REQUIRE="Python >= 2.7, Optware | opkg, OPT/openssh"# Specifies what packages cannot be installed if the current package# is to operate properly.#QPKG_CONFLICT="Python, OPT/sed"# Name of configuration file (multiple definitions are allowed).#QPKG_CONFIG="myApp.conf"QPKG_CONFIG="/etc/config/qdk.conf"
- 修改package_routines,加入以下黃色程式碼
[/share/Public/QDK] # vi package_routines
######################################################################CMD_RM="/bin/rm"
CMD_SED="/bin/sed"
CMD_CHMOD="/bin/chmod"
QDK_CONF=/etc/config/qdk.confPKG_MAIN_REMOVE="{ $CMD_RM -f $QDK_CONF}"pkg_init(){ add_qpkg_config $QDK_CONF 0}pkg_install(){ if [ -f "$QDK_CONF" ]; then $CMD_SED -i "s!\(QDK_VERSION=\).*!\1$QPKG_VER!" $QDK_CONF $CMD_SED -i "s!\(QDK_PATH=\).*!\1$SYS_QPKG_DIR!" $QDK_CONF else $CMD_ECHO "QDK_VERSION=$QPKG_VER" > $QDK_CONF $CMD_ECHO "QDK_PATH=$SYS_QPKG_DIR" >> $QDK_CONF fi $CMD_CHMOD 644 $QDK_CONF}###### Command definitions #####
[/share/Public/QDK] # qbuildCreating archive with data files.../etc/config/qdk.conf: no such file; check your QPKG_CONFIG settings[/share/Public/QDK] # [/share/Public/QDK] # qbuild --force-configCreating archive with data files...Creating archive with control files...Creating QPKG package...[/share/Public/QDK] #
[/share/Public/QDK] # cd build/[/share/Public/QDK/build] # lsQDK_2.0.2.qpkg <-- 製作好的QPKG[/share/Public/QDK/build] # chmod 755 QDK_2.0.2.qpkg [/share/Public/QDK/build] # ./QDK_2.0.2.qpkg # 安裝 Install QNAP package on TS-NAS...76+1 records in76+1 records out././md5sum./qpkg.cfg./qinstall.sh./package_routines1+1 records in1+1 records out26+1 records in26+1 records outQDK 2.0.1 is already installed. Setup will now perform package upgrading.Link service start/stop script: qdkSet QPKG information in /etc/config/qpkg.confQDK 2.0.2 has been installed in /share/MD0_DATA/.qpkg/QDK.[/share/Public/QDK/build] #
安裝後,可以比較QDK前後版本和摘要資訊的差異 (版本、作者、但說明顯然和「QPKG_SUMMARY="QDK 2.0.2 from QDK 2.0.1"」無關。
|
原來的QDK 2.0.1 |
|
自製QDK 2.0.2安裝後的資訊 |
下載次數都還是683,我也是過移除重裝,都沒變。看來QNAP Market還蠻謹慎的,下在完全綁機器ID,不像mobile markets,都是綁帳號,容易灌水。
以下時官方文件的內容,我閱讀後所劃重點。
|
注意:不可以有空白 (space鍵) 的參數值 |
|
QPKG_RC_NUM這個參數很怪,由100開始,在qpkg.conf的位置,那開發者當然都寫100 |
|
可以看出:要開發QNAP Apps,最方便還是以Web做IO輸出 |
No comments :
Post a Comment