aboutsummaryrefslogtreecommitdiffstats
path: root/community
diff options
context:
space:
mode:
authorSören Tempel <soeren+git@soeren-tempel.net>2018-10-15 21:04:33 +0200
committerSören Tempel <soeren+git@soeren-tempel.net>2018-10-15 21:04:33 +0200
commit0d8a6942ac6996a4c31ea4180e21f5d5706e929a (patch)
tree72ec31061632792874f29f04943d10a0a10eef71 /community
parent28150adaf85ebb64ea4668c5fa3e5658e46058e7 (diff)
downloadaports-0d8a6942ac6996a4c31ea4180e21f5d5706e929a.tar.bz2
aports-0d8a6942ac6996a4c31ea4180e21f5d5706e929a.tar.xz
community/rest-server: move from testing
Diffstat (limited to 'community')
-rw-r--r--community/rest-server/0001-Move-TestIsUserPath-to-correct-package.patch71
-rw-r--r--community/rest-server/APKBUILD55
-rw-r--r--community/rest-server/rest-server.confd5
-rw-r--r--community/rest-server/rest-server.initd18
-rw-r--r--community/rest-server/rest-server.pre-install7
5 files changed, 156 insertions, 0 deletions
diff --git a/community/rest-server/0001-Move-TestIsUserPath-to-correct-package.patch b/community/rest-server/0001-Move-TestIsUserPath-to-correct-package.patch
new file mode 100644
index 0000000000..5c3932f849
--- /dev/null
+++ b/community/rest-server/0001-Move-TestIsUserPath-to-correct-package.patch
@@ -0,0 +1,71 @@
+From 69ed06aa661590ae74e4e839f71f6861d5fb4243 Mon Sep 17 00:00:00 2001
+From: Alexander Neumann <alexander@bumpern.de>
+Date: Tue, 20 Mar 2018 20:45:59 +0100
+Subject: [PATCH] Move TestIsUserPath to correct package
+
+---
+ cmd/rest-server/main_test.go | 21 ---------------------
+ handlers_test.go | 21 +++++++++++++++++++++
+ 2 files changed, 21 insertions(+), 21 deletions(-)
+
+diff --git a/cmd/rest-server/main_test.go b/cmd/rest-server/main_test.go
+index 44b06a2..b2a71e1 100644
+--- a/cmd/rest-server/main_test.go
++++ b/cmd/rest-server/main_test.go
+@@ -71,24 +71,3 @@ func TestTLSSettings(t *testing.T) {
+ })
+ }
+ }
+-
+-func TestIsUserPath(t *testing.T) {
+- var tests = []struct {
+- username string
+- path string
+- result bool
+- }{
+- {"foo", "/", false},
+- {"foo", "/foo", true},
+- {"foo", "/foo/", true},
+- {"foo", "/foo/bar", true},
+- {"foo", "/foobar", false},
+- }
+-
+- for _, test := range tests {
+- result := isUserPath(test.username, test.path)
+- if result != test.result {
+- t.Errorf("isUserPath(%q, %q) was incorrect, got: %v, want: %v.", test.username, test.path, result, test.result)
+- }
+- }
+-}
+diff --git a/handlers_test.go b/handlers_test.go
+index 6536a26..f6cdbaa 100644
+--- a/handlers_test.go
++++ b/handlers_test.go
+@@ -37,3 +37,24 @@ func TestJoin(t *testing.T) {
+ })
+ }
+ }
++
++func TestIsUserPath(t *testing.T) {
++ var tests = []struct {
++ username string
++ path string
++ result bool
++ }{
++ {"foo", "/", false},
++ {"foo", "/foo", true},
++ {"foo", "/foo/", true},
++ {"foo", "/foo/bar", true},
++ {"foo", "/foobar", false},
++ }
++
++ for _, test := range tests {
++ result := isUserPath(test.username, test.path)
++ if result != test.result {
++ t.Errorf("isUserPath(%q, %q) was incorrect, got: %v, want: %v.", test.username, test.path, result, test.result)
++ }
++ }
++}
+--
+2.18.0
+
diff --git a/community/rest-server/APKBUILD b/community/rest-server/APKBUILD
new file mode 100644
index 0000000000..fce452c001
--- /dev/null
+++ b/community/rest-server/APKBUILD
@@ -0,0 +1,55 @@
+# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
+# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
+pkgname=rest-server
+pkgver=0.9.7
+pkgrel=0
+pkgdesc="A high performance HTTP server that implements restic's REST backend API"
+url="https://github.com/restic/rest-server"
+arch="all"
+license="BSD-2-Clause"
+depends=""
+makedepends="go"
+install="$pkgname.pre-install"
+subpackages="$pkgname-doc $pkgname-openrc"
+source="$pkgname-$pkgver.tar.gz::https://github.com/restic/$pkgname/archive/v$pkgver.tar.gz
+ 0001-Move-TestIsUserPath-to-correct-package.patch
+
+ $pkgname.confd
+ $pkgname.initd"
+builddir="$srcdir/src/github.com/restic/$pkgname"
+
+export GOPATH="$srcdir"
+
+prepare() {
+ mkdir -p "${builddir%/*}"
+ ln -s "$srcdir"/$pkgname-$pkgver "$builddir"
+ default_prepare
+}
+
+build() {
+ cd "$builddir"
+ go build ./cmd/...
+}
+
+check() {
+ cd "$builddir"
+ go test -v . ./cmd/rest-server
+}
+
+package() {
+ cd "$builddir"
+
+ install -Dm755 $pkgname "$pkgdir"/usr/bin/$pkgname
+ install -Dm644 README.md \
+ "$pkgdir"/usr/share/doc/$pkgname/README.md
+
+ install -Dm755 "$srcdir"/$pkgname.initd \
+ "$pkgdir"/etc/init.d/$pkgname
+ install -Dm644 "$srcdir"/$pkgname.confd \
+ "$pkgdir"/etc/conf.d/$pkgname
+}
+
+sha512sums="2288f93703d03859ec1a5d9085eda7ca5b82e801bc74cd66fcc58601e73a2bf5150f85e948749ca7d95e4598087acf5115499404ccbbfba62a4cc9043437ed29 rest-server-0.9.7.tar.gz
+98a9fbb7c0b60dbb3682bab40f7b4f488da93d7c7afdab174185bc62ad250bf8e1238b6513a239dd5da276935b51bd05495f13c7e03befa3a0f651cf3d109979 0001-Move-TestIsUserPath-to-correct-package.patch
+cd9e4d3df04c26aa602a57196bdfb14d7ad6e957f1d9596a09e596b9d01543eee08474817ba47192659fe6f5ab15b8fa64400fb6a8d24111f5c792b1412f5e5b rest-server.confd
+185c0022d07c66fcee2d84af1bb0a11ac0753bd79deb8f5ae7dc2bd84909886aa3e58f42cd6ace4f191da6128d0385036948d4a8accd14cf9cdb9603001b9aca rest-server.initd"
diff --git a/community/rest-server/rest-server.confd b/community/rest-server/rest-server.confd
new file mode 100644
index 0000000000..20e9a4552c
--- /dev/null
+++ b/community/rest-server/rest-server.confd
@@ -0,0 +1,5 @@
+# Storage directory used by the rest-server.
+REST_SERVER_PATH="/var/lib/restic"
+
+# Additional commandline flags passed to rest-server.
+#REST_SERVER_OPTS=""
diff --git a/community/rest-server/rest-server.initd b/community/rest-server/rest-server.initd
new file mode 100644
index 0000000000..25745876e3
--- /dev/null
+++ b/community/rest-server/rest-server.initd
@@ -0,0 +1,18 @@
+#!/sbin/openrc-run
+
+name="rest-server"
+command="/usr/bin/$name"
+command_args="$REST_SERVER_OPTS --path '${REST_SERVER_PATH}'"
+command_background="yes"
+command_user="${REST_USER:-restic}"
+pidfile="/var/run/$RC_SVCNAME.pid"
+
+depend() {
+ need net
+ after firewall
+}
+
+start_pre() {
+ checkpath --directory "${REST_SERVER_PATH}" \
+ --owner "${REST_USER:-restic}:${REST_GROUP:-restic}"
+}
diff --git a/community/rest-server/rest-server.pre-install b/community/rest-server/rest-server.pre-install
new file mode 100644
index 0000000000..0c7845dc50
--- /dev/null
+++ b/community/rest-server/rest-server.pre-install
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+addgroup -S restic 2>/dev/null
+adduser -S -D -H -h /dev/null -s /sbin/nologin \
+ -G restic -g 'Rest Server Daemon' restic 2>/dev/null
+
+exit 0