diff --git a/gogs/default/0001-Adjust-config-for-Arch-Linux-package.patch b/gogs/default/0001-Adjust-config-for-Arch-Linux-package.patch new file mode 100644 index 00000000..93d02985 --- /dev/null +++ b/gogs/default/0001-Adjust-config-for-Arch-Linux-package.patch @@ -0,0 +1,79 @@ +From 60c868f117e603dbe89be616539d88ca85236693 Mon Sep 17 00:00:00 2001 +From: Martchus +Date: Sun, 19 Mar 2017 18:03:36 +0100 +Subject: [PATCH 1/2] Adjust config for Arch Linux package + +--- + conf/app.ini | 18 +++++++++--------- + 1 file changed, 9 insertions(+), 9 deletions(-) + +diff --git a/conf/app.ini b/conf/app.ini +index 315d305d..012feb8e 100644 +--- a/conf/app.ini ++++ b/conf/app.ini +@@ -5,7 +5,7 @@ + ; App name that shows on every page title + APP_NAME = Gogs + ; The name of the system user that runs Gogs +-RUN_USER = git ++RUN_USER = gogs + ; Either "dev", "prod" or "test" + RUN_MODE = dev + +@@ -54,13 +54,13 @@ DISABLE_ROUTER_LOG = false + ; not forget to export the private key): + ; $ openssl pkcs12 -in cert.pfx -out cert.pem -nokeys + ; $ openssl pkcs12 -in cert.pfx -out key.pem -nocerts -nodes +-CERT_FILE = custom/https/cert.pem +-KEY_FILE = custom/https/key.pem ++CERT_FILE = /var/lib/gogs/cert/cert.pem ++KEY_FILE = /var/lib/gogs/cert/key.pem + ; Upper level of template and static file path + ; default is the path where Gogs is executed +-STATIC_ROOT_PATH = ++STATIC_ROOT_PATH = /usr/share/gogs + ; Default path for App data +-APP_DATA_PATH = data ++APP_DATA_PATH = /var/lib/gogs/data + ; Application level GZIP support + ENABLE_GZIP = false + ; Landing page for non-logged users, can be "home" or "explore" +@@ -68,7 +68,7 @@ LANDING_PAGE = home + + [repository] + ; Root path for storing repositories's data, default is "~//gogs-repositories" +-ROOT = ++ROOT = /var/lib/gogs/repos + ; The script type server supports, sometimes could be "sh" + SCRIPT_TYPE = bash + ; Default ANSI charset for an unrecognized charset +@@ -106,7 +106,7 @@ PREVIEWABLE_FILE_MODES = markdown + ; Enable repository file uploads. + ENABLED = true + ; Path to temporarily store uploads (default path gets cleaned by Gogs in every start) +-TEMP_PATH = data/tmp/uploads ++TEMP_PATH = /var/cache/gogs + ; File types that are allowed to be uploaded, e.g. image/jpeg|image/png. Leave empty means allow any file type + ALLOWED_TYPES = + ; Maximum size of each file in MB +@@ -165,7 +165,7 @@ PASSWD = + ; For "postgres" only, either "disable", "require" or "verify-full" + SSL_MODE = disable + ; For "sqlite3" and "tidb", use absolute path when you start as service +-PATH = data/gogs.db ++PATH = /var/lib/gogs/gogs.db + + [admin] + ; Disable regular (non-admin) users to create organizations +@@ -307,7 +307,7 @@ FORMAT = + + ; General settings of loggers + [log] +-ROOT_PATH = ++ROOT_PATH = /var/log/gogs + ; Can be "console" and "file", default is "console" + ; Use comma to separate multiple modes, e.g. "console, file" + MODE = console +-- +2.12.0 + diff --git a/gogs/default/0002-Adjust-service-file-for-Arch-Linux-package.patch b/gogs/default/0002-Adjust-service-file-for-Arch-Linux-package.patch new file mode 100644 index 00000000..23f3671c --- /dev/null +++ b/gogs/default/0002-Adjust-service-file-for-Arch-Linux-package.patch @@ -0,0 +1,34 @@ +From aac58a3b3036bef496937b84668424ea1c3b761a Mon Sep 17 00:00:00 2001 +From: Martchus +Date: Sun, 19 Mar 2017 18:04:48 +0100 +Subject: [PATCH 2/2] Adjust service file for Arch Linux package + +--- + scripts/systemd/gogs.service | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/scripts/systemd/gogs.service b/scripts/systemd/gogs.service +index 9f105bf8..99ca11e0 100644 +--- a/scripts/systemd/gogs.service ++++ b/scripts/systemd/gogs.service +@@ -12,12 +12,12 @@ After=mariadb.service mysqld.service postgresql.service memcached.service redis. + #LimitMEMLOCK=infinity + #LimitNOFILE=65535 + Type=simple +-User=git +-Group=git +-WorkingDirectory=/home/git/gogs +-ExecStart=/home/git/gogs/gogs web ++User=gogs ++Group=gogs ++WorkingDirectory=/var/lib/gogs ++ExecStart=/usr/bin/gogs web --config /etc/gogs/app.ini + Restart=always +-Environment=USER=git HOME=/home/git ++Environment=USER=gogs HOME=/var/lib/gogs + + [Install] + WantedBy=multi-user.target +-- +2.12.0 + diff --git a/gogs/default/PKGBUILD b/gogs/default/PKGBUILD new file mode 100644 index 00000000..17c736cf --- /dev/null +++ b/gogs/default/PKGBUILD @@ -0,0 +1,84 @@ +# Maintainer: Thomas Fanninger +# Contributor: Thomas Laroche +# Contributor: Martchus > + +pkgname=gogs +_pkgname=${pkgname} +pkgver=0.10.18 +pkgrel=1 +epoch=1 +pkgdesc='Self Hosted Git Service written in Go' +arch=('i686' 'x86_64' 'armv6h' 'armv7h') +url='http://gogs.io/' +license=('MIT') +provides=('gogs') +depends=('git>=1.7.1') +optdepends=('sqlite: SQLite support' + 'mariadb: MariaDB support' + 'postgresql: PostgreSQL support' + 'redis: Redis support' + 'memcached: MemCached support' + 'openssh: GIT over SSH support') +makedepends=('go>=1.3' 'glide>=0.10') +conflicts=('gogs-bin' 'gogs-git' 'gogs-git-dev') +options=('!strip' '!emptydirs') +backup=('etc/gogs/app.ini') +install=gogs.install +_gourl=github.com/gogits/$_pkgname +source=("$_pkgname-$pkgver::https://${_gourl}/archive/v${pkgver}.tar.gz" + '0001-Adjust-config-for-Arch-Linux-package.patch' + '0002-Adjust-service-file-for-Arch-Linux-package.patch') +sha512sums=('aedf45900c85d260466e3db906e0320454c0a987198dc3101400d0d73d11b074d19594d655af8ac848ac14d27fa2a9adbfe09b6f055b28d72bb6d3e2f88b4cec' + 'd15c2c0faac4fc378c1c041ca3e4662909ce083d0eae519e7ddfce567ce8329283ef9eff0c4a55a4e9e25df594d020938d3fff9bcc13abcf9d2762ffa2893c9e' + '6bbfc939959b56a64da6783922bec3239a010d77f26bad18415ce17db7095e9d3ef59d5e2ff1fb70e31f1f42464e39e2aa52193ba1f534613d3ebad578bfb914') +_goroot='/usr/lib/go' + +prepare() { + export GOROOT="$_goroot" + + msg2 'Prepare GO build enviroment' + rm -rf build + mkdir -p build/go + cd build/go + + for f in "$GOROOT/"*; do + ln -s "$f" + done + + rm pkg && mkdir pkg && cd pkg + + for f in "$GOROOT/pkg/"*; do + ln -s "$f" + done + + export GOROOT="$srcdir/build/go" + export GOPATH="$srcdir/build" + + mkdir -p "$GOPATH/src/github.com/gogits" + mv "$srcdir/$_pkgname-${pkgver}" "$GOPATH/src/${_gourl}" + + msg2 'Patch config and service file' + cd "$GOPATH/src/${_gourl}" + patch -Np1 -i "$srcdir/0001-Adjust-config-for-Arch-Linux-package.patch" + patch -Np1 -i "$srcdir/0002-Adjust-service-file-for-Arch-Linux-package.patch" +} + +build() { + cd "$GOPATH/src/${_gourl}" + + go fix + go build -x -tags='sqlite pam cert' +} + +package() { + install -Dm0755 "$srcdir/build/src/${_gourl}/$_pkgname" "$pkgdir/usr/bin/$_pkgname" + + mkdir -p "$pkgdir/usr/share/${_pkgname}" + cp -r "$srcdir/build/src/${_gourl}/conf" "$pkgdir/usr/share/${_pkgname}" + cp -r "$srcdir/build/src/${_gourl}/public" "$pkgdir/usr/share/${_pkgname}" + cp -r "$srcdir/build/src/${_gourl}/templates" "$pkgdir/usr/share/${_pkgname}" + + install -Dm0644 "$pkgdir/usr/share/$_pkgname/conf/app.ini" "$pkgdir/etc/$_pkgname/app.ini" + install -Dm0644 "$srcdir/build/src/${_gourl}/scripts/systemd/gogs.service" "$pkgdir/usr/lib/systemd/system/gogs.service" + install -Dm0644 "$srcdir/build/src/${_gourl}/LICENSE" "$pkgdir/usr/share/licenses/$_pkgname" +} diff --git a/gogs/default/README.md b/gogs/default/README.md new file mode 100644 index 00000000..0b08372d --- /dev/null +++ b/gogs/default/README.md @@ -0,0 +1,45 @@ +# Gogs +PKGBUILD files for different versions of Gogs (Go Git Service). + +## Open points +* ~~Systemd service support~~ +* ~~better file structure~~ +* ~~Publishing on https://aur.archlinux.org~~ +* Test MariaDB and PostgreSQL installation +* ~~Test on armv6h (Raspberry Pi), armv7h (Cubieboard 2) and on x86_64~~ +* Documentation for usage and configuration + +## Install +``` +$ tar -xvzf //gogs-*.tar.gz +$ cd +$ makepkg +$ pacman -U gogs-*.tgz +``` + +## Configuration +Config file is located under `/etc/gogs/app.ini`. + +Enable and start systemd service: +``` +$ systemctl enable gogs.service +$ systemctl start gogs.service +``` + +## Setup proxy in NGINX +Eg. +``` +location ^~ /gogs/ { + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass http://localhost:3000/; +} +``` + +## Logging +After start of the service every log entry is over journalctl displayable. +``` +$ journalctl -f -u gogs.service +``` diff --git a/gogs/default/gogs.install b/gogs/default/gogs.install new file mode 100644 index 00000000..0135c975 --- /dev/null +++ b/gogs/default/gogs.install @@ -0,0 +1,39 @@ +pre_install() { + if ! getent group gogs >/dev/null; then + groupadd --system gogs + fi + if ! getent passwd gogs >/dev/null; then + useradd -m --system -c 'gogs daemon users' -g gogs -s /bin/false gogs -d /var/lib/gogs + fi + chsh gogs -s /bin/bash +} + +post_install(){ + mkdir -p /var/log/gogs + chown -R gogs:gogs /var/log/gogs + chown -R gogs:gogs /var/lib/gogs + + systemctl daemon-reload +} + +pre_upgrade(){ + pre_install $1 +} + +post_upgrade() { + post_install $1 +} + +pre_remove() { + systemctl stop gogs.service + systemctl disable gogs.service +} + +post_remove() { + if getent passwd gogs >/dev/null; then + userdel -r gogs + fi + if getent group gogs >/dev/null; then + groupdel gogs + fi +}