1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python3_{6,7} )
8 inherit toolchain-funcs libtool flag-o-matic bash-completion-r1 usr-ldscript \
9 pam python-r1 multilib-minimal multiprocessing systemd
14 if [[ ${PV} == 9999 ]] ; then
15 inherit git-r3 autotools
16 EGIT_REPO_URI="https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git"
18 [[ "${PV}" = *_rc* ]] || \
19 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sh ~sparc ~x86 ~amd64-linux ~x86-linux"
20 SRC_URI="https://www.kernel.org/pub/linux/utils/util-linux/v${PV:0:4}/${MY_P}.tar.xz"
23 DESCRIPTION="Various useful Linux utilities"
24 HOMEPAGE="https://www.kernel.org/pub/linux/utils/util-linux/ https://github.com/karelzak/util-linux"
26 LICENSE="GPL-2 LGPL-2.1 BSD-4 MIT public-domain"
28 IUSE="build caps +cramfs fdformat hardlink kill +logger ncurses nls pam python +readline selinux slang static-libs su +suid systemd test tty-helpers udev unicode userland_GNU"
30 # Most lib deps here are related to programs rather than our libs,
31 # so we rarely need to specify ${MULTILIB_USEDEP}.
33 caps? ( sys-libs/libcap-ng )
34 cramfs? ( sys-libs/zlib:= )
35 ncurses? ( >=sys-libs/ncurses-5.2-r2:0=[unicode?] )
36 nls? ( virtual/libintl[${MULTILIB_USEDEP}] )
38 python? ( ${PYTHON_DEPS} )
39 readline? ( sys-libs/readline:0= )
40 selinux? ( >=sys-libs/libselinux-2.2.2-r4[${MULTILIB_USEDEP}] )
41 slang? ( sys-libs/slang )
42 !build? ( systemd? ( sys-apps/systemd ) )
43 udev? ( virtual/libudev:= )"
46 nls? ( sys-devel/gettext )
47 test? ( sys-devel/bc )
54 hardlink? ( !app-arch/hardlink )
55 logger? ( !>=app-admin/sysklogd-2.0[logger] )
57 !sys-apps/coreutils[kill]
58 !sys-process/procps[kill]
61 !<sys-apps/shadow-4.7-r2
62 !>=sys-apps/shadow-4.7-r2[su]
65 !sys-process/schedutils
67 !<sys-apps/sysvinit-2.88-r7
68 !<sys-libs/e2fsprogs-libs-1.41.8
69 !<sys-fs/e2fsprogs-1.41.8
70 !<app-shells/bash-completion-2.7-r1"
72 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
73 RESTRICT="!test? ( test )"
75 S="${WORKDIR}/${MY_P}"
80 # Prevent uuidd test failure due to socket path limit. #593304
82 -e "s|UUIDD_SOCKET=\"\$(mktemp -u \"\${TS_OUTDIR}/uuiddXXXXXXXXXXXXX\")\"|UUIDD_SOCKET=\"\$(mktemp -u \"${T}/uuiddXXXXXXXXXXXXX.sock\")\"|g" \
83 tests/ts/uuid/uuidd || die "Failed to fix uuidd test"
85 if ! use userland_GNU; then
86 # test runner is using GNU-specific xargs call
87 sed -i -e 's:xargs:gxargs:' tests/run.sh || die
88 # test requires util-linux uuidgen (which we don't build)
89 rm tests/ts/uuid/oids || die
92 if [[ ${PV} == 9999 ]] ; then
100 lfs_fallocate_test() {
101 # Make sure we can use fallocate with LFS #300307
102 cat <<-EOF > "${T}"/fallocate.${ABI}.c
105 main() { return fallocate(0, 0, 0, 0); }
108 $(tc-getCC) ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} "${T}"/fallocate.${ABI}.c -o /dev/null >/dev/null 2>&1 \
109 || export ac_cv_func_fallocate=no
110 rm -f "${T}"/fallocate.${ABI}.c
116 --disable-all-programs
117 --disable-bash-completion
118 --without-systemdsystemunitdir
121 if use userland_GNU; then
128 mkdir "${BUILD_DIR}" || die
129 pushd "${BUILD_DIR}" >/dev/null || die
130 ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
131 popd >/dev/null || die
134 multilib_src_configure() {
136 # The scanf test in a run-time test which fails while cross-compiling.
137 # Blindly assume a POSIX setup since we require libmount, and libmount
138 # itself fails when the scanf test fails. #531856
139 tc-is-cross-compiler && export scanf_cv_alloc_modifier=ms
140 export ac_cv_header_security_pam_misc_h=$(multilib_native_usex pam) #485486
141 export ac_cv_header_security_pam_appl_h=$(multilib_native_usex pam) #545042
143 # Undo bad ncurses handling by upstream. Fall back to pkg-config. #601530
144 export NCURSES6_CONFIG=false NCURSES5_CONFIG=false
145 export NCURSESW6_CONFIG=false NCURSESW5_CONFIG=false
147 # configure args shared by python and non-python builds
149 --enable-fs-paths-extra="${EPREFIX}/usr/sbin:${EPREFIX}/bin:${EPREFIX}/usr/bin"
154 --with-bashcompletiondir="$(get_bashcompdir)"
156 $(multilib_native_use_enable suid makeinstall-chown)
157 $(multilib_native_use_enable suid makeinstall-setuid)
158 $(multilib_native_use_with readline)
159 $(multilib_native_use_with slang)
160 $(multilib_native_use_with systemd)
161 $(multilib_native_use_with udev)
162 $(multilib_native_usex ncurses "$(use_with unicode ncursesw)" '--without-ncursesw')
163 $(multilib_native_usex ncurses "$(use_with !unicode ncurses)" '--without-ncurses')
164 $(tc-has-tls || echo --disable-tls)
166 $(use_enable unicode widechar)
167 $(use_enable static-libs static)
168 $(use_with ncurses tinfo)
171 # build programs only on GNU, on *BSD we want libraries only
172 if multilib_is_native_abi && use userland_GNU; then
179 --enable-bash-completion
186 --with-systemdsystemunitdir="$(systemd_get_systemunitdir)"
187 $(use_enable caps setpriv)
189 $(use_enable fdformat)
190 $(use_enable hardlink)
194 $(use_enable tty-helpers mesg)
195 $(use_enable tty-helpers wall)
196 $(use_enable tty-helpers write)
200 --disable-all-programs
201 --disable-bash-completion
202 --without-systemdsystemunitdir
206 --enable-libsmartcols
209 if use userland_GNU; then
210 # those libraries don't work on *BSD
216 ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
218 if multilib_is_native_abi && use python; then
219 python_foreach_impl python_configure
224 pushd "${BUILD_DIR}" >/dev/null || die
226 popd >/dev/null || die
229 multilib_src_compile() {
232 if multilib_is_native_abi && use python; then
233 python_foreach_impl python_compile
238 pushd "${BUILD_DIR}" >/dev/null || die
239 emake check TS_OPTS="--parallel=$(makeopts_jobs) --nonroot"
240 popd >/dev/null || die
243 multilib_src_test() {
244 emake check TS_OPTS="--parallel=$(makeopts_jobs) --nonroot"
245 if multilib_is_native_abi && use python; then
246 python_foreach_impl python_test
251 pushd "${BUILD_DIR}" >/dev/null || die
252 emake DESTDIR="${D}" install
254 popd >/dev/null || die
257 multilib_src_install() {
258 if multilib_is_native_abi && use python; then
259 python_foreach_impl python_install
262 # This needs to be called AFTER python_install call (#689190)
263 emake DESTDIR="${D}" install
265 if multilib_is_native_abi && use userland_GNU; then
267 gen_usr_ldscript -a blkid fdisk mount smartcols uuid
271 multilib_src_install_all() {
272 dodoc AUTHORS NEWS README* Documentation/{TODO,*.txt,releases/*}
274 # e2fsprogs-libs didnt install .la files, and .pc work fine
275 find "${ED}" -name "*.la" -delete || die
277 if ! use userland_GNU; then
279 # TODO: figure out a good way to keep them
280 rm "${ED}"/usr/share/man/man3/uuid* || die
284 newpamd "${FILESDIR}/runuser.pamd" runuser
285 newpamd "${FILESDIR}/runuser-l.pamd" runuser-l
289 # Bash completion for "runuser" command is provided by same file which
290 # would also provide bash completion for "su" command. However, we don't
291 # use "su" command from this package.
292 # This triggers a known QA warning which we ignore for now to magically
293 # keep bash completion for "su" command which shadow package does not
298 if ! use tty-helpers; then
299 elog "The mesg/wall/write tools have been disabled due to USE=-tty-helpers."
302 if [[ -z ${REPLACING_VERSIONS} ]]; then
303 elog "The agetty util now clears the terminal by default. You"
304 elog "might want to add --noclear to your /etc/inittab lines."