summaryrefslogtreecommitdiff
blob: f2826293e380fe5fab1788ae9aab57cb6683779f (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
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

# Generate using https://github.com/thesamesam/sam-gentoo-scripts/blob/main/niche/generate-sshuttle-docs
# Set to 1 if prebuilt, 0 if not
# (the construct below is to allow overriding from env for script)
: ${SSHUTTLE_DOCS_PREBUILT:=1}

SSHUTTLE_DOCS_PREBUILT_DEV=sam
SSHUTTLE_DOCS_VERSION=${PV}
# Default to generating docs (inc. man pages) if no prebuilt; overridden later
SSHUTTLE_DOCS_USEFLAG="+doc"

DISTUTILS_USE_PEP517=setuptools
PYTHON_COMPAT=( python3_{9..11} )
inherit distutils-r1 linux-info pypi

DESCRIPTION="Transparent proxy server that works as a poor man's VPN using ssh"
HOMEPAGE="https://github.com/sshuttle/sshuttle https://pypi.org/project/sshuttle/"
if [[ ${SSHUTTLE_DOCS_PREBUILT} == 1 ]] ; then
	SRC_URI+=" !doc? ( https://dev.gentoo.org/~${SSHUTTLE_DOCS_PREBUILT_DEV}/distfiles/${CATEGORY}/${PN}/${PN}-${SSHUTTLE_DOCS_VERSION}-docs.tar.xz )"

	SSHUTTLE_DOCS_USEFLAG="doc"
fi

LICENSE="LGPL-2.1+"
SLOT="0"
KEYWORDS="amd64 x86"
IUSE="${SSHUTTLE_DOCS_USEFLAG}"

BDEPEND="
	doc? ( dev-python/sphinx )
	test? (
		dev-python/mock[${PYTHON_USEDEP}]
	)
"
RDEPEND="
	dev-python/psutil[${PYTHON_USEDEP}]
	|| ( net-firewall/iptables net-firewall/nftables )
"

CONFIG_CHECK="~NETFILTER_XT_TARGET_HL ~IP_NF_TARGET_REDIRECT ~IP_NF_MATCH_TTL ~NF_NAT"

distutils_enable_tests pytest

python_prepare_all() {
	# Don't run tests via setup.py pytest
	sed -i "/setup_requires=/s/'pytest-runner'//" setup.py || die

	# Don't require pytest-cov when running tests
	sed -i "s/^addopts =/#\0/" setup.cfg || die

	distutils-r1_python_prepare_all
}

python_compile_all() {
	if use doc ; then
		emake -j1 -C docs html man
	fi
}

python_install_all() {
	# If USE=doc, there'll be newly generated docs which we install instead.
	if ! use doc && [[ ${SSHUTTLE_DOCS_PREBUILT} == 1 ]] ; then
		doman "${WORKDIR}"/${PN}-${SSHUTTLE_DOCS_VERSION}-docs/sshuttle.1
	else
		HTML_DOCS=( docs/_build/html/. )
		doman docs/_build/man/*
	fi

	distutils-r1_python_install_all
}