filebrowser: call native compiler to pack binary
This commit is contained in:
parent
4a97f83839
commit
ef4ee640e9
@ -1,78 +1,97 @@
|
||||
#
|
||||
# Copyright (C) 2014-2018 OpenWrt-dist
|
||||
# Copyright (C) 2019 [CTCGFW] Project OpenWRT
|
||||
#
|
||||
# Copyright (C) 2020 Project OpenWrt
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
# See /LICENSE.txt for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=filebrowser
|
||||
PKG_VERSION:=snapshot
|
||||
PKG_RELEASE:=6ce44f7
|
||||
PKG_VERSION:=2.6.2
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_LICENSE:=GPLv3
|
||||
PKG_MAINTAINER:=[CTCGFW] Project OpenWRT
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=be8683f
|
||||
PKG_SOURCE_URL:=https://github.com/filebrowser/filebrowser
|
||||
PKG_MIRROR_HASH:=dbf4ff9db137d1f596ad687edec097ae1bbf75ef04447256044e960e044e2ee5
|
||||
|
||||
ifeq ($(ARCH),x86_64)
|
||||
PKG_ARCH_filebrowser:=linux_amd64
|
||||
endif
|
||||
ifeq ($(ARCH),i386)
|
||||
PKG_ARCH_filebrowser:=linux_386
|
||||
endif
|
||||
ifeq ($(ARCH),mipsel)
|
||||
PKG_ARCH_filebrowser:=linux_mipsle
|
||||
endif
|
||||
ifeq ($(ARCH),mips)
|
||||
PKG_ARCH_filebrowser:=linux_mips
|
||||
endif
|
||||
ifeq ($(ARCH),arm)
|
||||
ifeq ($(BOARD),kirkwood)
|
||||
PKG_ARCH_filebrowser:=linux_arm5
|
||||
else ifeq ($(BOARD),bcm53xx)
|
||||
PKG_ARCH_filebrowser:=linux_arm5
|
||||
else
|
||||
PKG_ARCH_filebrowser:=linux_arm7
|
||||
endif
|
||||
endif
|
||||
ifeq ($(ARCH),aarch64)
|
||||
PKG_ARCH_filebrowser:=linux_arm64
|
||||
endif
|
||||
PKG_LICENSE:=Apache-2.0
|
||||
PKG_LICENSE_FILES:=LICENSE.txt
|
||||
PKG_MAINTAINER:=CN_SZTL <cnsztl@project-openwrt.eu.org>
|
||||
|
||||
PKG_SOURCE:=filebrowser_$(PKG_ARCH_filebrowser).tar.gz
|
||||
PKG_SOURCE_URL:=https://package.project-openwrt.eu.org/utils/filebrowser/$(PKG_RELEASE)/
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)
|
||||
PKG_HASH:=skip
|
||||
PKG_BUILD_DEPENDS:=golang/host node/host
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_USE_MIPS16:=0
|
||||
|
||||
PKG_CONFIG_DEPENDS:= \
|
||||
CONFIG_FILEBROWSER_COMPRESS_GOPROXY \
|
||||
CONFIG_FILEBROWSER_COMPRESS_UPX
|
||||
|
||||
GO_PKG:=github.com/filebrowser/filebrowser
|
||||
GO_PKG_LDFLAGS:=-s -w
|
||||
GO_PKG_LDFLAGS_X:= \
|
||||
github.com/filebrowser/filebrowser/v2/version.CommitSHA=$(PKG_SOURCE_VERSION) \
|
||||
github.com/filebrowser/filebrowser/v2/version.Version=$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=OpenWrt Support for FileBrowser.
|
||||
DEPENDS:=@(aarch64||arm||i386||mips||mipsel||x86_64)
|
||||
URL:=https://github.com/filebrowser/filebrowser
|
||||
define Package/filebrowser
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Web File Browser which can be used as a middleware or standalone app.
|
||||
URL:=https://github.com/filebrowser/filebrowser
|
||||
DEPENDS:=$(GO_ARCH_DEPENDS)
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
OpenWrt Support for FileBrowser.
|
||||
define Package/filebrowser/description
|
||||
filebrowser provides a file managing interface within a specified directory
|
||||
and it can be used to upload, delete, preview, rename and edit your files.
|
||||
It allows the creation of multiple users and each user can have its own directory.
|
||||
It can be used as a standalone app or as a middleware.
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
tar -xzf $(DL_DIR)/$(PKG_SOURCE) -C $(PKG_BUILD_DIR)
|
||||
define Package/filebrowser/config
|
||||
config FILEBROWSER_COMPRESS_GOPROXY
|
||||
bool "Compiling with GOPROXY proxy"
|
||||
default n
|
||||
|
||||
config FILEBROWSER_COMPRESS_UPX
|
||||
bool "Compress executable files with UPX"
|
||||
default y
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
ifeq ($(CONFIG_FILEBROWSER_COMPRESS_GOPROXY),y)
|
||||
export GO111MODULE=on
|
||||
export GOPROXY=https://goproxy.cn
|
||||
endif
|
||||
|
||||
define Build/Compile
|
||||
chmod 0755 $(PKG_BUILD_DIR)/filebrowser
|
||||
( \
|
||||
cd $(PKG_BUILD_DIR) ; \
|
||||
rm -rf frontend/dist ; \
|
||||
rm -f http/rice-box.go ; \
|
||||
cd $(PKG_BUILD_DIR)/frontend ; \
|
||||
npm ci; \
|
||||
npm run lint ; \
|
||||
npm run build ; \
|
||||
GOOS=$$$$(go env GOOS) GOARCH=$$$$(go env GOARCH) GO111MODULE=off go get -v github.com/GeertJohan/go.rice/rice/... ; \
|
||||
cd $(PKG_BUILD_DIR)/http ; \
|
||||
"$$$$(go env GOPATH)/bin/rice" embed-go ; \
|
||||
$(call GoPackage/Build/Compile) ; \
|
||||
)
|
||||
ifeq ($(CONFIG_FILEBROWSER_COMPRESS_UPX),y)
|
||||
$(STAGING_DIR_HOST)/bin/upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/filebrowser
|
||||
endif
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/filebrowser $(1)/usr/bin/filebrowser
|
||||
define Package/filebrowser/install
|
||||
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
|
||||
$(INSTALL_DIR) $(1)/etc/config/ $(1)/etc/init.d/ $(1)/usr/bin/
|
||||
$(INSTALL_CONF) $(curdir)/files/filebrowser.config $(1)/etc/config/filebrowser
|
||||
$(INSTALL_BIN) $(curdir)/files/filebrowser.init $(1)/etc/init.d/filebrowser
|
||||
$(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/filebrowser $(1)/usr/bin/filebrowser
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
$(eval $(call GoBinPackage,filebrowser))
|
||||
$(eval $(call BuildPackage,filebrowser))
|
||||
65
package/ctcgfw/filebrowser/files/filebrowser.init
Executable file
65
package/ctcgfw/filebrowser/files/filebrowser.init
Executable file
@ -0,0 +1,65 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2019 [CTCGFW] Project OpenWRT
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/procd.sh
|
||||
|
||||
USE_PROCD=1
|
||||
|
||||
START=90
|
||||
STOP=10
|
||||
|
||||
init_conf() {
|
||||
config_load "filebrowser"
|
||||
config_get "addr_type" "config" "addr_type" "lan"
|
||||
config_get "db_dir" "config" "db_dir" "/etc"
|
||||
[ "${db_dir}" == "/" ] || db_dir="${db_dir%*/}"
|
||||
config_get "db_name" "config" "db_name" "filebrowser.db"
|
||||
db_name="$(uci get filebrowser.config.db_name| sed 's#/##g')"
|
||||
config_get "enabled" "config" "enabled" "0"
|
||||
config_get "port" "config" "port" "8989"
|
||||
config_get "root_dir" "config" "root_dir" "/"
|
||||
|
||||
config_load "network"
|
||||
config_get "lan_addr" "lan" "ipaddr" "192.168.1.1"
|
||||
}
|
||||
|
||||
|
||||
start_service() {
|
||||
init_conf
|
||||
[ "${enabled}" == "1" ] || exit 0
|
||||
procd_open_instance filebrowser
|
||||
mkdir -p "${root_dir}"
|
||||
mkdir -p "${db_dir}"
|
||||
|
||||
if [ "${addr_type}" == "local" ];then
|
||||
addr="127.0.0.1"
|
||||
elif [ "${addr_type}" == "lan" ];then
|
||||
addr="$(uci get network.lan.ipaddr)"
|
||||
elif [ "${addr_type}" == "wan" ];then
|
||||
addr="0.0.0.0"
|
||||
fi
|
||||
|
||||
procd_set_param command filebrowser
|
||||
procd_append_param command -a "${addr}"
|
||||
procd_append_param command -d "${db_dir}/${db_name}"
|
||||
procd_append_param command -p "${port}"
|
||||
procd_append_param command -r "${root_dir}"
|
||||
procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
stop_service(){
|
||||
init_conf
|
||||
echo "${db_dir}/${db_name}" > "/lib/upgrade/keep.d/filebrowser"
|
||||
}
|
||||
|
||||
reload_service()
|
||||
{
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "filebrowser"
|
||||
}
|
||||
@ -1,50 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2019 [CTCGFW] Project OpenWRT
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/procd.sh
|
||||
|
||||
USE_PROCD=1
|
||||
|
||||
START=90
|
||||
STOP=10
|
||||
|
||||
addr_type="$(uci get filebrowser.config.addr_type)"
|
||||
db_dir="$(uci get filebrowser.config.db_dir)"
|
||||
[ "${db_dir}" == "/" ] || db_dir="${db_dir%*/}"
|
||||
db_name="$(uci get filebrowser.config.db_name| sed 's#/##g')"
|
||||
enabled="$(uci get filebrowser.config.enabled)"
|
||||
port="$(uci get filebrowser.config.port)"
|
||||
root_dir="$(uci get filebrowser.config.root_dir)"
|
||||
|
||||
if [ "${addr_type}" == "local" ];then
|
||||
addr="127.0.0.1"
|
||||
elif [ "${addr_type}" == "lan" ];then
|
||||
addr="$(uci get network.lan.ipaddr)"
|
||||
elif [ "${addr_type}" == "wan" ];then
|
||||
addr="0.0.0.0"
|
||||
fi
|
||||
|
||||
start_service() {
|
||||
[ "${enabled}" == "1" ] || exit 0
|
||||
procd_open_instance filebrowser
|
||||
mkdir -p "${root_dir}"
|
||||
mkdir -p "${db_dir}"
|
||||
procd_set_param command filebrowser
|
||||
procd_append_param command -a "${addr}"
|
||||
procd_append_param command -d "${db_dir}/${db_name}"
|
||||
procd_append_param command -p "${port}"
|
||||
procd_append_param command -r "${root_dir}"
|
||||
procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
reload_service()
|
||||
{
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "filebrowser"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user