diff options
author | Edvinas Valatka | 2018-06-10 16:53:16 +0300 |
---|---|---|
committer | Edvinas Valatka | 2018-06-10 16:53:16 +0300 |
commit | 324221942522e6799c4012f6498782d2292cd35f (patch) | |
tree | 114039945260f91738f68d7842f7e9ec3b4ea5cb | |
parent | 8ca9b9dc752ee2f259e69690ebed1c8fa9b677c0 (diff) | |
download | aur-324221942522e6799c4012f6498782d2292cd35f.tar.gz |
Refactor similar to gogs
-rw-r--r-- | .SRCINFO | 31 | ||||
-rw-r--r-- | .gitignore | 10 | ||||
-rw-r--r-- | PKGBUILD | 132 | ||||
-rw-r--r-- | gogs.install | 94 | ||||
-rw-r--r-- | gogs.service | 5 | ||||
-rw-r--r-- | gogs.sysusers | 2 |
6 files changed, 166 insertions, 108 deletions
@@ -1,40 +1,41 @@ pkgbase = gogs-git - pkgdesc = Gogs(Go Git Service) is a Self Hosted Git Service in the Go Programming Language. - pkgver = 0.11.19.0609+1+6197a7639 + pkgdesc = Self Hosted Git Service in the Go Programming Language. This is the current git version from branch master. + pkgver = 0.11.53.0603+2+91441c3fb pkgrel = 1 - epoch = 2 - url = http://gogs.io/ + url = https://gogs.io install = gogs.install arch = i686 arch = x86_64 arch = armv6h arch = armv7h - arch = aarch64 license = MIT - makedepends = go makedepends = git + makedepends = go + makedepends = go-bindata-git makedepends = nodejs-less + makedepends = sqlite depends = git - depends = sqlite + depends = pam + optdepends = sqlite: SQLite support optdepends = mariadb: MariaDB support optdepends = postgresql: PostgreSQL support optdepends = redis: Redis support optdepends = memcached: MemCached support optdepends = openssh: GIT over SSH support + optdepends = bash: GIT over SSH support provides = gogs conflicts = gogs - replaces = gogs-master-git options = !buildflags - source = git+https://github.com/gogits/gogs.git#branch=master - source = git+https://github.com/jteeuwen/go-bindata.git + options = !strip + options = emptydirs + source = git+https://github.com/gogs/gogs.git#branch=master source = gogs.service source = gogs.sysusers source = gogs.tmpfiles - md5sums = SKIP - md5sums = SKIP - md5sums = 4ea1610580f7e7de4259025f8980942d - md5sums = e919a9b9cfee91e3ff146bc8841d4d28 - md5sums = 0cef7ff4495be24a34178a4f29e803b6 + sha512sums = SKIP + sha512sums = 26fa3b9579ec2780e56f4a52870461b9cc1e4c1608e006b0759de7c5de137895d48e94a1694341b545be0dae87c966a982d8b581397d56fad83ab12e297f98df + sha512sums = 0a546902ffb9fe99f61b301183059cc85c75408cd735f04ee93829ad6e3d66a07ebc73ce663743f109ea6303c1815933a17fe2b83bf9104d1528acb5aa63faf8 + sha512sums = a48c51665079575aa9e4774e9d6ccaf15880c81d3d8d77dbcc0871133be7907177694986f12a5d880aa1930a636ca42b5ccb2dbb91874ad9f3c31fa6e5218c6b pkgname = gogs-git diff --git a/.gitignore b/.gitignore index 6b2f8a43fcf0..512ba7b0b717 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ -pkg/ -src/ -gogs/ -go-bindata/ -*.pkg.tar.* +/pkg/ +/src/ +/bin/ +/*.pkg.tar* +/*.log @@ -1,90 +1,88 @@ -# Maintainer: surefire@cryptomile.net -pkgname=gogs-git -epoch=2 -pkgver=0.11.19.0609+1+6197a7639 +# Contributor: Thomas Laroche <tho.laroche@gmail.com> +# Contributor: Thomas Fanninger <thomas@fanninger.at> +# Contributor: surefire@cryptomile.net +# Maintainer: Edvinas Valatka <edacval@gmail.com> + +_branch=master +_pkgname=gogs +_team=github.com/gogs +_gogsdir="${_team}/${_pkgname}" +pkgname=${_pkgname}-git +pkgver=0.11.53.0603+2+91441c3fb pkgrel=1 -pkgdesc="Gogs(Go Git Service) is a Self Hosted Git Service in the Go Programming Language." -arch=('i686' 'x86_64' 'armv6h' 'armv7h' 'aarch64') -url="http://gogs.io/" +pkgdesc="Self Hosted Git Service in the Go Programming Language. This is the current git version from branch ${_branch}." +arch=('i686' 'x86_64' 'armv6h' 'armv7h') +url="https://${_pkgname}.io" license=('MIT') -depends=('git' 'sqlite') -conflicts=('gogs') -provides=('gogs') -replaces=('gogs-master-git') -options=('!buildflags') -optdepends=('mariadb: MariaDB support' - 'postgresql: PostgreSQL support' - 'redis: Redis support' - 'memcached: MemCached support' - 'openssh: GIT over SSH support') -makedepends=('go' 'git' 'nodejs-less') -source=('git+https://github.com/gogits/gogs.git#branch=master' - 'git+https://github.com/jteeuwen/go-bindata.git' #Because сommunity package is very outdated - 'gogs.service' - 'gogs.sysusers' - 'gogs.tmpfiles') -md5sums=('SKIP' - 'SKIP' - '4ea1610580f7e7de4259025f8980942d' - 'e919a9b9cfee91e3ff146bc8841d4d28' - '0cef7ff4495be24a34178a4f29e803b6') -install=gogs.install -_gogsdir="src/github.com/gogits/gogs" +depends=('git' 'pam') +optdepends=("sqlite: SQLite support" + "mariadb: MariaDB support" + "postgresql: PostgreSQL support" + "redis: Redis support" + "memcached: MemCached support" + "openssh: GIT over SSH support" + "bash: GIT over SSH support") +makedepends=('git' 'go' 'go-bindata-git' 'nodejs-less' 'sqlite') +conflicts=("${_pkgname}") +provides=("${_pkgname}") +options=('!buildflags' '!strip' 'emptydirs') +install=${_pkgname}.install + +source=("git+https://${_team}/${_pkgname}.git#branch=${_branch}" + "${_pkgname}.service" + "${_pkgname}.sysusers" + "${_pkgname}.tmpfiles") prepare() { - export GOPATH="$srcdir" + export GOPATH="$srcdir" - mkdir -p ./src/github.com/{gogits,jteeuwen} + mkdir -p "$srcdir/${_team}" + mv -v -t "$srcdir/${_team}" ./${_pkgname} - mv -t ./src/github.com/gogits ./gogs - mv -t ./src/github.com/jteeuwen ./go-bindata + cd "$srcdir/$_gogsdir" - cd "$_gogsdir" - - sed -r -i conf/app.ini \ - -e '0, /^\[/ s/^(RUN_USER)\W.*$/\1 = gogs/' \ - -e '/^\[server\]/, /^\[/ s/^(STATIC_ROOT_PATH)\W.*$/\1 = \/usr\/share\/gogs/' \ - -e '/^\[log\]/, /^\[/ s/^(ROOT_PATH)\W.*$/\1 = \/var\/log\/gogs/' \ - ; - - # Dirty hack - sed -i vendor/github.com/go-xorm/xorm/logger.go \ - -e '/DEFAULT_LOG_LEVEL/ s/core\.LOG_DEBUG/core.LOG_WARNING/' vendor/github.com/go-xorm/xorm/logger.go \ - ; + sed -E -i conf/app.ini \ + -e '0, /^\[/ s/^(RUN_USER)\W.*$/\1 = gogs/' \ + -e '/^\[server\]/, /^\[/ s/^(STATIC_ROOT_PATH)\W.*$/\1 = \/usr\/share\/gogs/' \ + -e '/^\[log\]/, /^\[/ s/^(ROOT_PATH)\W.*$/\1 = \/var\/log\/gogs/' \ + ; } pkgver() { - cd "$_gogsdir" - printf '%s+%s+%s' \ - $(sed -e 's,/,+,g; s, ,,g' templates/.VERSION) \ - $(git rev-list --count HEAD...$(git log --pretty=format:%H -n 1 -- templates/.VERSION)) \ - $(git rev-parse --short HEAD) \ - ; + cd "$srcdir/$_gogsdir" + printf '%s+%s+%s' \ + $(sed -e 's,/,+,g; s, ,,g' templates/.VERSION) \ + $(git rev-list --count HEAD...$(git log --pretty=format:%H -n 1 -- templates/.VERSION)) \ + $(git rev-parse --short HEAD) \ + ; } build() { - export GOPATH="$srcdir" + export GOPATH="$srcdir" - cd "$srcdir/src/github.com/jteeuwen/go-bindata/go-bindata" - go install -v + cd "$srcdir/$_gogsdir" - cd "$srcdir/$_gogsdir" - - make PATH="$GOPATH/bin:$PATH" TAGS='libsqlite3 sqlite pam cert' build + go fix + LDFLAGS='-s -w' make PATH="$GOPATH/bin:$PATH" TAGS='libsqlite3 sqlite pam cert' build } package() { - cd "$_gogsdir" + cd "$srcdir/$_gogsdir" - rm -rf ./public/{less,config.codekit} + rm -rf ./public/{less,config.codekit} - install -d "$pkgdir/usr/share/gogs" - cp -rt "$pkgdir/usr/share/gogs" ./{templates,public} + install -Dm0644 ./conf/app.ini "$pkgdir/usr/share/${_pkgname}/conf/app.ini.default" + cp -rt "$pkgdir/usr/share/${_pkgname}" ./{templates,public} - install -Dm0755 -t "$pkgdir/usr/bin" ./gogs - install -Dm0644 -t "$pkgdir/usr/share/licenses/gogs" ./LICENSE - install -Dm0644 -t "$pkgdir/usr/lib/systemd/system" "$srcdir/gogs.service" + install -Dm0755 -t "$pkgdir/usr/bin" ./${_pkgname} + install -Dm0644 -t "$pkgdir/usr/share/licenses/gogs" ./LICENSE + install -Dm0644 -t "$pkgdir/usr/lib/systemd/system" "$srcdir/${_pkgname}.service" - install -Dm0644 "$srcdir/gogs.sysusers" "$pkgdir/usr/lib/sysusers.d/gogs.conf" - install -Dm0644 "$srcdir/gogs.tmpfiles" "$pkgdir/usr/lib/tmpfiles.d/gogs.conf" + install -Dm0644 "$srcdir/${_pkgname}.tmpfiles" "$pkgdir/usr/lib/tmpfiles.d/${_pkgname}.conf" + install -Dm0644 "$srcdir/${_pkgname}.sysusers" "$pkgdir/usr/lib/sysusers.d/${_pkgname}.conf" } + +sha512sums=('SKIP' + '26fa3b9579ec2780e56f4a52870461b9cc1e4c1608e006b0759de7c5de137895d48e94a1694341b545be0dae87c966a982d8b581397d56fad83ab12e297f98df' + '0a546902ffb9fe99f61b301183059cc85c75408cd735f04ee93829ad6e3d66a07ebc73ce663743f109ea6303c1815933a17fe2b83bf9104d1528acb5aa63faf8' + 'a48c51665079575aa9e4774e9d6ccaf15880c81d3d8d77dbcc0871133be7907177694986f12a5d880aa1930a636ca42b5ccb2dbb91874ad9f3c31fa6e5218c6b') diff --git a/gogs.install b/gogs.install index 9e139659d257..eaa5aa5e62b5 100644 --- a/gogs.install +++ b/gogs.install @@ -1,22 +1,80 @@ -post_install() { -cat <<EOF -:: If you do not have a custom configuration files finish the setup: - 1) systemctl start gogs.service - 2) open the installation page http://localhost:3000 - otherwise: - place your custom configuration files in /var/lib/gogs/custom -EOF +_start_if_enabled() { + if systemctl -q is-enabled gogs.service ;then + echo " Starting gogs service" + systemctl start gogs.service + fi +} + +_stop_if_active() { + if systemctl -q is-active gogs.service ;then + echo " Stoping gogs service" + systemctl stop gogs.service + fi +} + +_disable_if_enabled() { + if systemctl -q is-enabled gogs.service 2>/dev/null ;then + echo " Disabling gogs service" + systemctl disable gogs.service + fi +} + +_gogs_home=/var/lib/gogs + +pre_install() { + if getent passwd gogs >/dev/null; then + local _OldHome="$( getent passwd gogs | cut -d: -f6 )" + if [[ ${_OldHome} != "${_gogs_home}" ]]; then + echo " Setting gogs home directory to ${_gogs_home}" + echo " You must migrate from ${_OldHome}" to ${_gogs_home} + echo " before starting or re-enabling service" + usermod -c 'Gogs service user' -g gogs -d ${_gogs_home} -L -s /bin/bash gogs + _disable_if_enabled + fi + fi +} + +post_install(){ + systemctl daemon-reload + echo " If you do not have a custom configuration file finish the setup:" + echo " 1) start gogs service" + echo " 2) open the installation page http://$(uname -n):3000/" + echo " Otherwise:" + echo " Place your custom configuration file in ${_gogs_home}/custom/conf/app.ini" + echo "" + echo " Default configuration can be located at:" + echo " /usr/share/gogs/conf/app.ini.default" +} + +pre_upgrade() { + _stop_if_active + pre_install } post_upgrade() { - if [ $(vercmp 2:0.9.140 $2) -gt 0 ]; then - echo ":: Gogs configuration now placed in /var/lib/gogs/custom/conf" - - if [ ! -f /var/lib/gogs/custom/conf/app.ini ] && [ -f /srv/gogs/conf/app.ini ]; then - echo ":: Gogs app.ini copied to new place" - install -d -o gogs -g gogs /var/lib/gogs/custom - install -d -o gogs -g gogs /var/lib/gogs/custom/conf - install -m644 -o gogs -g gogs -t /var/lib/gogs/custom/conf /srv/gogs/conf/app.ini - fi - fi + systemctl daemon-reload + + local _CustConf=${_gogs_home}/custom/conf/app.ini + + if [ ! -f ${_CustConf} ] ; then + echo " Gogs old configuration file must be moved to ${_CustConf} before starting service." + _disable_if_enabled + fi + _start_if_enabled +} + +pre_remove() { + _stop_if_active + _disable_if_enabled +} + +post_remove() { + if getent passwd gogs >/dev/null; then + userdel gogs + fi + if getent group gogs >/dev/null; then + groupdel gogs + fi + systemctl daemon-reload + echo " You may need to manually remove an old Gogs home: ${_gogs_home}" } diff --git a/gogs.service b/gogs.service index 14f15c1ba319..9eaa603b9f84 100644 --- a/gogs.service +++ b/gogs.service @@ -1,14 +1,15 @@ [Unit] Description=Gogs (Go Git Service) +After=syslog.target After=network.target [Service] Type=simple User=gogs Group=gogs -Environment="GOGS_WORK_DIR=/var/lib/gogs" -WorkingDirectory=/var/lib/gogs +Environment=GOGS_WORK_DIR=/var/lib/gogs USER=gogs HOME=/var/lib/gogs ExecStart=/usr/bin/gogs web +WorkingDirectory=/var/lib/gogs Restart=always [Install] diff --git a/gogs.sysusers b/gogs.sysusers index 223099f2bd27..de61ce626054 100644 --- a/gogs.sysusers +++ b/gogs.sysusers @@ -1 +1 @@ -u gogs - "Go Git Service" /var/lib/gogs +u gogs - "Go Git Service" /var/lib/gogs /bin/bash |