1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python3_6 )
8 inherit eutils flag-o-matic python-any-r1 toolchain-funcs
11 DESCRIPTION="Standard GNU utilities (chmod, cp, dd, ls, sort, tr, head, wc, who,...)"
12 HOMEPAGE="https://www.gnu.org/software/coreutils/"
13 SRC_URI="mirror://gnu/${PN}/${P}.tar.xz
14 mirror://gentoo/${P}-patches-${PATCH_VER}.tar.xz
15 https://dev.gentoo.org/~polynomial-c/dist/${P}-patches-${PATCH_VER}.tar.xz"
19 KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 m68k ~mips ppc ppc64 s390 sparc x86 ~x86-linux"
20 IUSE="acl caps gmp hostname kill multicall nls selinux +split-usr static test userland_BSD vanilla xattr"
21 RESTRICT="!test? ( test )"
23 LIB_DEPEND="acl? ( sys-apps/acl[static-libs] )
24 caps? ( sys-libs/libcap )
25 gmp? ( dev-libs/gmp:=[static-libs] )
26 xattr? ( !userland_BSD? ( sys-apps/attr[static-libs] ) )"
27 RDEPEND="!static? ( ${LIB_DEPEND//\[static-libs]} )
28 selinux? ( sys-libs/libselinux )
29 nls? ( virtual/libintl )"
31 static? ( ${LIB_DEPEND} )
40 $(python_gen_any_dep 'dev-python/pyinotify[${PYTHON_USEDEP}]')
43 hostname? ( !sys-apps/net-tools[hostname] )
45 !sys-apps/util-linux[kill]
46 !sys-process/procps[kill]
49 !<sys-apps/util-linux-2.13
50 !<sys-apps/sandbox-2.10-r4
54 !<app-forensics/tct-1.18-r1
55 !<net-fs/netatalk-2.0.3-r4"
58 has_version --host-root "dev-python/pyinotify[${PYTHON_USEDEP}]"
63 python-any-r1_pkg_setup
68 if ! use vanilla ; then
69 eapply "${WORKDIR}"/patch/*.patch
74 # Since we've patched many .c files, the make process will try to
75 # re-build the manpages by running `./bin --help`. When doing a
76 # cross-compile, we can't do that since 'bin' isn't a native bin.
77 # Also, it's not like we changed the usage on any of these things,
78 # so let's just update the timestamps and skip the help2man step.
82 # Avoid perl dep for compiled in dircolors default #348642
83 if ! has_version dev-lang/perl ; then
91 --with-packager="Gentoo"
92 --with-packager-version="${PVR} (p${PATCH_VER:-0})"
93 --with-packager-bug-reports="https://bugs.gentoo.org/"
94 --enable-install-program="arch,$(usev hostname),$(usev kill)"
95 --enable-no-install-program="groups,$(usev !hostname),$(usev !kill),su,uptime"
97 $(usex caps '' --disable-libcap)
100 $(use_enable multicall single-binary)
104 if tc-is-cross-compiler && [[ ${CHOST} == *linux* ]] ; then
105 export fu_cv_sys_stat_statfs2_bsize=yes #311569
106 export gl_cv_func_realpath_works=yes #416629
109 export gl_cv_func_mknod_works=yes #409919
110 use static && append-ldflags -static && sed -i '/elf_sys=yes/s:yes:no:' configure #321821
111 use selinux || export ac_cv_{header_selinux_{context,flash,selinux}_h,search_setfilecon}=no #301782
112 use userland_BSD && myconf+=( -program-prefix=g --program-transform-name=s/stat/nustat/ )
113 # kill/uptime - procps
115 # hostname - net-tools
120 # Known to fail with FEATURES=usersandbox (bug #439574):
121 # - tests/du/long-from-unreadable.sh} (bug #413621)
122 # - tests/rm/deep-2.sh (bug #413621)
123 # - tests/dd/no-allocate.sh (bug #629660)
124 if has usersandbox $FEATURES ; then
125 ewarn "You are emerging ${P} with 'usersandbox' enabled." \
126 "Expect some test failures or emerge with 'FEATURES=-usersandbox'!"
129 # Non-root tests will fail if the full path isn't
130 # accessible to non-root users
131 chmod -R go-w "${WORKDIR}"
132 chmod a+rx "${WORKDIR}"
134 # coreutils tests like to do `mount` and such with temp dirs
135 # so make sure /etc/mtab is writable #265725
136 # make sure /dev/loop* can be mounted #269758
137 mkdir -p "${T}"/mount-wrappers
141 ww="${T}/mount-wrappers/${w}"
144 exec env SANDBOX_WRITE="\${SANDBOX_WRITE}:/etc/mtab:/dev/loop" $(type -P $w) "\$@"
152 #export RUN_EXPENSIVE_TESTS="yes"
153 #export FETISH_GROUPS="portage wheel"
154 env PATH="${T}/mount-wrappers:${PATH}" \
162 newins src/dircolors.hin DIR_COLORS
164 if [[ ${USERLAND} == "GNU" ]] ; then
165 cd "${ED%/}"/usr/bin || die
167 # move critical binaries into /bin (required by FHS)
168 local fhs="cat chgrp chmod chown cp date dd df echo false ln ls
169 mkdir mknod mv pwd rm rmdir stty sync true uname"
170 mv ${fhs} ../../bin/ || die "could not move fhs bins"
171 if use hostname; then
172 mv hostname ../../bin/ || die
175 mv kill ../../bin/ || die
177 if use split-usr ; then
178 # move critical binaries into /bin (common scripts)
179 local com="basename chroot cut dir dirname du env expr head mkfifo
180 mktemp readlink seq sleep sort tail touch tr tty vdir wc yes"
181 mv ${com} ../../bin/ || die "could not move common bins"
182 # create a symlink for uname in /usr/bin/ since autotools require it
184 for x in ${com} uname ; do
185 dosym ../../bin/${x} /usr/bin/${x}
189 # For now, drop the man pages, collides with the ones of the system.
190 rm -rf "${ED%/}"/usr/share/man
196 ewarn "Make sure you run 'hash -r' in your active shells."
197 ewarn "You should also re-source your shell settings for LS_COLORS"
198 ewarn " changes, such as: source /etc/profile"
200 # Help out users using experimental filesystems
201 if grep -qs btrfs "${EROOT%/}"/etc/fstab /proc/mounts ; then
203 2.6.[12][0-9]|2.6.3[0-7]*)
204 ewarn "You are running a system with a buggy btrfs driver."
205 ewarn "Please upgrade your kernel to avoid silent corruption."
206 ewarn "See: https://bugs.gentoo.org/353907"