summaryrefslogtreecommitdiff
blob: 7905bbf3153a7d8d2a766bd1745e0ecabdbcb625 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7
inherit golang-vcs-snapshot systemd user

EGO_PN="code.gitea.io/gitea"
KEYWORDS="~amd64 ~arm ~arm64"

DESCRIPTION="A painless self-hosted Git service"
HOMEPAGE="https://gitea.io"
SRC_URI="https://github.com/go-gitea/gitea/archive/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="MIT"
SLOT="0"
IUSE="pam sqlite"

COMMON_DEPEND="pam? ( sys-libs/pam )"
DEPEND="${COMMON_DEPEND}
	dev-go/go-bindata"
RDEPEND="${COMMON_DEPEND}
	dev-vcs/git"

DOCS=( custom/conf/app.ini.sample CONTRIBUTING.md README.md )
S="${WORKDIR}/${P}/src/${EGO_PN}"

pkg_setup() {
	enewgroup git
	enewuser git -1 /bin/bash /var/lib/gitea git
}

gitea_make() {
	local my_tags=(
		bindata
		$(usev pam)
		$(usex sqlite 'sqlite sqlite_unlock_notify' '')
	)
	local my_makeopt=(
		DRONE_TAG=${PV}
		TAGS="${my_tags[@]}"
	)
	GOPATH=${WORKDIR}/${P}:$(get_golibdir_gopath) emake "${my_makeopt[@]}" "$1"
}

src_compile() {
	gitea_make generate
	gitea_make build
}

src_test() {
	gitea_make test
}

src_install() {
	einstalldocs
	dobin gitea
	newconfd "${FILESDIR}"/gitea.confd-r1 gitea
	newinitd "${FILESDIR}"/gitea.initd-r2 gitea
	systemd_newunit "${FILESDIR}"/gitea.service-r1 gitea.service
	diropts -m0750 -o git -g git
	keepdir /etc/gitea
	keepdir /var/lib/gitea /var/lib/gitea/custom /var/lib/gitea/data
	keepdir /var/log/gitea
}

pkg_postinst() {
	ewarn "The configuration path has been changed to ${EROOT}/etc/gitea/app.ini."
	ewarn "Please adapt the gitea-repositories hooks and ssh authorized_keys."
	ewarn "Depending on your configuration you should run something like:"
	ewarn "sed -i -e 's#/var/lib/gitea/conf/app.ini#/etc/gitea/app.ini#' \\"
	ewarn "  /var/lib/gitea/gitea-repositories/*/*/hooks/*/* \\"
	ewarn "  /var/lib/gitea/.ssh/authorized_keys"

	if [[ ! -e "${EROOT}/etc/gitea/app.ini" ]]; then
		elog "No app.ini found, copying initial config over"
		cp "${FILESDIR}"/app.ini "${EROOT}"/etc/gitea/ || die
		chown git:git "${EROOT}"/etc/gitea/app.ini || die
		elog "Please make sure that your 'git' user has the correct homedir (/var/lib/gitea)."
	else
		elog "app.ini found, please check the sample 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
}