Add gitea package

This commit is contained in:
Martchus 2017-06-16 22:51:17 +02:00
parent 8e058660bd
commit d29ef315f1
6 changed files with 282 additions and 12 deletions

View File

@ -0,0 +1,66 @@
From 76b1b0b0933eb352f90b4d841f328acc8f632eff Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Sun, 19 Mar 2017 18:03:36 +0100
Subject: [PATCH 1/2] Adjust config for Arch Linux package
---
conf/app.ini | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/conf/app.ini b/conf/app.ini
index 1390d453..1ff5acef 100644
--- a/conf/app.ini
+++ b/conf/app.ini
@@ -1,12 +1,12 @@
; App name that shows on every page title
APP_NAME = Gitea: Git with a cup of tea
; Change it if you run locally
-RUN_USER = git
+RUN_USER = gitea
; Either "dev", "prod" or "test", default is "dev"
RUN_MODE = dev
[repository]
-ROOT =
+ROOT = /var/lib/gitea/repos
SCRIPT_TYPE = bash
; Default ANSI charset
ANSI_CHARSET =
@@ -127,13 +127,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/gitea/cert/cert.pem
+KEY_FILE = /var/lib/gitea/cert/key.pem
; Upper level of template and static file path
; default is the path where Gitea is executed
STATIC_ROOT_PATH =
; Default path for App data
-APP_DATA_PATH = data
+APP_DATA_PATH = /var/lib/gitea/data
; Application level GZIP support
ENABLE_GZIP = false
; Landing page for non-logged users, can be "home" or "explore"
@@ -156,7 +156,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/gitea.db
+PATH = /var/lib/gitea/gitea.db
[indexer]
ISSUE_INDEXER_PATH = indexers/issues.bleve
@@ -310,7 +310,7 @@ MAX_FILES = 5
FORMAT =
[log]
-ROOT_PATH =
+ROOT_PATH = /var/log/gitea
; Either "console", "file", "conn", "smtp" or "database", default is "console"
; Use comma to separate multiple modes, e.g. "console, file"
MODE = console
--
2.13.1

View File

@ -0,0 +1,34 @@
From e0502aec7784f655db71380f375e959debacaa35 Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Sun, 19 Mar 2017 18:04:48 +0100
Subject: [PATCH 2/2] Adjust service file for Arch Linux package
---
scripts/systemd/gitea.service | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/scripts/systemd/gitea.service b/scripts/systemd/gitea.service
index 758f1590..302e7a9e 100644
--- a/scripts/systemd/gitea.service
+++ b/scripts/systemd/gitea.service
@@ -15,12 +15,12 @@ After=network.target
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
Type=simple
-User=git
-Group=git
-WorkingDirectory=/home/git/gitea
-ExecStart=/home/git/gitea/gitea web
+User=gitea
+Group=gitea
+WorkingDirectory=/var/lib/gitea
+ExecStart=/usr/bin/gitea web --config /etc/gitea/app.ini
Restart=always
-Environment=USER=git HOME=/home/git
+Environment=USER=gitea HOME=/var/lib/gitea
[Install]
WantedBy=multi-user.target
--
2.13.1

85
gitea/default/PKGBUILD Normal file
View File

@ -0,0 +1,85 @@
# Maintainer: Martchus <martchus@gmx.net>
# Contributor: Thomas Fanninger <thomas@fanninger.at>
# Contributor: Thomas Laroche <tho.laroche@gmail.com>
_pkgname=gitea
_orga=go-${_pkgname}
_gourl=code.$_pkgname.io/$_pkgname
pkgname=${_pkgname}
pkgver=1.1.2
pkgrel=1
#epoch=
pkgdesc='Self Hosted Git Service written in Go'
arch=('i686' 'x86_64' 'armv6h' 'armv7h')
url="https://$_pkgname.io"
license=('MIT')
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')
conflicts=("$_pkgname-bin" "$_pkgname-git" "$_pkgname-dev-git")
options=('!strip' '!emptydirs')
backup=("etc/$_pkgname/app.ini")
install=$_pkgname.install
source=("$_pkgname-$pkgver::https://github.com/$_orga/$_pkgname/archive/v${pkgver}.tar.gz"
'0001-Adjust-config-for-Arch-Linux-package.patch'
'0002-Adjust-service-file-for-Arch-Linux-package.patch')
sha512sums=('ecad2e11cc01fd9c2b05b672e334c013d65824a111be25cbd3956196688c0d52e31875263e16fdae497e651d771539de7c9244cb01fbc522ef77a763315ecaca'
'2885691d8f35ecb72e3a1d5a52708209715b537a0afef1147f32d10c188b1bbb067fd3db7c034273a5499a46f9fbb3310004fcf67eda1797dd193eef5a81460b'
'5ea1d89809427fe395214c5dde88bdb4c4a62e2d19f9da7fa480a0a3cfaaaf2e97c906bd3dceb11676c9720896d72a73f48638411389fa1f07fcbc17e94e0545')
_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/$_gourl"
mv "$srcdir/$_pkgname-${pkgver}" "$GOPATH/src/${_gourl%/$_pkgname}"
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 -ldflags="-s -w" -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/$_pkgname.service" "$pkgdir/usr/lib/systemd/system/$_pkgname.service"
install -Dm0644 "$srcdir/build/src/${_gourl}/LICENSE" "$pkgdir/usr/share/licenses/$_pkgname"
}

45
gitea/default/README.md Normal file
View File

@ -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 /<path to Tarball>/gogs-*.tar.gz
$ cd <package-name>
$ 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
```

View File

@ -0,0 +1,39 @@
pre_install() {
if ! getent group gitea >/dev/null; then
groupadd --system gitea
fi
if ! getent passwd gitea >/dev/null; then
useradd -m --system -c 'gitea daemon users' -g gitea -s /bin/false gitea -d /var/lib/gitea
fi
chsh gitea -s /bin/bash
}
post_install(){
mkdir -p /var/log/gitea
chown -R gitea:gitea /var/log/gitea
chown -R gitea:gitea /var/lib/gitea
systemctl daemon-reload
}
pre_upgrade(){
pre_install $1
}
post_upgrade() {
post_install $1
}
pre_remove() {
systemctl stop gitea.service
systemctl disable gitea.service
}
post_remove() {
if getent passwd gitea >/dev/null; then
userdel -r gitea
fi
if getent group gitea >/dev/null; then
groupdel gitea
fi
}

View File

@ -1,9 +1,12 @@
# Maintainer: Martchus <martchus@gmx.net>>
# Maintainer: Martchus <martchus@gmx.net>
# Contributor: Thomas Fanninger <thomas@fanninger.at>
# Contributor: Thomas Laroche <tho.laroche@gmail.com>
pkgname=gogs
_pkgname=${pkgname}
_pkgname=gogs
_orga=go-${_pkgname}
_gourl=github.com/gogits/$_pkgname
pkgname=$_pkgname
pkgver=0.11.19
pkgrel=1
epoch=1
@ -11,7 +14,6 @@ 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'
@ -20,12 +22,11 @@ optdepends=('sqlite: SQLite support'
'memcached: MemCached support'
'openssh: GIT over SSH support')
makedepends=('go>=1.3')
conflicts=('gogs-bin' 'gogs-git' 'gogs-dev-git')
conflicts=("$_pkgname-bin" "$_pkgname-git" "$_pkgname-dev-git")
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"
backup=("etc/$_pkgname/app.ini")
install=$_pkgname.install
source=("$_pkgname-$pkgver::https://github.com/$_orga/$_pkgname/archive/v${pkgver}.tar.gz"
'0001-Adjust-config-for-Arch-Linux-package.patch'
'0002-Adjust-service-file-for-Arch-Linux-package.patch')
sha512sums=('80339daefe9c4eb9e39af4ab90b6803e9d86648565c0f109a34c00aad9bd40e2edfc77d58e18ad1192ce2e8bc7322113a407e7a02c0116229e1cecf8e67fc8b5'
@ -54,8 +55,8 @@ prepare() {
export GOROOT="$srcdir/build/go"
export GOPATH="$srcdir/build"
mkdir -p "$GOPATH/src/github.com/gogits"
mv "$srcdir/$_pkgname-${pkgver}" "$GOPATH/src/${_gourl}"
mkdir -p "$GOPATH/src/$_gourl"
mv "$srcdir/$_pkgname-${pkgver}" "$GOPATH/src/${_gourl%/$_pkgname}"
msg2 'Patch config and service file'
cd "$GOPATH/src/${_gourl}"
@ -79,6 +80,6 @@ package() {
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}/scripts/systemd/$_pkgname.service" "$pkgdir/usr/lib/systemd/system/$_pkgname.service"
install -Dm0644 "$srcdir/build/src/${_gourl}/LICENSE" "$pkgdir/usr/share/licenses/$_pkgname"
}