summaryrefslogtreecommitdiff
path: root/sys-apps/uutils-coreutils/uutils-coreutils-0.8.0-r1.ebuild
blob: a20abe2d9cb937c2cca297e9205de7a60a26ddf2 (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
# Copyright 2022-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Autogenerated by pycargoebuild 0.6.2

EAPI=8

CRATES="
"

RUST_MIN_VER="1.88.0"
LLVM_COMPAT=( {17..22} )
inherit cargo flag-o-matic llvm-r2 multiprocessing

DESCRIPTION="GNU coreutils rewritten in Rust"
HOMEPAGE="https://uutils.github.io/coreutils/ https://github.com/uutils/coreutils"

if [[ ${PV} == 9999 ]] ; then
	EGIT_REPO_URI="https://github.com/uutils/coreutils"
	inherit git-r3
elif [[ ${PV} == *_p* ]] ; then
	COREUTILS_COMMIT=""
	SRC_URI="https://github.com/uutils/coreutils/archive/${COREUTILS_COMMIT}.tar.gz -> ${P}.tar.gz"
	S="${WORKDIR}"/coreutils-${COREUTILS_COMMIT}
else
	SRC_URI="https://github.com/uutils/coreutils/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz"
	S="${WORKDIR}"/coreutils-${PV}

	KEYWORDS="~amd64 ~arm64 ~ppc64"
fi

if [[ ${PV} != 9999 ]] ; then
	SRC_URI+="
		https://github.com/gentoo-crate-dist/coreutils/releases/download/${PV}/coreutils-${PV}-crates.tar.xz
	"
fi

LICENSE="MIT"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 BSD-2 BSD Boost-1.0 CC0-1.0 ISC MIT Unicode-3.0 ZLIB
"
SLOT="0"
IUSE="debug selinux test"
RESTRICT="!test? ( test )"

DEPEND="
	dev-libs/oniguruma:=
	selinux? ( sys-libs/libselinux )
"
RDEPEND="${DEPEND}"
BDEPEND="
	test? ( dev-util/cargo-nextest )
	selinux? (
		$(llvm_gen_dep '
			llvm-core/clang:${LLVM_SLOT}
		')
	)
"
QA_FLAGS_IGNORED=".*"

pkg_setup() {
	llvm-r2_pkg_setup
	rust_pkg_setup
}

src_unpack() {
	if [[ ${PV} == 9999 ]] ; then
		git-r3_src_unpack
		cargo_live_src_unpack
	else
		cargo_src_unpack
	fi
}

src_prepare() {
	default
	# This is should be a set of env vars in upstream CI
	rm -f "${S}/.cargo/config.toml"

	# Upstream convention for bash-completions clashes with our own
	sed -i -e 's:\.bash::' "${S}/GNUmakefile" || die
}

src_compile() {
	# normally cargo_src_compile sets this for us, but we don't use it
	filter-lto

	# By default, the crate uses a system version if it can. This just guarantees
	# that it will error out instead of building a vendored copy.
	export RUSTONIG_SYSTEM_LIBONIG=1

	makeargs=(
		# Disable output synchronisation as make calls cargo
		-Onone

		V=1

		PROFILE=$(usex debug debug release)

		PREFIX="${EPREFIX}/usr"
		PROG_PREFIX="uu-"
		MULTICALL=y
		MANDIR="/share/man/man1"

		SELINUX_ENABLED=$(usex selinux 1 0)

		# pinky, uptime, users, and who require utmpx (not available on musl)
		# bug #832868
		SKIP_UTILS="$(usev elibc_musl "pinky uptime users who")"

		# bug #963516
		LIBSTDBUF_DIR="${EPREFIX}/usr/libexec/${PN}"
	)

	emake "${makeargs[@]}"
}

src_test() {
	local -x RUST_BACKTRACE=full
	local -x NEXTEST_TEST_THREADS="$(makeopts_jobs)"

	# Nicer output for nextest vs test
	emake "${makeargs[@]}" \
		CARGOFLAGS="${CARGOFLAGS} $(usev !debug --release)" \
		TEST_NO_FAIL_FAST="--no-fail-fast" \
		nextest
}

src_install() {
	emake "${makeargs[@]}" DESTDIR="${D}" install
}