diff --git a/www-apps/gitea/files/app.ini b/www-apps/gitea/files/app.ini new file mode 100644 index 000000000..5dd998f60 --- /dev/null +++ b/www-apps/gitea/files/app.ini @@ -0,0 +1,4 @@ +[log] +MODE = file +LEVEL = Info +ROOT_PATH = /var/log/gitea diff --git a/www-apps/gitea/files/gitea.confd b/www-apps/gitea/files/gitea.confd new file mode 100644 index 000000000..8b1710b06 --- /dev/null +++ b/www-apps/gitea/files/gitea.confd @@ -0,0 +1,2 @@ +# arguments for gitea +command_args="--config /var/lib/gitea/conf/app.ini" diff --git a/www-apps/gitea/files/gitea.initd b/www-apps/gitea/files/gitea.initd new file mode 100644 index 000000000..837164aa0 --- /dev/null +++ b/www-apps/gitea/files/gitea.initd @@ -0,0 +1,25 @@ +#!/sbin/openrc-run +# Copyright 2016-2018 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +description="Gitea, a self-hosted Git service" +pidfile=${pidfile:-"/run/${SVCNAME}/${SVCNAME}.pid"} +user=${user:-git} +group=${group:-git} + +command="/usr/bin/gitea web" +command_args="${command_args:--config /var/lib/gitea/conf/app.ini}" +command_background="true" +start_stop_daemon_args="--user ${user} --group ${group} \ + -e GITEA_WORK_DIR=/var/lib/gitea + --stdout /var/log/${SVCNAME}/${SVCNAME}.log \ + --stderr /var/log/${SVCNAME}/${SVCNAME}.log" + +depend() { + need net + after net +} + +start_pre() { + checkpath -d -m 0755 -o "${user}":"${group}" "${pidfile%/*}" +} diff --git a/www-apps/gitea/files/gitea.initd-r1 b/www-apps/gitea/files/gitea.initd-r1 new file mode 100644 index 000000000..837164aa0 --- /dev/null +++ b/www-apps/gitea/files/gitea.initd-r1 @@ -0,0 +1,25 @@ +#!/sbin/openrc-run +# Copyright 2016-2018 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +description="Gitea, a self-hosted Git service" +pidfile=${pidfile:-"/run/${SVCNAME}/${SVCNAME}.pid"} +user=${user:-git} +group=${group:-git} + +command="/usr/bin/gitea web" +command_args="${command_args:--config /var/lib/gitea/conf/app.ini}" +command_background="true" +start_stop_daemon_args="--user ${user} --group ${group} \ + -e GITEA_WORK_DIR=/var/lib/gitea + --stdout /var/log/${SVCNAME}/${SVCNAME}.log \ + --stderr /var/log/${SVCNAME}/${SVCNAME}.log" + +depend() { + need net + after net +} + +start_pre() { + checkpath -d -m 0755 -o "${user}":"${group}" "${pidfile%/*}" +} diff --git a/www-apps/gitea/files/gitea.logrotated b/www-apps/gitea/files/gitea.logrotated new file mode 100644 index 000000000..ec6ddfe60 --- /dev/null +++ b/www-apps/gitea/files/gitea.logrotated @@ -0,0 +1,8 @@ +/var/log/gitea/* { + su git git + missingok + size 5M + rotate 3 + compress + copytruncate +} diff --git a/www-apps/gitea/files/gitea.service b/www-apps/gitea/files/gitea.service new file mode 100644 index 000000000..3fdbc1fd0 --- /dev/null +++ b/www-apps/gitea/files/gitea.service @@ -0,0 +1,26 @@ +[Unit] +Description=Gitea service +Documentation=https://gitea.io + +AssertPathIsDirectory=/var/lib/gitea +AssertPathIsReadWrite=/var/lib/gitea + +After=network.target +Requires=network.target +After=mysqld.service +Requires=mysqld.service + +[Service] +User=git +Group=git + +Environment="GITEA_CUSTOM=/var/lib/gitea" +WorkingDirectory=/var/lib/gitea +ExecStart=/usr/bin/gitea web -c /var/lib/gitea/conf/app.ini + +Restart=always +PrivateTmp=true +Nice=5 + +[Install] +WantedBy=multi-user.target diff --git a/www-apps/gitea/gitea-1.4.2.ebuild b/www-apps/gitea/gitea-1.4.2.ebuild new file mode 100644 index 000000000..41abc1c91 --- /dev/null +++ b/www-apps/gitea/gitea-1.4.2.ebuild @@ -0,0 +1,61 @@ +# Copyright 1999-2018 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 +inherit user systemd golang-build golang-vcs-snapshot + +EGO_PN="code.gitea.io/gitea" +KEYWORDS="~amd64 ~arm" + +DESCRIPTION="A painless self-hosted Git service, written in Go" +HOMEPAGE="https://github.com/go-gitea/gitea" +SRC_URI="https://github.com/go-gitea/gitea/archive/v${PV}.tar.gz -> ${P}.tar.gz" + +LICENSE="MIT" +SLOT="0" +IUSE="" + +DEPEND="dev-go/go-bindata" +RDEPEND="dev-vcs/git" + +pkg_setup() { + enewgroup git + enewuser git -1 /bin/bash /var/lib/gitea git +} + +src_prepare() { + default + sed -i -e "s/\"main.Version.*$/\"main.Version=${PV}\"/"\ + -e "s/-ldflags '-s/-ldflags '/" src/${EGO_PN}/Makefile || die +} + +src_compile() { + GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" emake -C src/${EGO_PN} generate + TAGS="bindata pam sqlite" LDFLAGS="" CGO_LDFLAGS="-fno-PIC" GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" emake -C src/${EGO_PN} build +} + +src_install() { + pushd src/${EGO_PN} || die + dobin gitea + insinto /var/lib/gitea/conf + newins custom/conf/app.ini.sample app.ini.example + popd || die + newinitd "${FILESDIR}"/gitea.initd-r1 gitea + newconfd "${FILESDIR}"/gitea.confd gitea + keepdir /var/log/gitea /var/lib/gitea/data + fowners -R git:git /var/log/gitea /var/lib/gitea/ + systemd_dounit "${FILESDIR}/gitea.service" +} + +pkg_postinst() { + if [[ ! -e "${EROOT}/var/lib/gitea/conf/app.ini" ]]; then + elog "No app.ini found, copying initial config over" + cp "${FILESDIR}"/app.ini "${EROOT}"/var/lib/gitea/conf/ || die + chown git:git /var/lib/gitea/conf/app.ini + else + elog "app.ini found, please check example file for possible changes" + ewarn "Please note that environment variables have been changed:" + ewarn "GITEA_WORK_DIR is set to /var/lib/gitea (previous value: unset)" + ewarn "GITEA_CUSTOM is set to '\$GITEA_WORK_DIR/custom' (previous: /var/lib/gitea)" + fi +}