aboutsummaryrefslogtreecommitdiffstats
path: root/community/gitea/APKBUILD
blob: 8ce5aabeeac3b249459e7bcf0ca8b0076b39943c (plain) (blame)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Contributor: 6543 <6543@obermui.de>
# Maintainer: 6543 <6543@obermui.de>
pkgname=gitea
pkgver=1.15.7
pkgrel=0
pkgdesc="A self-hosted Git service written in Go"
url="https://gitea.io"
# armhf: failing tests
arch="all"
license="MIT"
options="chmod-clean"
depends="git git-lfs gnupg"
makedepends="go libcap"
checkdepends="bash openssh openssh-keygen sqlite"
install="$pkgname.pre-install"
pkgusers="gitea"
pkggroups="www-data"
subpackages="$pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://dl.gitea.io/gitea/$pkgver/gitea-src-$pkgver.tar.gz
	$pkgname.initd
	$pkgname.ini
	fix-tests-ssh-hostkeys.patch
	"
builddir="$srcdir/src/code.gitea.io/$pkgname"

# secfixes:
#   1.14.6-r0:
#     - CVE-2020-26160
#   1.13.7-r0:
#     - CVE-2021-29272
#   1.13.6-r0:
#     - CVE-2021-29134
#   1.13.4-r0:
#     - CVE-2021-28378
#   1.13.2-r0:
#     - CVE-2021-3382

# Skip tests for archs that fail unrelated in CI
case "$CARCH" in
	s390x|x86|armhf|armv7) options="$options !check" ;;
esac

prepare() {
	mkdir -p ${builddir%/*}
	mv "$srcdir"/$pkgname-$pkgver "$builddir"/
	default_prepare
}

build() {
	export GOPATH="$srcdir"
	export TAGS="tidb sqlite sqlite_unlock_notify"
	export GITEA_VERSION="$pkgver"
	unset LDFLAGS
	## make FHS compliant
	LDFLAGS="$LDFLAGS -X code.gitea.io/gitea/modules/setting.CustomConf=/etc/gitea/app.ini"
	LDFLAGS="$LDFLAGS -X code.gitea.io/gitea/modules/setting.AppWorkPath=/var/lib/gitea/"
	LDFLAGS="$LDFLAGS -X code.gitea.io/gitea/modules/setting.StaticRootPath=/usr/share/webapps/gitea/"
	export LDFLAGS

	## make should run without any parallelism
	make backend -j1
}

check() {
	local _home="$srcdir"/home
	mkdir -p $_home
	install -d -m700 $_home/.ssh
	touch $_home/.gitconfig

	## "make test" - modified (exclude broken tests)
	## 'code.gitea.io/gitea/modules/migrations': github hase rate limits! 403 API
	PACKAGES=$(go list ./... | grep -v /vendor/ | \
		grep -v 'code.gitea.io/gitea/modules/migrations' | \
		grep -v 'code.gitea.io/gitea/modules/charset' | \
		grep -v 'code.gitea.io/gitea/models/migrations' | \
		grep -v 'code.gitea.io/gitea/integrations')
	env HOME=$_home GO111MODULE=on go test -mod=vendor -tags='sqlite sqlite_unlock_notify' $PACKAGES

	env HOME=$_home GITEA_WORK_DIR="$(pwd)" timeout -s ABRT 20m make test-sqlite
}

unpack() {
	verify
	initdcheck

	local archdest="$srcdir/$pkgname-$pkgver"

	mkdir -p "$archdest"

	msg "Unpacking $pkgname-$pkgver.tar.gz..."
	tar -C "$archdest" -zxf "$pkgname-$pkgver.tar.gz"
}

package() {
	for dir in $pkgname $pkgname/git $pkgname/data $pkgname/db $pkgname/custom; do
		install -d -m 750 -o gitea -g www-data \
			"$pkgdir"/var/lib/$dir
	done

	install -d -m 755 -o gitea -g www-data "$pkgdir"/var/log/$pkgname

	install -D -m 755 $pkgname "$pkgdir"/usr/bin/$pkgname

	# Allow non root to bind to port 80.
	setcap cap_net_bind_service=+ep \
		"$pkgdir"/usr/bin/$pkgname

	install -D -m 644 -o gitea -g www-data "$srcdir"/gitea.ini \
		"$pkgdir"/etc/$pkgname/app.ini
	chown gitea:www-data "$pkgdir"/etc/$pkgname

	install -d -m 755 "$pkgdir"/usr/share/webapps/$pkgname
	mv options public templates "$pkgdir"/usr/share/webapps/$pkgname/

	install -D -m 755 "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
}

sha512sums="
9488776bb39d15a7390e6734e05c6ee9e092a52055575bc784660d6815125f29498d16a7807dac71ecbabc3f08c407c2da1514c36cce72855a17a9ed7b52fbb9  gitea-1.15.7.tar.gz
207129e9f304b0db77a334e13aab5f9d3b0184af0fa3d63baac7eac5309210afe2b05e91386346a383131004af518fe308c63c49c2429ab85b1fd7ba783a6426  gitea.initd
431184faffa8996873d92d7b0d16bc4b1a0178d264cd2928d1f49b13ad3e6470d9ede7a18c12112deeeb38f0647ccc0b012e98bcbd96e7b8496a3dc18f5b1fb7  gitea.ini
185673516549aaaece6670df039abd327ac3e7da3b744447330ad66d1ea7c1d0c788e04a6eb082be40358b9992a4dd47bb8c423d9f3d5994ece35743fde79a4f  fix-tests-ssh-hostkeys.patch
"