aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyril Rohr <cyril.rohr@gmail.com>2014-09-08 16:58:23 +0000
committerCyril Rohr <cyril.rohr@gmail.com>2014-09-09 18:31:32 +0000
commit7fe61558f616b5889d26a7564722560b6e265a5d (patch)
tree8bc070a76cc8f1742b2abcb6aa192c4987adca6d
parente21d8a7d350ea6003f2edac016a4cd8537e00ef0 (diff)
Make Gogs packageable with https://packager.io
-rw-r--r--.godir1
-rw-r--r--.pkgr.yml11
-rw-r--r--Procfile1
-rwxr-xr-xpackaging/debian/postinst51
4 files changed, 64 insertions, 0 deletions
diff --git a/.godir b/.godir
new file mode 100644
index 00000000..ba2906d0
--- /dev/null
+++ b/.godir
@@ -0,0 +1 @@
+main
diff --git a/.pkgr.yml b/.pkgr.yml
new file mode 100644
index 00000000..f9818780
--- /dev/null
+++ b/.pkgr.yml
@@ -0,0 +1,11 @@
+buildpack: "https://github.com/kr/heroku-buildpack-go.git"
+targets:
+ ubuntu-14.04:
+build_dependencies:
+ - mercurial
+ - bzr
+dependencies:
+ - git
+after:
+ - mv bin/main gogs
+after_install: ./packaging/debian/postinst
diff --git a/Procfile b/Procfile
new file mode 100644
index 00000000..efa00d25
--- /dev/null
+++ b/Procfile
@@ -0,0 +1 @@
+web: ./gogs web
diff --git a/packaging/debian/postinst b/packaging/debian/postinst
new file mode 100755
index 00000000..90ff2b46
--- /dev/null
+++ b/packaging/debian/postinst
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+set -e
+
+# summary of how this script can be called:
+# * <postinst> `configure' <most-recently-configured-version>
+# * <old-postinst> `abort-upgrade' <new version>
+# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+# <new-version>
+# * <postinst> `abort-remove'
+# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+# <failed-install-package> <version> `removing'
+# <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+APP_NAME="gogs"
+CLI="${APP_NAME}"
+APP_USER=$(${CLI} config:get APP_USER)
+APP_GROUP=$(${CLI} config:get APP_GROUP)
+APP_CONFIG="/etc/${APP_NAME}/conf/app.ini"
+
+# source debconf library
+. /usr/share/debconf/confmodule
+
+case "$1" in
+
+ configure)
+ mkdir -p $(dirname ${APP_CONFIG})
+ chown ${APP_USER}.${APP_GROUP} $(dirname ${APP_CONFIG})
+ [ -f ${APP_CONFIG} ] || ${CLI} run cp conf/app.ini ${APP_CONFIG}
+ ${CLI} config:set USER=${APP_USER}
+ ${CLI} config:set GOGS_CUSTOM="/etc/${APP_NAME}"
+ PORT=$(${CLI} config:get PORT || echo "6000")
+ sed -i "s|HTTP_PORT = 3000|HTTP_PORT = ${PORT}|" ${APP_CONFIG}
+ sed -i "s|RUN_USER = git|RUN_USER = ${APP_USER}|" ${APP_CONFIG}
+ sed -i "s|RUN_MODE = dev|RUN_MODE = prod|" ${APP_CONFIG}
+
+ # scale
+ ${CLI} scale web=1 || true
+ ;;
+
+ abort-upgrade|abort-remove|abort-deconfigure)
+ exit 0
+ ;;
+
+ *)
+ echo "postinst called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac