Subject: [alpine-aports] [PATCH] testing/docker-registry: new aport

From: Christian Kampka <[email-masked]>
Date: Thu, 16 Jul 2015 20:39:56 +0000

https://github.com/docker/distribution
An implementation of the Docker Registry HTTP API V2 for use with docker
1.6+.

Patch is attached, I would appreciate a review of the openrc init script,
since I have no previous experience with openrc whatsoever.
From a4f46c2dcf08e59436728622356256896d914f68 Mon Sep 17 00:00:00 2001
From: Christian Kampka <[email-masked]>
Date: Thu, 16 Jul 2015 22:28:54 +0200
Subject: [PATCH] testing/docker-registry: new aport

https://github.com/docker/distribution
An implementation of the Docker Registry HTTP API V2 for use with
docker 1.6+.
---
 testing/docker-registry/APKBUILD              | 49 +++++++++++++++++++++++++++
 testing/docker-registry/docker-registry.initd | 30 ++++++++++++++++
 2 files changed, 79 insertions(+)
 create mode 100644 testing/docker-registry/APKBUILD
 create mode 100644 testing/docker-registry/docker-registry.initd

diff --git a/testing/docker-registry/APKBUILD b/testing/docker-registry/APKBUILD
new file mode 100644
index 0000000..356e61a
--- /dev/null
+++ b/testing/docker-registry/APKBUILD
@@ -0,0 +1,49 @@
+# Maintainer: Chritsian Kampka <christian at kampka dot net>
+pkgname=docker-registry
+pkgver=2.0.1
+pkgrel=0
+pkgdesc="An implementation of the Docker Registry HTTP API V2 for use with docker 1.6+."
+url="https://github.com/docker/distribution"
+arch="x86_64"
+license="MIT"
+makedepends="git go"
+backup="/etc/${pkgname}/config.yml"
+source="
+  $pkgname-$pkgver.tar.gz::${url}/archive/v${pkgver}.tar.gz
+	docker-registry.initd
+	"
+
+_builddir="$srcdir/distribution-$pkgver"
+prepare() {
+	local i
+	cd "$_builddir"
+	for i in $source; do
+		case $i in
+		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+		esac
+	done
+}
+
+build() {
+    export DISTRIBUTION_DIR="${_builddir}"
+    export GOPATH="${DISTRIBUTION_DIR}/Godeps/_workspace"
+    cd "${DISTRIBUTION_DIR}"
+
+    # GOPATH fix
+    ln -s "${DISTRIBUTION_DIR}" "${DISTRIBUTION_DIR}/Godeps/_workspace/src/github.com/docker/distribution"
+
+    make clean binaries
+}
+
+package() {
+    export DISTRIBUTION_DIR="${srcdir}/distribution-${pkgver}"
+    install -v -D -m755 "${srcdir}/${pkgname}.initd" "${pkgdir}/etc/init.d/${pkgname}"
+    install -v -D -m755 "${DISTRIBUTION_DIR}/bin/registry" "${pkgdir}/usr/bin/${pkgname}"
+    install -v -D -m644 "${DISTRIBUTION_DIR}/cmd/registry/config.yml" "${pkgdir}/etc/${pkgname}/config.yml"
+}
+md5sums="7dc693ced280834bb37913b7164953b7  docker-registry-2.0.1.tar.gz
+95f83f704c630aadb167cbcbfad867cb  docker-registry.initd"
+sha256sums="1664584c311dac98a8b09880d5c79ffceea7a4e0f2359be70c6a9a6ddd9d804a  docker-registry-2.0.1.tar.gz
+f4cbf23714741b3a867ef0842ccac5b9236de241dfd9407a22dc97bcc01f2637  docker-registry.initd"
+sha512sums="3f8e73f04f2a2ea20eaeb0b065e5107b85fa937680aeac750b59e413aa769de98320b88b573a674b60ebb53291cdae1905e92563c827a7f3c14e9d7db17eeaa9  docker-registry-2.0.1.tar.gz
+4aaf59be97cbd5145cfa3a897628fd2193d8967388d0314e22b08981d4bf56d134c119e3abd4751e40f349e535e165e5595c354f04b075f8e872a4feadeddd04  docker-registry.initd"
diff --git a/testing/docker-registry/docker-registry.initd b/testing/docker-registry/docker-registry.initd
new file mode 100644
index 0000000..62fd0bf
--- /dev/null
+++ b/testing/docker-registry/docker-registry.initd
@@ -0,0 +1,30 @@
+#!/sbin/runscript
+# $Header: $
+
+DOCKER_REGISTRY_LOGFILE=${DOCKER_REGISTRY_LOGFILE:-/var/log/${SVCNAME}.log}
+DOCKER_REGISTRY_PIDFILE=${DOCKER_REGISTRY_PIDFILE:-/run/${SVCNAME}.pid}
+DOCKER_REGISTRY_BINARY=${DOCKER_REGISTRY_BINARY:-/usr/bin/docker-registry}
+DOCKER_REGISTRY_CONFIG=${DOCKER_REGISTRY_CONFIG:-/etc/docker-registry/config.yml}
+
+start() {
+	checkpath -f -m 0644 -o root:docker "$DOCKER_REGISTRY_LOGFILE"
+
+	ebegin "Starting docker registry"
+	start-stop-daemon --start --background \
+		--exec "$DOCKER_REGISTRY_BINARY" \
+		--pidfile "$DOCKER_PIDFILE" \
+    --make-pid \
+    --background \
+		--stdout "$DOCKER_LOGFILE" \
+		--stderr "$DOCKER_LOGFILE" \
+		-- "$DOCKER_REGISTRY_CONFIG"
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping docker daemon"
+	start-stop-daemon --stop \
+		--exec "$DOCKER_BINARY" \
+		--pidfile "$DOCKER_PIDFILE"
+	eend $?
+}
-- 
2.4.5