# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

CRATES="
	addr2line@0.25.1
	adler2@2.0.1
	aead@0.5.2
	aes-gcm@0.10.3
	aes@0.8.4
	ahash@0.8.12
	aho-corasick@1.1.5
	aliasable@0.1.3
	alloc-no-stdlib@2.0.4
	alloc-stdlib@0.2.4
	allocator-api2@0.2.21
	android_system_properties@0.1.6
	annotate-snippets@0.12.16
	annotated-string@0.3.1
	anstream@1.0.0
	anstyle-parse@1.0.0
	anstyle-query@1.1.5
	anstyle-wincon@3.0.11
	anstyle@1.0.14
	ar_archive_writer@0.5.3
	arc-swap@1.9.2
	array-const-fn-init@0.1.1
	arraydeque@0.5.1
	arrayref@0.3.9
	arrayvec@0.7.8
	assert_cmd@2.2.2
	assert_fs@1.1.4
	async-trait@0.1.92
	async_io_stream@0.3.3
	atomic-waker@1.1.2
	autocfg@1.5.1
	backon@1.6.0
	backtrace@0.3.76
	base16ct@1.0.0
	base64@0.22.1
	base64@0.23.1
	base64ct@1.8.3
	bindgen@0.70.1
	bitflags@1.3.2
	bitflags@2.13.1
	blake2@0.10.6
	blake3@1.8.6
	block-buffer@0.10.4
	block-buffer@0.12.1
	block2@0.6.2
	brotli-decompressor@2.5.1
	brotli@3.5.0
	bstr@1.13.1
	bumpalo@3.20.3
	byteorder@1.5.0
	bytes@1.12.1
	cc@1.4.2
	cesu8@1.1.0
	cexpr@0.6.0
	cf-rustracing-jaeger@1.2.2
	cf-rustracing@1.2.1
	cfg-if@1.0.4
	cfg_aliases@0.2.2
	chacha20@0.10.1
	chrono@0.4.45
	cipher@0.4.4
	clang-sys@1.9.1
	clap@4.6.6
	clap_builder@4.6.6
	clap_complete@4.6.9
	clap_derive@4.6.4
	clap_lex@1.1.0
	clap_mangen@0.2.33
	cmake@0.1.58
	cmov@0.5.4
	cobs@0.3.0
	colorchoice@1.0.5
	combine@4.6.7
	console@0.16.4
	const-oid@0.10.2
	constant_time_eq@0.4.2
	convert_case@0.10.0
	cordyceps@0.3.5
	core-foundation-sys@0.8.7
	core-foundation@0.10.1
	core-foundation@0.9.4
	cpufeatures@0.2.17
	cpufeatures@0.3.0
	crc32fast@1.5.1
	critical-section@1.2.0
	crossbeam-channel@0.5.16
	crossbeam-deque@0.8.7
	crossbeam-epoch@0.9.20
	crossbeam-queue@0.3.13
	crossbeam-utils@0.8.22
	crypto-common@0.1.7
	crypto-common@0.2.2
	ctr@0.9.2
	ctutils@0.4.2
	curve25519-dalek-derive@0.1.1
	curve25519-dalek@5.0.0
	daemonize@0.5.0
	daggy@0.8.1
	darling@0.20.11
	darling_core@0.20.11
	darling_macro@0.20.11
	data-encoding-macro-internal@0.1.19
	data-encoding-macro@0.1.21
	data-encoding@2.11.1
	der@0.8.1
	deranged@0.5.8
	derivative@2.2.0
	derive_builder@0.20.2
	derive_builder_core@0.20.2
	derive_builder_macro@0.20.2
	derive_more-impl@1.0.0
	derive_more-impl@2.1.1
	derive_more@1.0.0
	derive_more@2.1.1
	diatomic-waker@0.2.3
	difflib@0.4.0
	digest@0.10.7
	digest@0.11.3
	dispatch2@0.3.1
	displaydoc@0.2.7
	dlopen2@0.8.2
	drop_bomb@0.1.5
	dyn-clone@1.0.20
	ed25519-dalek@3.0.0
	ed25519@3.0.0
	educe@0.7.6
	either@1.17.0
	embedded-io@0.4.0
	embedded-io@0.6.1
	encode_unicode@1.0.0
	encoding_rs@0.8.35
	encoding_rs_io@0.1.8
	enum-assoc@1.3.0
	enum-ordinalize-derive@4.4.2
	enum-ordinalize@4.4.2
	equivalent@1.0.2
	errno@0.3.14
	extension-trait@1.0.2
	fastrand@2.5.0
	fiat-crypto@0.3.0
	find-msvc-tools@0.1.10
	fixedbitset@0.5.7
	flate2@1.1.9
	float-cmp@0.10.0
	fnv@1.0.7
	foldhash@0.2.0
	form_urlencoded@1.2.2
	futures-buffered@0.2.13
	futures-channel@0.3.34
	futures-core@0.3.34
	futures-executor@0.3.34
	futures-io@0.3.34
	futures-lite@2.6.1
	futures-macro@0.3.34
	futures-sink@0.3.34
	futures-task@0.3.34
	futures-util@0.3.34
	futures@0.3.34
	generator@0.8.9
	generic-array@0.14.7
	getrandom@0.2.17
	getrandom@0.3.4
	getrandom@0.4.3
	getset@0.1.7
	ghash@0.5.1
	gimli@0.32.3
	glob@0.3.4
	globset@0.4.20
	globwalk@0.9.1
	gloo-timers@0.3.0
	granit-parser@0.0.7
	h2@0.4.18
	hashbrown@0.12.3
	hashbrown@0.16.1
	hashbrown@0.17.1
	heck@0.4.1
	heck@0.5.0
	hermit-abi@0.5.2
	hex@0.4.3
	hi-doc-jumprope@1.2.1
	hi-doc@0.3.1
	hickory-net@0.26.1
	hickory-proto@0.26.1
	hickory-resolver@0.26.1
	hostname@0.4.2
	http-body-util@0.1.4
	http-body@1.1.0
	http@1.5.0
	httparse@1.10.1
	httpdate@1.0.3
	hybrid-array@0.4.14
	hyper-rustls@0.27.9
	hyper-util@0.1.20
	hyper@1.11.0
	iana-time-zone-haiku@0.1.2
	iana-time-zone@0.1.65
	icu_collections@2.2.0
	icu_locale_core@2.2.0
	icu_normalizer@2.2.0
	icu_normalizer_data@2.2.0
	icu_properties@2.2.0
	icu_properties_data@2.2.0
	icu_provider@2.2.0
	ident_case@1.0.1
	identity-hash@0.1.0
	idna@1.1.0
	idna_adapter@1.2.2
	ignore@0.4.33
	indexmap@1.9.3
	indexmap@2.14.0
	inout@0.1.4
	insta@1.48.0
	ipconfig@0.3.4
	ipnet@2.12.1
	ipset_derive@0.1.1
	iroh-base@1.0.3
	iroh-dns@1.0.3
	iroh-metrics-derive@1.0.1
	iroh-metrics@1.0.1
	iroh-relay@1.0.3
	iroh@1.0.3
	is_terminal_polyfill@1.70.2
	itertools@0.13.0
	itertools@0.14.0
	itoa@1.0.18
	jni-macros@0.22.4
	jni-sys-macros@0.4.1
	jni-sys@0.3.1
	jni-sys@0.4.1
	jni@0.21.1
	jni@0.22.4
	jobserver@0.1.35
	jrsonnet-gcmodule-derive@0.5.0
	jrsonnet-gcmodule@0.5.0
	js-sys@0.3.105
	keccak@0.2.1
	lazy_static@1.5.0
	libc@0.2.189
	libloading@0.8.9
	libnftables1-sys@1.0.0
	libz-ng-sys@1.1.29
	linux-raw-sys@0.12.1
	litemap@0.8.2
	local-ip-address@0.6.13
	lock_api@0.4.14
	log@0.4.33
	logos-codegen@0.16.1
	logos-derive@0.16.1
	logos@0.16.1
	loom@0.7.2
	lru-slab@0.1.2
	lru@0.16.4
	lru@0.18.2
	mac-addr@0.3.0
	matchers@0.2.0
	md5@0.8.1
	memchr@2.8.3
	memoffset@0.6.5
	minimal-lexical@0.2.1
	miniz_oxide@0.8.9
	mio@1.2.2
	moka@0.12.16
	n0-error-macros@1.0.0
	n0-error@1.0.0
	n0-future@0.3.2
	n0-watcher@1.0.0
	ndk-context@0.1.1
	neli-proc-macros@0.2.2
	neli@0.7.4
	netdev@0.45.0
	netlink-packet-core@0.8.2
	netlink-packet-route@0.31.0
	netlink-proto@0.12.1
	netlink-sys@0.8.8
	netwatch@0.19.1
	nftables@0.6.3
	nix@0.24.3
	nix@0.29.0
	nohash-hasher@0.2.0
	nom@7.1.3
	noq-proto@1.1.1
	noq-udp@1.1.1
	noq@1.1.1
	normalize-line-endings@0.3.0
	nu-ansi-term@0.50.3
	num-bigint@0.5.1
	num-conv@0.2.2
	num-integer@0.1.47
	num-traits@0.2.19
	num_cpus@1.17.0
	num_enum@0.7.6
	num_enum_derive@0.7.6
	objc2-core-foundation@0.3.2
	objc2-core-wlan@0.3.2
	objc2-encode@4.1.0
	objc2-foundation@0.3.2
	objc2-security-foundation@0.3.2
	objc2-security@0.3.2
	objc2-system-configuration@0.3.2
	objc2@0.6.4
	object@0.37.3
	object@0.39.1
	once_cell@1.21.4
	once_cell_polyfill@1.70.2
	opaque-debug@0.3.1
	openssl-probe@0.1.6
	openssl-probe@0.2.1
	ouroboros@0.18.5
	ouroboros_macro@0.18.5
	papaya@0.2.4
	parking@2.2.1
	parking_lot@0.12.5
	parking_lot_core@0.9.12
	paste@1.0.15
	pathdiff@0.2.3
	peg-macros@0.8.6
	peg-runtime@0.8.6
	peg@0.8.6
	pem-rfc7468@1.0.0
	percent-encoding@2.3.2
	petgraph@0.7.1
	pharos@0.5.3
	pin-project-internal@1.1.13
	pin-project-lite@0.2.17
	pin-project@1.1.13
	pingora-cache@0.8.1
	pingora-core@0.8.1
	pingora-error@0.8.1
	pingora-header-serde@0.8.1
	pingora-http@0.8.1
	pingora-lru@0.8.1
	pingora-pool@0.8.1
	pingora-proxy@0.8.1
	pingora-runtime@0.8.1
	pingora-timeout@0.8.1
	pkcs8@0.11.0
	pkg-config@0.3.33
	plist@1.10.0
	polyval@0.6.2
	portable-atomic@1.15.0
	postbag@0.4.3
	postcard-derive@0.2.2
	postcard@1.1.3
	potential_utf@0.1.5
	powerfmt@0.2.0
	ppv-lite86@0.2.21
	predicates-core@1.0.10
	predicates-tree@1.0.13
	predicates@3.1.4
	prefix-trie@0.10.1
	prefix-trie@0.8.4
	prettyplease@0.2.37
	proc-macro-crate@3.5.0
	proc-macro2-diagnostics@0.10.1
	proc-macro2@1.0.107
	prometheus@0.13.4
	protobuf@2.28.0
	psm@0.1.32
	quick-xml@0.41.0
	quote@1.0.47
	r-efi@5.3.0
	r-efi@6.0.0
	rand@0.10.2
	rand@0.8.7
	rand@0.9.5
	rand_chacha@0.3.1
	rand_chacha@0.9.0
	rand_core@0.10.1
	rand_core@0.6.4
	rand_core@0.9.5
	rand_pcg@0.10.2
	random_color@1.1.0
	range-map@0.2.0
	redox_syscall@0.5.18
	ref-cast-impl@1.0.26
	ref-cast@1.0.26
	regex-automata@0.4.18
	regex-syntax@0.8.11
	regex@1.13.1
	remoc@0.18.3
	remoc_macro@0.18.3
	reqwest@0.13.5
	resolv-conf@0.7.6
	ring@0.17.14
	rmp-serde@1.3.1
	rmp@0.8.15
	roff@1.1.1
	rust_decimal@1.42.1
	rustc-demangle@0.1.28
	rustc-hash@1.1.0
	rustc-hash@2.1.3
	rustc_version@0.4.1
	rustix@1.1.4
	rustls-native-certs@0.8.4
	rustls-pki-types@1.15.1
	rustls-platform-verifier-android@0.1.1
	rustls-platform-verifier@0.6.2
	rustls-webpki@0.103.14
	rustls@0.23.43
	rustversion@1.0.23
	ryu@1.0.23
	same-file@1.0.6
	saphyr-parser-bw@0.0.611
	schannel@0.1.29
	schemars@1.2.2
	schemars_derive@1.2.2
	scoped-tls@1.0.1
	scopeguard@1.2.0
	security-framework-sys@2.17.0
	security-framework@3.7.0
	seize@0.5.1
	semver@1.0.28
	send_wrapper@0.6.0
	serde-saphyr@0.0.25
	serde-saphyr@0.0.29
	serde@1.0.229
	serde_bytes@0.11.19
	serde_core@1.0.229
	serde_derive@1.0.229
	serde_derive_internals@0.30.0
	serde_json@1.0.151
	serde_json_borrow@0.9.0
	serde_path_to_error@0.1.20
	serde_yaml@0.9.34+deprecated
	serdect@0.4.3
	sfv@0.10.4
	sha1@0.11.0
	sha1_smol@1.0.1
	sha2@0.11.0
	sha3@0.12.0
	sharded-slab@0.1.7
	shlex@1.3.0
	shlex@2.0.1
	signal-hook-registry@1.4.8
	signature@3.0.0
	simd-adler32@0.3.10
	simd_cesu8@1.2.0
	simdutf8@0.1.5
	similar@2.7.0
	simple-dns@0.11.3
	slab@0.4.12
	smallvec@1.15.2
	socket2@0.6.5
	sorted-index-buffer@0.2.1
	spez@0.1.2
	spin@0.10.1
	spki@0.8.0
	sponge-cursor@0.1.0
	stable_deref_trait@1.2.1
	stacker@0.1.25
	static_assertions@1.1.0
	str_indices@0.4.4
	strsim@0.11.1
	strum@0.26.3
	strum@0.27.2
	strum@0.28.0
	strum_macros@0.26.4
	strum_macros@0.27.2
	strum_macros@0.28.0
	subtle@2.6.1
	syn-dissect-closure@0.2.1
	syn@1.0.109
	syn@2.0.119
	syn@3.0.3
	sync_wrapper@1.0.2
	synstructure@0.13.2
	system-configuration-sys@0.6.0
	system-configuration@0.7.0
	tagptr@0.2.0
	tempfile@3.27.0
	termtree@0.5.1
	thiserror-impl@1.0.69
	thiserror-impl@2.0.18
	thiserror@1.0.69
	thiserror@2.0.18
	thread_local@1.1.10
	thrift_codec@0.3.2
	time-core@0.1.9
	time-macros@0.2.32
	time@0.3.55
	tinystr@0.8.3
	tinyvec@1.12.0
	tinyvec_macros@0.1.1
	tokio-macros@2.7.2
	tokio-rustls@0.26.4
	tokio-stream@0.1.19
	tokio-test@0.4.5
	tokio-util@0.7.19
	tokio-websockets@0.13.3
	tokio@1.53.1
	toml_datetime@1.1.1+spec-1.1.0
	toml_edit@0.25.13+spec-1.1.0
	toml_parser@1.1.3+spec-1.1.0
	tower-http@0.6.11
	tower-layer@0.3.3
	tower-service@0.3.3
	tower@0.5.3
	tracing-attributes@0.1.31
	tracing-core@0.1.36
	tracing-log@0.2.0
	tracing-subscriber@0.3.23
	tracing@0.1.44
	trackable@1.3.0
	trackable_derive@1.0.0
	try-lock@0.2.5
	typenum@1.20.1
	unicase@2.9.0
	unicode-box-drawing@0.3.1
	unicode-ident@1.0.24
	unicode-segmentation@1.13.3
	unicode-width@0.2.2
	unicode-xid@0.2.6
	universal-hash@0.5.1
	unsafe-libyaml@0.2.11
	untrusted@0.9.0
	url@2.5.8
	utf8_iter@1.0.4
	utf8parse@0.2.2
	uuid@1.24.0
	valuable@0.1.1
	version_check@0.9.5
	wait-timeout@0.2.1
	walkdir@2.5.0
	want@0.3.1
	wasi@0.11.1+wasi-snapshot-preview1
	wasip2@1.0.4+wasi-0.2.12
	wasm-bindgen-futures@0.4.78
	wasm-bindgen-macro-support@0.2.128
	wasm-bindgen-macro@0.2.128
	wasm-bindgen-shared@0.2.128
	wasm-bindgen@0.2.128
	wasm-streams@0.5.0
	web-sys@0.3.105
	web-time@1.1.0
	webpki-root-certs@1.0.9
	webpki-roots@1.0.9
	widestring@1.2.1
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-util@0.1.11
	winapi-x86_64-pc-windows-gnu@0.4.0
	winapi@0.3.9
	windows-collections@0.3.2
	windows-core@0.62.2
	windows-future@0.3.2
	windows-implement@0.60.2
	windows-interface@0.59.3
	windows-link@0.2.1
	windows-numerics@0.3.1
	windows-registry@0.6.1
	windows-result@0.4.1
	windows-strings@0.5.1
	windows-sys@0.45.0
	windows-sys@0.52.0
	windows-sys@0.59.0
	windows-sys@0.61.2
	windows-targets@0.42.2
	windows-targets@0.52.6
	windows-threading@0.2.1
	windows@0.62.2
	windows_aarch64_gnullvm@0.42.2
	windows_aarch64_gnullvm@0.52.6
	windows_aarch64_msvc@0.42.2
	windows_aarch64_msvc@0.52.6
	windows_i686_gnu@0.42.2
	windows_i686_gnu@0.52.6
	windows_i686_gnullvm@0.52.6
	windows_i686_msvc@0.42.2
	windows_i686_msvc@0.52.6
	windows_x86_64_gnu@0.42.2
	windows_x86_64_gnu@0.52.6
	windows_x86_64_gnullvm@0.42.2
	windows_x86_64_gnullvm@0.52.6
	windows_x86_64_msvc@0.42.2
	windows_x86_64_msvc@0.52.6
	winnow@1.0.4
	wit-bindgen@0.57.1
	wmi@0.18.4
	writeable@0.6.3
	ws_stream_wasm@0.7.5
	yansi@1.0.1
	yoke-derive@0.8.2
	yoke@0.8.3
	zerocopy-derive@0.8.56
	zerocopy@0.8.56
	zerofrom-derive@0.1.7
	zerofrom@0.1.8
	zeroize@1.9.0
	zeroize_derive@1.5.0
	zerotrie@0.2.4
	zerovec-derive@0.11.3
	zerovec@0.11.6
	zmij@1.0.23
	zstd-safe@7.2.4
	zstd-sys@2.0.16+zstd.1.5.7
	zstd@0.13.3
"

declare -A GIT_CRATES=(
	[ipset]='https://github.com/ppom0/ipset;6b3b24a1f1a07c27c53aac3cb619982ba6bd0c32;ipset-%commit%'
	[jrsonnet-evaluator]='https://github.com/deltarocks/jrsonnet;b9d891c46e9e7d87e9aeb0765b44c416bae7645b;jrsonnet-%commit%/crates/jrsonnet-evaluator'
	[jrsonnet-interner]='https://github.com/deltarocks/jrsonnet;b9d891c46e9e7d87e9aeb0765b44c416bae7645b;jrsonnet-%commit%/crates/jrsonnet-interner'
	[jrsonnet-ir-parser]='https://github.com/deltarocks/jrsonnet;b9d891c46e9e7d87e9aeb0765b44c416bae7645b;jrsonnet-%commit%/crates/jrsonnet-ir-parser'
	[jrsonnet-ir]='https://github.com/deltarocks/jrsonnet;b9d891c46e9e7d87e9aeb0765b44c416bae7645b;jrsonnet-%commit%/crates/jrsonnet-ir'
	[jrsonnet-lexer]='https://github.com/deltarocks/jrsonnet;b9d891c46e9e7d87e9aeb0765b44c416bae7645b;jrsonnet-%commit%/crates/jrsonnet-lexer'
	[jrsonnet-macros]='https://github.com/deltarocks/jrsonnet;b9d891c46e9e7d87e9aeb0765b44c416bae7645b;jrsonnet-%commit%/crates/jrsonnet-macros'
	[jrsonnet-stdlib]='https://github.com/deltarocks/jrsonnet;b9d891c46e9e7d87e9aeb0765b44c416bae7645b;jrsonnet-%commit%/crates/jrsonnet-stdlib'
	[jrsonnet-types]='https://github.com/deltarocks/jrsonnet;b9d891c46e9e7d87e9aeb0765b44c416bae7645b;jrsonnet-%commit%/crates/jrsonnet-types'
)

inherit cargo shell-completion systemd

DESCRIPTION="Scan logs and take action"
HOMEPAGE="https://reaction.ppom.me"
SRC_URI="
	https://framagit.org/ppom/${PN}/-/archive/v${PV}/${PN}-v${PV}.tar.gz
	${CARGO_CRATE_URIS}
"
S="$WORKDIR/${PN}-v${PV}"

LICENSE="AGPL-3"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD-2 BSD
	CDLA-Permissive-2.0 GPL-2 ISC MIT Unicode-3.0 Unlicense ZLIB
"
SLOT="0"
KEYWORDS="~amd64"
RUST_MIN_VER="1.91.0"

src_prepare() {
	#Install man & completions regardless of profile
	sed -i 's/var_os(.PROFILE.).*/true {/' \
		"${S}/build.rs" || die "sed build.rs failed"
	default
}

src_test() {
	#Issue https://framagit.org/ppom/reaction/-/work_items/153
	rm "${S}/tests/plugin_virtual.rs"
	default
}

src_install() {
	cargo_src_install
	local target_dir="$(cargo_target_dir)"
	newbashcomp ${target_dir}/${PN}.bash ${PN}
	dofishcomp ${target_dir}/${PN}.fish
	dozshcomp ${target_dir}/_${PN}
	systemd_dounit "${FILESDIR}/systemd/${PN}.service"
	doman ${target_dir}/*.[0-9]
	doinitd "${FILESDIR}/init.d/${PN}"
	keepdir /var/lib/${PN}
	keepdir /etc/${PN}.d
}