From 7fe61558f616b5889d26a7564722560b6e265a5d Mon Sep 17 00:00:00 2001 From: Cyril Rohr Date: Mon, 8 Sep 2014 16:58:23 +0000 Subject: [PATCH 1/2] Make Gogs packageable with https://packager.io --- .godir | 1 + .pkgr.yml | 11 +++++++++ Procfile | 1 + packaging/debian/postinst | 51 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 .godir create mode 100644 .pkgr.yml create mode 100644 Procfile create mode 100755 packaging/debian/postinst 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: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# 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 From 27cb01cd5f705d5c86b059535d995b7aaa7a2ca6 Mon Sep 17 00:00:00 2001 From: Cyril Rohr Date: Tue, 9 Sep 2014 20:29:39 +0000 Subject: [PATCH 2/2] Move into packager folder --- .pkgr.yml | 5 ++++- .godir => packager/.godir | 0 Procfile => packager/Procfile | 0 {packaging => packager}/debian/postinst | 0 4 files changed, 4 insertions(+), 1 deletion(-) rename .godir => packager/.godir (100%) rename Procfile => packager/Procfile (100%) rename {packaging => packager}/debian/postinst (100%) diff --git a/.pkgr.yml b/.pkgr.yml index f9818780..9988ad4d 100644 --- a/.pkgr.yml +++ b/.pkgr.yml @@ -6,6 +6,9 @@ build_dependencies: - bzr dependencies: - git +before: + - mv packager/Procfile . + - mv packager/.godir . after: - mv bin/main gogs -after_install: ./packaging/debian/postinst +after_install: ./packager/debian/postinst diff --git a/.godir b/packager/.godir similarity index 100% rename from .godir rename to packager/.godir diff --git a/Procfile b/packager/Procfile similarity index 100% rename from Procfile rename to packager/Procfile diff --git a/packaging/debian/postinst b/packager/debian/postinst similarity index 100% rename from packaging/debian/postinst rename to packager/debian/postinst