1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python2_7 python3_{5,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 cryptsetup 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}.
34 caps? ( sys-libs/libcap-ng )
35 cramfs? ( sys-libs/zlib:= )
36 cryptsetup? ( sys-fs/cryptsetup )
37 ncurses? ( >=sys-libs/ncurses-5.2-r2:0=[unicode?] )
38 nls? ( virtual/libintl[${MULTILIB_USEDEP}] )
40 python? ( ${PYTHON_DEPS} )
41 readline? ( sys-libs/readline:0= )
42 selinux? ( >=sys-libs/libselinux-2.2.2-r4[${MULTILIB_USEDEP}] )
43 slang? ( sys-libs/slang )
44 !build? ( systemd? ( sys-apps/systemd ) )
45 udev? ( virtual/libudev:= )"
48 nls? ( sys-devel/gettext )
49 test? ( sys-devel/bc )
52 hardlink? ( !app-arch/hardlink )
53 logger? ( !>=app-admin/sysklogd-2.0[logger] )
55 !sys-apps/coreutils[kill]
56 !sys-process/procps[kill]
59 !<sys-apps/shadow-4.7-r2
60 !>=sys-apps/shadow-4.7-r2[su]
63 !sys-process/schedutils
65 !<sys-apps/sysvinit-2.88-r7
66 !<sys-libs/e2fsprogs-libs-1.41.8
67 !<sys-fs/e2fsprogs-1.41.8
68 !<app-shells/bash-completion-2.7-r1"
70 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
71 RESTRICT="!test? ( test )"
73 S="${WORKDIR}/${MY_P}"
78 # Prevent uuidd test failure due to socket path limit. #593304
80 -e "s|UUIDD_SOCKET=\"\$(mktemp -u \"\${TS_OUTDIR}/uuiddXXXXXXXXXXXXX\")\"|UUIDD_SOCKET=\"\$(mktemp -u \"${T}/uuiddXXXXXXXXXXXXX.sock\")\"|g" \
81 tests/ts/uuid/uuidd || die "Failed to fix uuidd test"
83 if ! use userland_GNU; then
84 # test runner is using GNU-specific xargs call
85 sed -i -e 's:xargs:gxargs:' tests/run.sh || die
86 # test requires util-linux uuidgen (which we don't build)
87 rm tests/ts/uuid/oids || die
90 if [[ ${PV} == 9999 ]] ; then
95 # Undo bad ncurses handling by upstream. #601530
97 -e '/NCURSES_/s:(ncursesw?)[56]-config:$PKG_CONFIG \1:' \
98 -e 's:(ncursesw?)[56]-config --version:$PKG_CONFIG --exists --print-errors \1:' \
104 lfs_fallocate_test() {
105 # Make sure we can use fallocate with LFS #300307
106 cat <<-EOF > "${T}"/fallocate.${ABI}.c
109 main() { return fallocate(0, 0, 0, 0); }
112 $(tc-getCC) ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} "${T}"/fallocate.${ABI}.c -o /dev/null >/dev/null 2>&1 \
113 || export ac_cv_func_fallocate=no
114 rm -f "${T}"/fallocate.${ABI}.c
120 --disable-all-programs
121 --disable-bash-completion
122 --without-systemdsystemunitdir
125 if use userland_GNU; then
132 mkdir "${BUILD_DIR}" || die
133 pushd "${BUILD_DIR}" >/dev/null || die
134 ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
135 popd >/dev/null || die
138 multilib_src_configure() {
140 # The scanf test in a run-time test which fails while cross-compiling.
141 # Blindly assume a POSIX setup since we require libmount, and libmount
142 # itself fails when the scanf test fails. #531856
143 tc-is-cross-compiler && export scanf_cv_alloc_modifier=ms
144 export ac_cv_header_security_pam_misc_h=$(multilib_native_usex pam) #485486
145 export ac_cv_header_security_pam_appl_h=$(multilib_native_usex pam) #545042
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)
197 $(use_with cryptsetup)
201 --disable-all-programs
202 --disable-bash-completion
203 --without-systemdsystemunitdir
207 --enable-libsmartcols
210 if use userland_GNU; then
211 # those libraries don't work on *BSD
217 ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
219 if multilib_is_native_abi && use python; then
220 python_foreach_impl python_configure
225 pushd "${BUILD_DIR}" >/dev/null || die
227 popd >/dev/null || die
230 multilib_src_compile() {
233 if multilib_is_native_abi && use python; then
234 python_foreach_impl python_compile
239 pushd "${BUILD_DIR}" >/dev/null || die
240 emake check TS_OPTS="--parallel=$(makeopts_jobs) --nonroot"
241 popd >/dev/null || die
244 multilib_src_test() {
245 emake check TS_OPTS="--parallel=$(makeopts_jobs) --nonroot"
246 if multilib_is_native_abi && use python; then
247 python_foreach_impl python_test
252 pushd "${BUILD_DIR}" >/dev/null || die
253 emake DESTDIR="${D}" install
255 popd >/dev/null || die
258 multilib_src_install() {
259 if multilib_is_native_abi && use python; then
260 python_foreach_impl python_install
263 # This needs to be called AFTER python_install call (#689190)
264 emake DESTDIR="${D}" install
266 if multilib_is_native_abi && use userland_GNU; then
268 gen_usr_ldscript -a blkid fdisk mount smartcols uuid
272 multilib_src_install_all() {
273 dodoc AUTHORS NEWS README* Documentation/{TODO,*.txt,releases/*}
275 # e2fsprogs-libs didnt install .la files, and .pc work fine
276 find "${ED}" -name "*.la" -delete || die
278 if ! use userland_GNU; then
280 # TODO: figure out a good way to keep them
281 rm "${ED}"/usr/share/man/man3/uuid* || die
285 newpamd "${FILESDIR}/runuser.pamd" runuser
286 newpamd "${FILESDIR}/runuser-l.pamd" runuser-l
290 # Bash completion for "runuser" command is provided by same file which
291 # would also provide bash completion for "su" command. However, we don't
292 # use "su" command from this package.
293 # This triggers a known QA warning which we ignore for now to magically
294 # keep bash completion for "su" command which shadow package does not
299 if ! use tty-helpers; then
300 elog "The mesg/wall/write tools have been disabled due to USE=-tty-helpers."
303 if [[ -z ${REPLACING_VERSIONS} ]]; then
304 elog "The agetty util now clears the terminal by default. You"
305 elog "might want to add --noclear to your /etc/inittab lines."