支持一键打包spk
81
README.md
|
@ -1,2 +1,79 @@
|
||||||
# frpc_spk_build
|
# frpc_spk_build 项目说明
|
||||||
build frpc to spk package in synology dsm.
|
- build frpc to spk package in synology dsm.
|
||||||
|
- 将frpc打包成群晖的spk安装包,方便分享与传播.
|
||||||
|
- 集成了frpc版本:0.30.0
|
||||||
|
- 群晖的打包除了官方环境的下载与部署之外,本身项目的spk构造也是很烦琐的一下事情,在本项目中我已将所有的构造文件写好,并push到了本项目中,可以直接一键打包.
|
||||||
|
- 同时,希望本项目对大家日后打其他spk包有参考作用
|
||||||
|
- 感谢源项目:https://github.com/fatedier/frp
|
||||||
|
|
||||||
|
# 打包环境构建
|
||||||
|
## 1. clone或者下载本项目
|
||||||
|
```
|
||||||
|
git clone https://github.com/qiusanshiye/frpc_spk_build.git
|
||||||
|
```
|
||||||
|
|
||||||
|
## 2. 下载群晖官方打包工具
|
||||||
|
```
|
||||||
|
cd frpc_spk_build
|
||||||
|
git clone https://github.com/SynologyOpenSource/pkgscripts-ng.git
|
||||||
|
```
|
||||||
|
|
||||||
|
## 3. 部署群晖官方打包环境
|
||||||
|
```
|
||||||
|
cd pkgscripts-ng
|
||||||
|
./EnvDeploy -v 6.0 -p x64
|
||||||
|
# 我这里部署的是群晖的 x64 架构的6.0版本的DSM环境
|
||||||
|
# 注意:这里需要python环境,我这里用的是python2.7。其他版本未测试。
|
||||||
|
```
|
||||||
|
待部署完成后,目录结构会是这样:
|
||||||
|
```
|
||||||
|
# tree -L 1
|
||||||
|
.
|
||||||
|
├── build_env # 新增的目录,群晖的chroot打包签名环境
|
||||||
|
├── gofrpc_build.sh
|
||||||
|
├── LICENSE
|
||||||
|
├── pkgscripts-ng # 第2步中下载的打包工具
|
||||||
|
├── README.md
|
||||||
|
├── result_spk # 这个建议先手动创建,在打包之后会输出到这个目录
|
||||||
|
├── source # 项目文件构造
|
||||||
|
└── toolkit_tarballs # 新增的目录,群晖的打包环境镜像
|
||||||
|
```
|
||||||
|
|
||||||
|
## 4. 生成spk签名证书
|
||||||
|
```
|
||||||
|
gpg --gen-key
|
||||||
|
cp -rf ~/.gnupg ./build_env/ds.x64-6.0/root/
|
||||||
|
```
|
||||||
|
|
||||||
|
## 5. 开始一键打包
|
||||||
|
- 先更新frpc最新版本
|
||||||
|
> 在这里下载最新的frp包,解压后拷贝frpc到 ./source/gofrpc/bin/arch/目录下
|
||||||
|
> 当前我已集成了frpc的0.30.0版本的程序
|
||||||
|
|
||||||
|
- 再更新想要打包的spk的版本号
|
||||||
|
```
|
||||||
|
vim source/gofrpc/INFO.sh
|
||||||
|
# 修改字段 version="1.0.1"
|
||||||
|
```
|
||||||
|
|
||||||
|
- 开始一键打包
|
||||||
|
```
|
||||||
|
./gofrpc_build.sh
|
||||||
|
# 没有出错的情况下会看到以下日志输出:
|
||||||
|
# [SUCCESS] PkgCreate.py -v 6.0 -p x64 -c gofrpc finished.
|
||||||
|
# 最终输出的spk路径:./build_env/ds.x64-6.0/image/packages/gofrpc-1.0.1.spk
|
||||||
|
# 也可以在这里找到: ./result_spk/gofrpc-1.0.1/
|
||||||
|
# 接下就可以上群晖套件中心手动安装试试啦
|
||||||
|
```
|
||||||
|
|
||||||
|
## 6. 环境部署与打包过程中可能会遇到的问题
|
||||||
|
- 提示没有权限
|
||||||
|
> 非root用户执行上述各步时,请使用 sudo 执行
|
||||||
|
|
||||||
|
- 群晖镜像无法下载或者太慢
|
||||||
|
> 建议屏蔽工具中的下载逻辑:打开 pkgscripts-ng/EnvDeploy, 注释:urllib.request.urlretrieve(url, dest, reporthook=reporthook) 这一行(大概在86行)
|
||||||
|
> 在上述的第3步中执行EnvDeploy命令时,会输出下载链接,我们可以把用迅雷下载,完后拷贝到 toolkit_tarballs 目录。
|
||||||
|
> 再次执行3步EnvDeploy命令即可.
|
||||||
|
|
||||||
|
- 其他问题
|
||||||
|
> 请移步[这里](http://blog.5941188.com/archives/%E7%BE%A4%E6%99%96%E5%A5%97%E4%BB%B6%E6%89%93%E5%8C%85)
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
[ $# -lt 1 ] && {
|
||||||
|
echo "usage: $0 arch";
|
||||||
|
echo -e "\tsupport list: monaco rtd1296 x64";
|
||||||
|
#exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCRIPTPATH="${0%/*}"
|
||||||
|
cd ${SCRIPTPATH}
|
||||||
|
CURPATH="$(pwd)"
|
||||||
|
|
||||||
|
APPNAME="gofrpc"
|
||||||
|
|
||||||
|
PLATVER="6.0"
|
||||||
|
PLATFORM="${1:-x64}"
|
||||||
|
|
||||||
|
### 实际编译环境 工程目录
|
||||||
|
APPBUILDPATH="${CURPATH}/build_env/ds.${PLATFORM}-${PLATVER}/source"
|
||||||
|
[ -d "${APPBUILDPATH}" ] || { echo "invalid arch:${PLATFORM}"; exit 2; }
|
||||||
|
REALBUILDPATH="${APPBUILDPATH}/${APPNAME}"
|
||||||
|
mkdir -p ${REALBUILDPATH} 2>/dev/null
|
||||||
|
|
||||||
|
### 可见编译环境 工程目录
|
||||||
|
APPSRCPATH="${CURPATH}/source"
|
||||||
|
PROJTEMPLATE="${APPNAME}"
|
||||||
|
|
||||||
|
### 编译脚本
|
||||||
|
BUILDTOOLPATH="${CURPATH}/pkgscripts-ng"
|
||||||
|
|
||||||
|
### 编译输出
|
||||||
|
BUILDOUTPATH="${CURPATH}/build_env/ds.${PLATFORM}-${PLATVER}/image/packages"
|
||||||
|
|
||||||
|
## 工程拷贝
|
||||||
|
rm -rf ${REALBUILDPATH}/*
|
||||||
|
#cp -rf ${APPSRCPATH}/gofrpc_bin/${PLATFORM}/frpc ${APPSRCPATH}/${PROJTEMPLATE}/bin/
|
||||||
|
#cp -rf ${APPSRCPATH}/gofrpc_bin/${PLATFORM}/frpc.ini ${APPSRCPATH}/${PROJTEMPLATE}/bin/
|
||||||
|
|
||||||
|
## build
|
||||||
|
rm -rf ${BUILDOUTPATH}/${APPNAME}*.spk
|
||||||
|
cd ${BUILDTOOLPATH}
|
||||||
|
python3 PkgCreate.py -v ${PLATVER} -p ${PLATFORM} -c ${APPNAME} #--print-log
|
||||||
|
|
||||||
|
# list
|
||||||
|
ls -lhrt ${BUILDOUTPATH}/
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Copyright (c) 2000-2016 Synology Inc. All rights reserved.
|
||||||
|
|
||||||
|
source /pkgscripts-ng/include/pkg_util.sh
|
||||||
|
|
||||||
|
package="gofrpc"
|
||||||
|
version="1.0.1"
|
||||||
|
displayname="gofrpc"
|
||||||
|
dsmuidir="ui"
|
||||||
|
dsmappname="SYNO.SDS.gofrpc"
|
||||||
|
distributor="jie800@163.com"
|
||||||
|
maintainer="秋三十爷"
|
||||||
|
maintainer_url="http://blog.5941188.com"
|
||||||
|
helpurl="https://github.com/fatedier/frp"
|
||||||
|
arch="noarch"
|
||||||
|
#arch="$(pkg_get_unified_platform)"
|
||||||
|
firmware="6.0-5914"
|
||||||
|
os_min_ver="6.0-5914"
|
||||||
|
support_conf_folder="yes"
|
||||||
|
description="内网穿透神器--frpc,个人整合为spk包,自适应arm,arm64,x86,x64四个平台,支持网页配置,及提供了一些配置模板,供大家食用。当前frpc版本:0.30.0"
|
||||||
|
#silent_install="yes"
|
||||||
|
silent_upgrade="yes"
|
||||||
|
silent_uninstall="yes"
|
||||||
|
thirdparty="yes"
|
||||||
|
adminprotocol="http"
|
||||||
|
adminurl="static/#"
|
||||||
|
adminport="8760"
|
||||||
|
[ "$(caller)" != "0 NULL" ] && return 0
|
||||||
|
pkg_dump_info
|
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 96 KiB |
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "skip owapp make"
|
|
@ -0,0 +1,60 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Copyright (C) 2000-2016 Synology Inc. All rights reserved.
|
||||||
|
|
||||||
|
### Use PKG_DIR as working directory.
|
||||||
|
pkgname="gofrpc"
|
||||||
|
PKG_DIR="/tmp/_${pkgname}_spk"
|
||||||
|
rm -rf $PKG_DIR
|
||||||
|
mkdir -p $PKG_DIR
|
||||||
|
|
||||||
|
### get spk packing functions
|
||||||
|
source /pkgscripts-ng/include/pkg_util.sh
|
||||||
|
|
||||||
|
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"
|
||||||
|
echo "==> create_inner_tarball.curpath: $(pwd)"
|
||||||
|
#cp -rf ${pkgname} ${inner_tarball_dir} || { echo "cp -rf ${pkgname} ${inner_tarball_dir} failed"; exit 1; }
|
||||||
|
cp -rf ./bin ${inner_tarball_dir}/
|
||||||
|
cp -rf ./ui ${inner_tarball_dir}/
|
||||||
|
cp -rf ./start.sh ${inner_tarball_dir}/
|
||||||
|
cp -rf ./stop.sh ${inner_tarball_dir}/
|
||||||
|
cp -rf ./config ${inner_tarball_dir}/ui/
|
||||||
|
|
||||||
|
### create package.txz: $1=source_dir, $2=dest_dir
|
||||||
|
pkg_make_inner_tarball $inner_tarball_dir "${PKG_DIR}" || echo "pkg_make_inner_tarball $inner_tarball_dir ${PKG_DIR}"
|
||||||
|
}
|
||||||
|
|
||||||
|
create_spk(){
|
||||||
|
local scripts_dir=$PKG_DIR/scripts
|
||||||
|
local conf_dir=$PKG_DIR/conf
|
||||||
|
|
||||||
|
### Copy Package Center scripts to PKG_DIR
|
||||||
|
mkdir -p $scripts_dir || echo "mkdir -p \$scripts_dir failed"
|
||||||
|
mkdir -p $conf_dir || echo "mkdir -p \$conf_dir failed"
|
||||||
|
cp -av scripts/* $scripts_dir || echo "cp -av scripts/* \$scripts_dir failed"
|
||||||
|
cp -av conf/* $conf_dir || echo "cp -av conf/* \$conf_dir failed"
|
||||||
|
|
||||||
|
### Copy package icon
|
||||||
|
echo "==> create_spk.curpath: $(pwd)"
|
||||||
|
cp -av PACKAGE_ICON*.PNG $PKG_DIR || echo " cp -av PACKAGE_ICON*.PNG \$PKG_DIR failed"
|
||||||
|
|
||||||
|
### Generate INFO file
|
||||||
|
./INFO.sh > INFO || echo "export info failed."
|
||||||
|
cp INFO $PKG_DIR/INFO || echo "cp INFO \$PKG_DIR/INFO failed"
|
||||||
|
|
||||||
|
### 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 || echo "mkdir -p /image/packages failed."
|
||||||
|
pkg_make_spk ${PKG_DIR} "/image/packages" $(pkg_get_spk_family_name) || echo "pkg_make_spk \${PKG_DIR} failed"
|
||||||
|
}
|
||||||
|
|
||||||
|
create_inner_tarball
|
||||||
|
create_spk
|
|
@ -0,0 +1,24 @@
|
||||||
|
[common]
|
||||||
|
admin_addr = 0.0.0.0
|
||||||
|
admin_port = 8760
|
||||||
|
server_addr = 47.111.117.185
|
||||||
|
server_port = 2680
|
||||||
|
token = 64590757cf05
|
||||||
|
|
||||||
|
#[template_ssh]
|
||||||
|
#type = tcp
|
||||||
|
#local_ip = 127.0.0.1
|
||||||
|
#local_port = 22
|
||||||
|
#remote_port = 50341
|
||||||
|
#
|
||||||
|
#[template_web]
|
||||||
|
#type = http
|
||||||
|
#local_ip = 127.0.0.1
|
||||||
|
#local_port = 5000
|
||||||
|
#custom_domains = template.nas.config
|
||||||
|
#
|
||||||
|
#[template_frpc_web]
|
||||||
|
#type = http
|
||||||
|
#local_ip = 127.0.0.1
|
||||||
|
#local_port = 8760
|
||||||
|
#custom_domains = template.self.web.config
|
|
@ -0,0 +1,47 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPTPATH="${0%/*}"
|
||||||
|
cd "${SCRIPTPATH}/.."
|
||||||
|
APPPATH="$(pwd)"
|
||||||
|
APPNAME="frpc"
|
||||||
|
ARCHBINPATH="${APPPATH}/bin/arch"
|
||||||
|
BINPATH="${APPPATH}/bin/${APPNAME}"
|
||||||
|
|
||||||
|
_arch_select() {
|
||||||
|
${BINPATH} -v && return 0
|
||||||
|
ls -1 ${ARCHBINPATH}/ | while read archbin
|
||||||
|
do
|
||||||
|
${ARCHBINPATH}/${archbin} -v && {
|
||||||
|
ln -sf ${ARCHBINPATH}/${archbin} ${BINPATH}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
done
|
||||||
|
[ -f ${BINPATHA} ] || return 2
|
||||||
|
}
|
||||||
|
|
||||||
|
_start() {
|
||||||
|
CONFPATH="${APPPATH}/bin/frpc.ini"
|
||||||
|
"${BINPATH}" -c "${CONFPATH}" >/dev/null &
|
||||||
|
}
|
||||||
|
|
||||||
|
_stop() {
|
||||||
|
kill -9 "$(pidof ${APPNAME})"
|
||||||
|
kill -11 "$(pidof ${APPNAME})"
|
||||||
|
}
|
||||||
|
|
||||||
|
_monitor() {
|
||||||
|
pidof "${APPNAME}" 2>/dev/null
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
_stop
|
||||||
|
_start
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
## main start
|
||||||
|
inter=5
|
||||||
|
_arch_select || exit 2
|
||||||
|
while [ 1 -eq 1 ]
|
||||||
|
do
|
||||||
|
_monitor
|
||||||
|
sleep "${inter}"
|
||||||
|
done
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"defaults":{
|
||||||
|
"run-as": "package"
|
||||||
|
},
|
||||||
|
"username": "ufrpc",
|
||||||
|
"ctrl-script": [{
|
||||||
|
"action": "stop",
|
||||||
|
"run-as": "package"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
{}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
".url": {
|
||||||
|
"SYNO.SDS.gofrpc": {
|
||||||
|
"type": "url",
|
||||||
|
"allUsers": true,
|
||||||
|
"title": "frpc-群晖内网穿透",
|
||||||
|
"desc": "内网穿透神器,开源frpc,个人整合为spk包,供大家使用。",
|
||||||
|
"icon": "images/icon_{0}.png",
|
||||||
|
"protocol": "http",
|
||||||
|
"url": "/static/#",
|
||||||
|
"port": "8760"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This script is run after the package files are transferred to @appstore.
|
||||||
|
# You can change the file permission and ownership in this script.
|
||||||
|
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This script is run after the package is removed from the system
|
||||||
|
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Package Center will call this script after installing the new version of your package.
|
||||||
|
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This script is run before the package files are transferred to @appstore.
|
||||||
|
# You can check if the installation requirements meet the DSM or package version, or if some services are enabled in this script.
|
||||||
|
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This script is run before the package is removed.
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Package Center will call this script before uninstalling the old version of your package
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This script is used to start and stop a package, detect running status, and generate the log file.
|
||||||
|
# Parameters used by the script are listed in below: start, stop, status
|
||||||
|
|
||||||
|
PRIVATE_LOCATION="/var/packages/${SYNOPKG_PKGNAME}/target"
|
||||||
|
START_FILE="./start.sh"
|
||||||
|
STOP_FILE="./stop.sh"
|
||||||
|
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
start)
|
||||||
|
cd ${PRIVATE_LOCATION}
|
||||||
|
/bin/sh ${START_FILE}
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
cd ${PRIVATE_LOCATION}
|
||||||
|
(/bin/sh ${STOP_FILE} &)
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
cd ${PRIVATE_LOCATION}
|
||||||
|
ret=$(ps -ef | grep frpc | grep -v 'grep')
|
||||||
|
if [ -n "${ret}" ]; then
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPTPATH="${0%/*}"
|
||||||
|
cd ${SCRIPTPATH}
|
||||||
|
APPPATH="$(pwd)"
|
||||||
|
APPNAME="frpc_" # char:_ should be set
|
||||||
|
MONINAME="frpc_monitor"
|
||||||
|
|
||||||
|
_start() {
|
||||||
|
owpid="$(ps -ef | grep ${APPNAME} | grep -v 'grep' | awk '{print $2}')"
|
||||||
|
if [ -z "${owpid}" ]; then
|
||||||
|
MONIPATH="${APPPATH}/bin/${MONINAME}"
|
||||||
|
/bin/sh ${MONIPATH} > /dev/null 2>&1 &
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_start
|
||||||
|
exit 0
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPTPATH="${0%/*}"
|
||||||
|
cd ${SCRIPTPATH}
|
||||||
|
APPPATH="$(pwd)"
|
||||||
|
APPNAME="frpc"
|
||||||
|
|
||||||
|
_stop() {
|
||||||
|
ps -ef | grep ${APPNAME}| grep -v 'stop' | grep -v 'grep' | awk '{print $2}' | xargs kill -9
|
||||||
|
}
|
||||||
|
|
||||||
|
_stop
|
||||||
|
_stop
|
||||||
|
exit 0
|
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 834 B |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 96 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 7.2 KiB |
After Width: | Height: | Size: 8.9 KiB |