Skip to content

Commit

Permalink
add kopia (#5845)
Browse files Browse the repository at this point in the history
* add kopia
- this is an initial commit with hardcoded password kopia

* fix package installation

* add download-all target
- additionally download all files when PKG_DIST_ARCH_LIST is defined
- use download-all target for download in github action

* update kopia to v0.15.0
- update kopia to latest release
- configure and install folders for config and cache

* Update to 0.17.0, Added wizard, added TLS, prefer env rather than export
- unset USER as this conflicts with kopia, as it tries to create a repository when USER is set

* Fix blank username/password from wizard and Fix TLS cert generation

* Update protocol to https

---------

Co-authored-by: publicarray <[email protected]>
  • Loading branch information
hgy59 and publicarray authored Jun 16, 2024
1 parent dec856f commit e1dfbea
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .github/actions/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Functions:
# - Download all referenced native and cross source files for packages to build.
# - Download all referenced python wheels needed to build.
# - use download-all target to get all files when package has multiple (arch specific) files.

set -o pipefail

Expand All @@ -17,8 +18,8 @@ else
echo "===> Download packages: ${DOWNLOAD_PACKAGES}"
for download in ${DOWNLOAD_PACKAGES}
do
echo "$ make -c ${download} download"
make -C ${download} download
echo "$ make -c ${download} download-all"
make -C ${download} download-all
done
fi

Expand Down
34 changes: 34 additions & 0 deletions cross/kopia/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
PKG_NAME = kopia
PKG_VERS = 0.17.0
PKG_EXT = tar.gz
PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS)-linux-$(PKG_DIST_ARCH).$(PKG_EXT)
PKG_DIST_SITE = https://github.com/kopia/kopia/releases/download/v$(PKG_VERS)
PKG_DIR = $(PKG_NAME)-$(PKG_VERS)-linux-$(PKG_DIST_ARCH)

UNSUPPORTED_ARCHS = $(PPC_ARCHS) $(ARMv5_ARCHS) $(ARMv7L_ARCHS) $(i686_ARCHS)

HOMEPAGE = https://kopia.io/
COMMENT = Kopia is a fast and secure open-source backup/restore tool that allows you to create encrypted snapshots of your data and save the snapshots to remote or cloud storage of your choice, to network-attached storage or server, or locally on your machine.
LICENSE = Apache 2.0

INSTALL_TARGET = kopia_install

# use digests with multiple files
PKG_DIST_ARCH_LIST = x64 arm arm64

include ../../mk/spksrc.archs.mk
ifeq ($(findstring $(ARCH),$(x64_ARCHS)),$(ARCH))
PKG_DIST_ARCH = x64
else ifeq ($(findstring $(ARCH),$(ARMv7_ARCHS)),$(ARCH))
PKG_DIST_ARCH = arm
else ifeq ($(findstring $(ARCH),$(ARMv8_ARCHS)),$(ARCH))
PKG_DIST_ARCH = arm64
endif

include ../../mk/spksrc.install-resources.mk

.PHONY: kopia_install
kopia_install:
@install -d -m 755 $(STAGING_INSTALL_PREFIX)/bin
@$(RUN) ; cp -f $(PKG_NAME) $(STAGING_INSTALL_PREFIX)/bin/
@chmod +x $(STAGING_INSTALL_PREFIX)/bin/$(PKG_NAME)
1 change: 1 addition & 0 deletions cross/kopia/PLIST
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin:bin/kopia
9 changes: 9 additions & 0 deletions cross/kopia/digests
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
kopia-0.17.0-linux-x64.tar.gz SHA1 5afb387ea490ab17e00db04d48dba0e4b76049d9
kopia-0.17.0-linux-x64.tar.gz SHA256 6851bba9f49c2ca2cabc5bec85a813149a180472d1e338fad42a8285dad047ee
kopia-0.17.0-linux-x64.tar.gz MD5 45f22473e0de02e4fb086698b0cac43d
kopia-0.17.0-linux-arm.tar.gz SHA1 e15363951883134e1f3728bfaa4dff1cd97d76be
kopia-0.17.0-linux-arm.tar.gz SHA256 25804d7271a0dfe6d0821270c5640caa01da5e05a03a7c4783fd1edafb234d51
kopia-0.17.0-linux-arm.tar.gz MD5 1a53555bd2de5ec5b8856fa49fd9acdf
kopia-0.17.0-linux-arm64.tar.gz SHA1 a482d045179f84c85f764fe3532c14ff2248d02a
kopia-0.17.0-linux-arm64.tar.gz SHA256 9679415cd2717a90cb6a793aa2d4accde4059084245b27fa4807d7e13fbe40a0
kopia-0.17.0-linux-arm64.tar.gz MD5 5e6223f90b0374e2a990a729153ae2b4
20 changes: 18 additions & 2 deletions mk/spksrc.download.mk
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
### Download rules
# Download $(URLS) from the wild internet, and place them in $(DISTRIB_DIR).
# Download $(URLS) from the wild internet, and place them in $(DISTRIB_DIR).
# Targets are executed in the following order:
# download_msg_target
# pre_download_target (override with PRE_DOWNLOAD_TARGET)
# download_target (override with DOWNLOAD_TARGET)
# post_download_target (override with POST_DOWNLOAD_TARGET)
# Variables:
# URLS: List of URL to download
# DISTRIB_DIR: Downloaded files will be placed there.
# DISTRIB_DIR: Downloaded files will be placed there.
# Targets:
# download Regular target for file download
# download-all To additionally download all files when PKG_DIST_ARCH_LIST is defined
# This target is for github prepare action to pre download all sources
#

# Configure file descriptor lock timeout
ifeq ($(strip $(FLOCK_TIMEOUT)),)
Expand Down Expand Up @@ -176,3 +181,14 @@ $(DOWNLOAD_COOKIE): $(POST_DOWNLOAD_TARGET)
else
download: ;
endif


ifneq ($(strip $(PKG_DIST_ARCH_LIST)),)
download-all:
@for pkg_arch in $(PKG_DIST_ARCH_LIST); do \
rm -f $(DOWNLOAD_COOKIE) ; \
$(MAKE) -s PKG_DIST_ARCH=$${pkg_arch} download ; \
done ;
else
download-all: download
endif
35 changes: 35 additions & 0 deletions spk/kopia/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
SPK_NAME = kopia
SPK_VERS = 0.17.0
SPK_REV = 1
SPK_ICON = src/kopia.png

DEPENDS = cross/kopia

UNSUPPORTED_ARCHS = $(PPC_ARCHS) $(ARMv5_ARCHS) $(ARMv7L_ARCHS) $(i686_ARCHS)

MAINTAINER = SynoCommunity
DISPLAY_NAME = Kopia
DESCRIPTION = Kopia is a fast and secure open-source backup/restore tool that allows you to create encrypted snapshots of your data and save the snapshots to remote or cloud storage of your choice, to network-attached storage or server, or locally on your machine.
HOMEPAGE = https://kopia.io/
LICENSE = Apache 2.0
CHANGELOG = "Initial package release"

STARTABLE = yes
SERVICE_USER = auto
SERVICE_SETUP = src/service-setup.sh
SERVICE_PORT = 51515
SERVICE_PORT_PROTOCOL = https
ADMIN_PORT = $(SERVICE_PORT)
ADMIN_PROTOCOL = https
WIZARDS_DIR = src/wizard/

POST_STRIP_TARGET = kopia_extra_install

SPK_COMMANDS = bin/kopia

include ../../mk/spksrc.spk.mk

.PHONY: kopia_extra_install
kopia_extra_install:
@$(MSG) Create config folders under var
@install -d $(STAGING_DIR)/var/config $(STAGING_DIR)/var/cache
Binary file added spk/kopia/src/kopia.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions spk/kopia/src/service-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export XDG_CACHE_HOME=${SYNOPKG_PKGVAR}/cache
export KOPIA_LOG_DIR=${SYNOPKG_PKGVAR}
export KOPIA_CACHE_DIR=${SYNOPKG_PKGVAR}
export KOPIA_CONFIG_PATH=${SYNOPKG_PKGVAR}/config/config.json
TLS_CONFIG="--tls-cert-file ${SYNOPKG_PKGVAR}/default.crt --tls-key-file ${SYNOPKG_PKGVAR}/default.key"
KOPIA=${SYNOPKG_PKGDEST}/bin/kopia
SERVICE_COMMAND="${KOPIA} server start --ui ${TLS_CONFIG} --address=0.0.0.0:${SERVICE_PORT} --grpc --control-api --enable-actions"
SVC_BACKGROUND=yes
SVC_WRITE_PID=yes

service_prestart () {
wizard_password=$(cat "${SYNOPKG_PKGVAR}/pwd")
wizard_username=$(cat "${SYNOPKG_PKGVAR}/usr")

if [ ! -f "${SYNOPKG_PKGVAR}/default.crt" ];then
SERVICE_COMMAND+=" --tls-generate-cert"
fi
SERVICE_COMMAND+=" --server-username=${wizard_username} --server-password=${wizard_password}"
}

service_postinst () {
if [ ! -f "${SYNOPKG_PKGVAR}/pwd" ]; then
echo "${wizard_password}" > "${SYNOPKG_PKGVAR}/pwd"
echo "${wizard_username}" > "${SYNOPKG_PKGVAR}/usr"
fi
}
35 changes: 35 additions & 0 deletions spk/kopia/src/wizard/install_uifile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[
{
"step_title": "Kopia Configuration",
"invalid_next_disabled": true,
"items": [
{
"desc": "Permissions for the package are managed by a \"System internal user\" named <b>sc-kopia</b>.Please read <a target=\"_blank\" href=\"https://github.com/SynoCommunity/spksrc/wiki/Permission-Management\">Permission Management</a> for details."
},
{
"type": "textfield",
"desc": "Kopia Settings",
"subitems": [
{
"key": "wizard_username",
"desc": "Web Username",
"defaultValue": "kopia",
"validator": {
"allowBlank": false,
"minLength": 1
}
},
{
"key": "wizard_password",
"desc": "Web Password",
"defaultValue": "kopiakopia",
"validator": {
"allowBlank": false,
"minLength": 8
}
}
]
}
]
}
]

0 comments on commit e1dfbea

Please sign in to comment.