summaryrefslogtreecommitdiff
path: root/dev-util/selenium-manager/selenium-manager-4.48.0.ebuild
blob: cd1cea07b9a97913b241d1dd5a71d206d928e8bb (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
# Copyright 2024-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

CRATES="
"
RUST_MIN_VER="1.88.0"

inherit cargo

TAG=selenium-${PV}
MY_P=selenium-${TAG}
CRATES_P=selenium-${PV}
DESCRIPTION="CLI tool that manages the browser/driver infrastructure required by Selenium"
HOMEPAGE="
	https://www.selenium.dev/
	https://github.com/SeleniumHQ/selenium/
"
SRC_URI="
	https://github.com/SeleniumHQ/selenium/archive/selenium-${PV}.tar.gz
		-> ${MY_P}.gh.tar.gz
"
if [[ ${PKGBUMPING} != ${PVR} ]]; then
	SRC_URI+="
		https://github.com/gentoo-crate-dist/selenium/releases/download/${CRATES_P}/${CRATES_P}-crates.tar.xz
	"
fi
S="${WORKDIR}/${MY_P}/rust"

LICENSE="Apache-2.0"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 BSD CDLA-Permissive-2.0 ISC MIT MPL-2.0 Unicode-3.0 ZLIB
	BZIP2
"
SLOT="0"
KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~x86"
IUSE="telemetry test"
RESTRICT="!test? ( test )"

DEPEND="
	app-arch/bzip2:=
	app-arch/xz-utils:=
	app-arch/zstd:=
	virtual/zlib:=
"
RDEPEND="
	${DEPEND}
"
BDEPEND="
	test? (
		|| (
			www-client/firefox
			www-client/firefox-bin
		)
	)
"

QA_FLAGS_IGNORED="usr/bin/${PN}"

src_prepare() {
	default

	sed -i -e '/strip/d' Cargo.toml || die

	# Avoid tests requiring Internet or specific browsers (or trying
	# to fetch them, whatever).
	rm tests/browser_download_tests.rs || die
	rm tests/cache_tests.rs || die
	rm tests/electron_tests.rs || die
	rm tests/exec_driver_tests.rs || die
	rm tests/grid_tests.rs || die
	rm tests/browser_tests.rs || die
	rm tests/config_tests.rs || die
	rm tests/iexplorer_tests.rs || die
	rm tests/mirror_tests.rs || die
	rm tests/output_tests.rs || die
	rm tests/stable_browser_tests.rs || die
	rm tests/webview_tests.rs || die

	# enable system libraries where supported
	export ZSTD_SYS_USE_PKG_CONFIG=1
	sed -i -e '/features.*static/d' "${ECARGO_VENDOR}"/apple-xar-*/Cargo.toml || die

	# remove unbundled sources, just in case
	# (smoke.c is actually used to test system -lz, sigh)
	find "${ECARGO_VENDOR}"/*-sys-*/ \
		\( -name '*.c' -a -not -name 'smoke.c' \) -delete || die

	# bzip2-sys requires a pkg-config file
	# https://github.com/alexcrichton/bzip2-rs/issues/104
	mkdir "${T}/pkg-config" || die
	export PKG_CONFIG_PATH=${T}/pkg-config${PKG_CONFIG_PATH+:${PKG_CONFIG_PATH}}
	cat >> "${T}/pkg-config/bzip2.pc" <<-EOF || die
		Name: bzip2
		Version: 9999
		Description:
		Libs: -lbz2
	EOF
}

src_configure() {
	local myfeatures=(
		$(usev !telemetry avoid_stats)
	)

	cargo_src_configure
}

src_test() {
	local -x PATH=${T}/bin:${PATH}

	mkdir "${T}/bin" || die
	if ! has_version "www-client/firefox"; then
		# upstream expects "firefox" rather than "firefox-bin"
		ln -s "$(type -P firefox-bin)" "${T}/bin/firefox" || die
	fi

	cargo_src_test --no-fail-fast
}

src_install() {
	dobin "$(cargo_target_dir)"/selenium-manager
	einstalldocs
	dodoc README.md

	newenvd - 70selenium-manager <<-EOF || die
		SE_MANAGER_PATH="${EPREFIX}/usr/bin/selenium-manager"
	EOF
}