Skip to content

Commit fb8d0ec

Browse files
committed
Add quick start readme
1 parent 0ce639f commit fb8d0ec

File tree

1 file changed

+264
-0
lines changed

1 file changed

+264
-0
lines changed

README.md

Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
# Qnap Package Build Tools
2+
3+
## reference
4+
* [QDK 快速开发指南中文版](https://blog.233so.com/2020/05/qdk-quick-start-guide-zh/)
5+
* [QPKG Development Guidelines - QNAPedia](https://wiki.qnap.com/wiki/QPKG_Development_Guidelines)
6+
* [qnap-dev/QDK: QNAP Development Kit](https://github.com/qnap-dev/QDK)
7+
* [qnap-dev/qdk2: QPKG development tool](https://github.com/qnap-dev/qdk2)
8+
* [qnap-dev/QDK-Guide](https://github.com/qnap-dev/QDK-Guide)
9+
10+
## quick start
11+
```bash
12+
$ qbuild --create-env Hello # 在当前目录创建Hello工程文件夹
13+
$ cd Hello
14+
$ tree # 工程目录结构
15+
├── arm-x09
16+
├── arm-x19
17+
├── arm-x31
18+
├── arm-x41
19+
├── arm_64
20+
├── x86
21+
├── x86_64
22+
├── x86_ce53xx
23+
├── build_sign.csv
24+
├── config
25+
├── icons
26+
├── package_routines
27+
├── qpkg.cfg
28+
└── shared
29+
└── Hello.sh
30+
$ rm -rf x86_ce53xx x86 arm-x09 arm-x19 arm-x31 arm-x41 # 去掉不需要的平台
31+
$ tree
32+
├── arm_64
33+
│ └── hello # arm64平台可执行文件
34+
├── x86_64
35+
│ └── hello # x64平台可执行文件
36+
├── build_sign.csv
37+
├── config
38+
├── icons
39+
│ ├── Hello.gif # 小图标, 64x64
40+
│ ├── Hello_80.gif # 大图标 80x80
41+
│ └── Hello_gray.gif # 灰度图标, 64x64
42+
├── package_routines
43+
├── qpkg.cfg # 配置文件
44+
└── shared
45+
└── Hello.sh # 启动脚本
46+
$ qbuild # 在build文件夹下生成QPKG文件
47+
```
48+
49+
## example
50+
### qpkg.cfg
51+
```bash
52+
# Name of the packaged application.
53+
QPKG_NAME="Hello"
54+
# Name of the display application.
55+
QPKG_DISPLAY_NAME="Hello World"
56+
# Version of the packaged application.
57+
QPKG_VER="1.0.0"
58+
# Author or maintainer of the package
59+
QPKG_AUTHOR="Hello"
60+
# License for the packaged application
61+
QPKG_LICENSE="GNU General Public License v3.0"
62+
# One-line description of the packaged application
63+
QPKG_SUMMARY="A Hello World Example!"
64+
65+
# Preferred number in start/stop sequence.
66+
QPKG_RC_NUM="101"
67+
# Init-script used to control the start and stop of the installed application.
68+
QPKG_SERVICE_PROGRAM="Hello.sh"
69+
QPKG_SERVICE_PIDFILE="/var/run/hello.pid"
70+
# Relative path to web interface
71+
QPKG_WEBUI="/"
72+
# Port number for the web interface.
73+
QPKG_WEB_PORT="9999" # 不加此选项应用程序图标不会在桌面和程序栏显示
74+
```
75+
76+
### Hello.sh
77+
```bash
78+
#!/bin/sh
79+
CONF=/etc/config/qpkg.conf
80+
QPKG_NAME="Hello" # 应用程序名
81+
EXE_NAME="hello" # 可执行文件名
82+
QPKG_ROOT=`/sbin/getcfg $QPKG_NAME Install_Path -f ${CONF}`
83+
APACHE_ROOT=`/sbin/getcfg SHARE_DEF defWeb -d Qweb -f /etc/config/def_share.info`
84+
export QNAP_QPKG=$QPKG_NAME
85+
export QPKG_NAME QPKG_ROOT APACHE_ROOT
86+
87+
export SHELL=/bin/sh
88+
export LC_ALL=en_US.UTF-8
89+
export USER=admin
90+
export LANG=en_US.UTF-8
91+
export LC_CTYPE=en_US.UTF-8
92+
export HOME=$QPKG_ROOT
93+
94+
export PIDF=/var/run/$EXE_NAME.pid
95+
96+
case "$1" in
97+
start)
98+
ENABLED=$(/sbin/getcfg $QPKG_NAME Enable -u -d FALSE -f $CONF)
99+
if [ "$ENABLED" != "TRUE" ]; then
100+
echo "$QPKG_NAME is disabled."
101+
exit 1
102+
fi
103+
104+
/bin/ln -sf $QPKG_ROOT /opt/$QPKG_NAME
105+
/bin/ln -sf $QPKG_ROOT/$EXE_NAME /usr/bin/$EXE_NAME
106+
107+
cd $QPKG_ROOT
108+
$EXE_NAME & # 后台运行对应平台的可执行文件
109+
echo $! > $PIDF
110+
;;
111+
stop)
112+
if [ -e $PIDF ]; then
113+
ID=$(more $PIDF)
114+
kill -9 $ID
115+
rm -f $PIDF
116+
fi
117+
killall -9 $EXE_NAME
118+
rm -rf /opt/$QPKG_NAME
119+
rm -rf /usr/bin/$EXE_NAME
120+
;;
121+
restart)
122+
$0 stop
123+
$0 start
124+
;;
125+
*)
126+
echo "Usage: $0 {start|stop|restart}"
127+
exit 1
128+
;;
129+
esac
130+
131+
exit 0
132+
```
133+
134+
## qbuild usage
135+
```
136+
$ qbuild -h
137+
usage: qbuild [--extract QPKG [DIR]] [--create-env NAME] [-s|--section SECTION]
138+
[--root ROOT_DIR] [--build-arch ARCH] [--build-version VERSION]
139+
[--build-number NUMBER] [--build-model MODEL] [--build-dir BUILD_DIR]
140+
[--force-config] [--setup SCRIPT] [--teardown SCRIPT]
141+
[--pre-build SCRIPT] [--post-build SCRIPT] [--exclude PATTERN]
142+
[--exclude-from FILE] [--gzip|--bzip2|--7zip] [--sign] [--gpg-name ID]
143+
[--verify QPKG] [--add-sign QPKG] [--import-key KEY] [--remove-key ID]
144+
[--list-keys] [--query OPTION QPKG] [-v|--verbose] [-q|--quiet] [--strict]
145+
[--add-code-signing QPKG] [--verify-code-signing QPKG]
146+
[--code-signing-cfg CODE_SIGNING_CFG]
147+
[--allow-no-volume]
148+
[-?|-h|--help] [--usage] [-V|--version]
149+
150+
-s
151+
--section SECTION
152+
Add SECTION to the list of searched sections in the configuration file.
153+
A section is a named set of definitions. By default, the DEFAULT section
154+
will be searched and then any sections specified on the command line.
155+
--root ROOT_DIR
156+
Use files and meta-data in ROOT_DIR when the QPKG is built (default is
157+
the current directory, '.').
158+
--build-version VERSION
159+
Use given version when QPKG is built (also updates the QPKG_VER
160+
definition in qpkg.cfg).
161+
--build-number NUMBER
162+
Use given build number when QPKG is built.
163+
--build-model MODEL
164+
Include check for given model in the QPKG package.
165+
--build-arch ARCH
166+
Build QPKG for specified ARCH (supported values: arm-x09, arm-x19, arm-x31, arm-x41, arm_64, x86, x86_ce53xx,
167+
and x86_64). Only one architecture per option, but you can repeat the
168+
option on the command line to add multiple architectures.
169+
--build-dir BUILD_DIR
170+
Place built QPKG in BUILD_DIR. If a full path is not specified then it
171+
is relative to the ROOT_DIR (default is ROOT_DIR/build).
172+
--setup SCRIPT
173+
Run specified script to setup build environment. Called once before
174+
build process is initiated.
175+
--teardown SCRIPT
176+
Run specified script to cleanup after all builds are finished. Called
177+
once after all builds are completed.
178+
--pre-build SCRIPT
179+
Run specified script before the build process is started. Called before
180+
each and every build. First argument contains the architecture (one of
181+
arm-x09, arm-x19, arm-x31, arm-x41, arm_64, x86, x86_ce53xx, and x86_64) and the second argument contains the
182+
location of the architecture specific code. For the generic build the
183+
arguments are empty.
184+
--post-build SCRIPT
185+
Run specified script after the build process is finished. Called after
186+
each and every build. First argument contains the architecture (one of
187+
arm-x09, arm-x19, arm-x31, arm-x41, arm_64, x86, x86_ce53xx, and x86_64) and the second argument contains the
188+
location of the architecture specific code. For the generic build the
189+
arguments are empty.
190+
--create-env NAME
191+
Create a template build environment in the current directory
192+
for a QPKG named NAME.
193+
--extract QPKG [DIR]
194+
Extract archive of files and meta-data from QPKG to DIR (default is
195+
current directory).
196+
--exclude PATTERN
197+
Do not include files matching PATTERN in data package. This option is
198+
passed on to rsync and follows the same rules as rsync's --exclude
199+
option. Only one exclude pattern per option, but you can repeat the
200+
option on the command line to add multiple patterns.
201+
--exclude-from FILE
202+
Related to --exclude, but specifies a FILE that contains exclude
203+
patterns (one per line). This option is passed on to rsync and follows
204+
the same rules as rsync's --exclude-from option.
205+
--strict
206+
Treat warnings as errors.
207+
--force-config
208+
Ignore missing configuration files specified in QPKG_CONFIG.
209+
--gzip
210+
Compress QPKG content using gzip (this is the default compression when
211+
no compression option is specified.)
212+
--bzip2
213+
Compress QPKG content using bzip2.
214+
--7zip
215+
Compress QPKG content using 7-zip.
216+
--query OPTION QPKG
217+
Retrieve information from QPKG. Available options:
218+
dump dump settings from qpkg.cfg
219+
info summary of settings in qpkg.cfg
220+
config list configuration files
221+
require list required packages
222+
conflict list conflicting packages
223+
funcs output package specific functions
224+
--sign
225+
Generate and insert digital signature to QPKG. By default the first key
226+
in the secret keyring is used.
227+
--gpg-name ID
228+
Use specified user ID to sign QPKG.
229+
--verify QPKG
230+
Verify digital signature assigned to QPKG.
231+
--add-sign QPKG
232+
Generate and insert digital signature to QPKG, replacing any existing
233+
signature.
234+
--import-key KEY
235+
Import ASCII armored key to public keyring.
236+
--list-keys
237+
Show keys in public keyring.
238+
--remove-key ID
239+
Remove key with specified ID from public keyring.
240+
--add-code-signing QPKG
241+
Add code signing digital signature into QPKG. By default configuration file 'qpkg.cfg' is used
242+
--verify-code-signing QPKG
243+
Verify code signing digital signature in the QPKG. By default configuration file 'qpkg.cfg' is used
244+
--code-signing-cfg CODE_SIGNING_CFG
245+
The configuration file for --add-code-signing and --verify-code-signing
246+
--allow-no-volume
247+
Allow qpkg install without volume. The default path is /mnt/HDA_ROOT/update_pkg when the volume can not be found.
248+
-?
249+
-h
250+
--help
251+
Show this help message.
252+
--usage
253+
Display brief usage information.
254+
-q
255+
--quiet
256+
Silent mode. Do not write anything to standard output. Normally only
257+
error messages will be displayed.
258+
-v
259+
--verbose
260+
Verbose mode. Multiple options increase the verbosity. The maximum is 3.
261+
-V
262+
--version
263+
Print a single line containing the version number of QDK.
264+
```

0 commit comments

Comments
 (0)