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

# Auto-Generated by cargo-ebuild 0.5.4

EAPI=8

CRATES="
	ahash-0.7.6
	aho-corasick-0.7.20
	ariadne-0.1.5
	atty-0.2.14
	autocfg-1.1.0
	bincode-1.3.3
	bitflags-1.3.2
	cc-1.0.79
	cfg-if-1.0.0
	chumsky-0.9.2
	clap-4.0.22
	clap_derive-4.0.21
	clap_lex-0.3.2
	colored_json-3.0.1
	dyn-clone-1.0.11
	either-1.8.1
	env_logger-0.10.0
	fastrand-1.9.0
	getrandom-0.2.8
	hashbrown-0.12.3
	heck-0.4.1
	hermit-abi-0.1.19
	hifijson-0.2.0
	indexmap-1.9.2
	instant-0.1.12
	itertools-0.10.5
	itoa-1.0.6
	libc-0.2.139
	libmimalloc-sys-0.1.30
	log-0.4.17
	memchr-2.5.0
	memmap2-0.5.10
	mimalloc-0.1.34
	once_cell-1.17.1
	os_str_bytes-6.4.1
	proc-macro-error-1.0.4
	proc-macro-error-attr-1.0.4
	proc-macro2-1.0.51
	quote-1.0.23
	redox_syscall-0.2.16
	regex-1.7.1
	remove_dir_all-0.5.3
	ryu-1.0.13
	serde-1.0.152
	serde_derive-1.0.152
	serde_json-1.0.94
	strsim-0.10.0
	syn-1.0.109
	tempfile-3.3.0
	termcolor-1.2.0
	unicode-ident-1.0.8
	version_check-0.9.4
	wasi-0.11.0+wasi-snapshot-preview1
	winapi-0.3.9
	winapi-i686-pc-windows-gnu-0.4.0
	winapi-util-0.1.5
	winapi-x86_64-pc-windows-gnu-0.4.0
	yansi-0.5.1
"

declare -A GIT_CRATES=(
	[regex-syntax]="https://github.com/01mf02/regex;90eebbdb9396ca10510130327073a3d596674d04;regex-%commit%/regex-syntax"
)

inherit cargo

DESCRIPTION="Just another JSON query tool"
# Double check the homepage as the cargo_metadata crate
# does not provide this value so instead repository is used
HOMEPAGE="https://github.com/01mf02/jaq"
SRC_URI="
	https://github.com/01mf02/jaq/archive/refs/tags/v${PV}.tar.gz -> ${P}.gh.tar.gz
	$(cargo_crate_uris)
"

# License set may be more restrictive as OR is not respected
# use cargo-license for a more accurate license picture
LICENSE="Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD Boost-1.0 EPL-2.0 MIT Unicode-DFS-2016 Unlicense"
SLOT="0"
KEYWORDS="~amd64"

BDEPEND="
	app-misc/yq
"

QA_FLAGS_IGNORED="usr/bin/jaq"

DOCS=(
	README.md
	examples/
)

src_prepare() {
	local crate crate_uri commit crate_dir sedexpr ifs
	for crate in "${!GIT_CRATES[@]}"; do
		IFS=';' read -r crate_uri commit crate_dir <<< "${GIT_CRATES[${crate}]}"
		: "${crate_dir:=${crate}-%commit%}"

		# replace git patch for crates.io
		sedexpr+="s@^(${crate}[[:space:]]*=[[:space:]]*[{][[:space:]]*.*)[[:space:]]*git[[:space:]]*=[[:space:]]*[\"'][[:graph:]]+[\"'](,|)(.*[[:space:]]*[}])@\\1path = \"${WORKDIR}/${crate_dir//%commit%/${commit}}\",\\3 @;"

		# get rid of the rev=
		sedexpr+="s@^(${crate}[[:space:]]*=[[:space:]]*[{][[:space:]]*.*)[[:space:]]*rev[[:space:]]*=[[:space:]]*[\"'][[:alnum:]]+[\"'](,|[[:space:]]*)(.*[[:space:]]*[}])@\\1\\3@;"

		# make sure we don't have a trailing comma
		sedexpr+="s@^(${crate}[[:space:]]*=[[:space:]]*[{][[:space:]]*.*),([[:space:]]*[}])@\\1\\2@;"
	done

	sed -r -e "${sedexpr}" -i Cargo.toml || die

	default
}

src_install() {
	pushd "${S}/jaq" >/dev/null || die
	cargo_src_install
	popd >/dev/null || die
	default
}