aboutsummaryrefslogtreecommitdiffstats
path: root/community/borgbackup/APKBUILD
blob: 207989df0adcaded246c5a69969b1f8c29d600e7 (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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# Contributor: Olivier Mauras <olivier@mauras.ch>
# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=borgbackup
_pkgname=borg
pkgver=1.2.7
pkgrel=0
pkgdesc="Deduplicating backup program"
url="https://www.borgbackup.org/"
arch="all"
license="BSD-3-Clause"
depends="
	py3-msgpack
	py3-packaging
	python3
	"
makedepends="
	acl-dev
	attr-dev
	linux-headers
	lz4-dev
	openssl-dev>3
	py3-setuptools
	py3-setuptools_scm
	python3-dev
	xxhash-dev
	zstd-dev
	"
checkdepends="
	cmd:fusermount3
	py3-dateutil
	py3-pytest
	py3-pytest-benchmark
	py3-pytest-xdist
	"
subpackages="
	$pkgname-pyc
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/borgbackup/borg/releases/download/$pkgver/borgbackup-$pkgver.tar.gz
	test-fusermount3.patch
	"

# secfixes:
#   1.2.6-r0:
#     - CVE-2023-36811

case "$CARCH" in
	armhf | armv7 | x86) ;;  # blocked by py3-pyfuse3
	*) makedepends="$makedepends py3-pyfuse3"
	   subpackages="$subpackages $pkgname-fuse::noarch";;
esac

export BORG_LIBLZ4_PREFIX="/usr/include"
export BORG_LIBXXHASH_PREFIX="/usr/include"
export BORG_LIBZSTD_PREFIX="/usr/include"
export BORG_OPENSSL_PREFIX="/usr/include/openssl"

prepare() {
	default_prepare

	# Remove bundled libs to ensure these don't end up in our binaries.
	cd src/borg/algorithms/
	rm -rf lz4 xxh64 zstd
}

build() {
	# CYTHON_FORCE_REGEN - don't use precompiled Cython code, always regenerate.
	CYTHON_FORCE_REGEN=1 \
	python3 setup.py build
}

check() {
	[ -e /dev/fuse ] || export BORG_FUSE_IMPL='none'

	PYTHONPATH="$(echo "$builddir"/build/lib.linux-*)" pytest -v -n auto \
		--benchmark-skip --pyargs borg.testsuite

	_delete_testsuite

	# Run selftest to ensure that we haven't deleted some testsuite module that
	# is needed for selftest. Note that borg runs selftest automatically before
	# every operation, so it's crucial.
	PYTHONPATH="$(echo build/lib.linux-*)" python3 -B <<-PYTHON
		from borg.selftest import selftest
		import logging

		logging.basicConfig(level=logging.DEBUG)
		selftest(logging)
	PYTHON
}

package() {
	# Run it again for the case we skipped check.
	_delete_testsuite

	python3 setup.py install --skip-build --root="$pkgdir"

	install -Dm644 -t "$pkgdir"/usr/share/man/man1 docs/man/*.1

	install -Dm644 scripts/shell_completions/bash/$_pkgname \
		"$pkgdir"/usr/share/bash-completion/completions/$_pkgname

	install -Dm644 scripts/shell_completions/fish/$_pkgname.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/$_pkgname.fish

	install -Dm644 scripts/shell_completions/zsh/_$_pkgname \
		"$pkgdir"/usr/share/zsh/site-functions/_$_pkgname

	# clean some useless files
	cd "$pkgdir"/usr/lib/python*/site-packages/borg
	find . -name '*.h' -delete -o -name '*.c' -delete -o -name '*.pyx' -delete
}

fuse() {
	pkgdesc="$pkgdesc (FUSE support)"
	depends="$pkgname=$pkgver-r$pkgrel py3-pyfuse3"

	mkdir -p "$subpkgdir"
}

# Delete testsuite but keep modules required for selftest (see src/borg/selftest.py).
_delete_testsuite() {
	cd build/lib.linux-*

	find borg/testsuite/ -type f ! \( \
		-name '__init__.*' -or \
		-name 'crypto.*' -or \
		-name 'chunker.*' -or \
		-name 'hashindex.*' \) -delete
	rm -f borg/testsuite/__pycache__/*-pytest-*.pyc

	cd - >/dev/null
}

sha512sums="
313f495d09bff9d2106a2354d02e8b5478dbce279ccfe863d22bbca40fe1bef94fc575e4ae45585a776689fa0058982c4c009c423ac948cc229e15bb5eb5f2bc  borgbackup-1.2.7.tar.gz
d5aea79b8ff663ca87b845680a31ba75235f734f95a5cfa444e49813916e530754b98269bfbccfda800fbf102652ee4ed47bdb71f6cda831e76f0fae3b5433d8  test-fusermount3.patch
"