1 # Copyright 1999-2025 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 # Try to keep an eye on Fedora's packaging: https://src.fedoraproject.org/rpms/coreutils
7 # The upstream coreutils maintainers also maintain the package in Fedora and may
8 # backport fixes which we want to pick up.
10 # Also recommend subscribing to the coreutils and bug-coreutils MLs.
12 PYTHON_COMPAT=( python3_{10..13} )
13 VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/coreutils.asc
14 inherit flag-o-matic python-any-r1 toolchain-funcs verify-sig
16 MY_PATCH="${PN}-9.6-patches"
17 DESCRIPTION="Standard GNU utilities (chmod, cp, dd, ls, sort, tr, head, wc, who,...)"
18 HOMEPAGE="https://www.gnu.org/software/coreutils/"
20 if [[ ${PV} == 9999 ]] ; then
21 EGIT_REPO_URI="https://git.savannah.gnu.org/git/coreutils.git"
23 elif [[ ${PV} == *_p* ]] ; then
24 # Note: could put this in devspace, but if it's gone, we don't want
25 # it in tree anyway. It's just for testing.
26 MY_SNAPSHOT="$(ver_cut 1-2).185-541b02"
27 SRC_URI="https://www.pixelbeat.org/cu/coreutils-${MY_SNAPSHOT}.tar.xz -> ${P}.tar.xz"
28 SRC_URI+=" verify-sig? ( https://www.pixelbeat.org/cu/coreutils-${MY_SNAPSHOT}.tar.xz.sig -> ${P}.tar.xz.sig )"
29 S="${WORKDIR}"/${PN}-${MY_SNAPSHOT}
32 mirror://gnu/${PN}/${P}.tar.xz
33 verify-sig? ( mirror://gnu/${PN}/${P}.tar.xz.sig )
36 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x86-linux"
39 SRC_URI+=" !vanilla? ( https://dev.gentoo.org/~sam/distfiles/${CATEGORY}/${PN}/${MY_PATCH}.tar.xz )"
43 IUSE="acl caps gmp hostname kill multicall nls +openssl selinux +split-usr static test vanilla xattr"
44 RESTRICT="!test? ( test )"
47 acl? ( sys-apps/acl[static-libs] )
48 caps? ( sys-libs/libcap )
49 gmp? ( dev-libs/gmp:=[static-libs] )
50 openssl? ( dev-libs/openssl:=[static-libs] )
51 xattr? ( sys-apps/attr[static-libs] )
54 !static? ( ${LIB_DEPEND//\[static-libs]} )
55 selinux? ( sys-libs/libselinux )
56 nls? ( virtual/libintl )
60 static? ( ${LIB_DEPEND} )
71 verify-sig? ( sec-keys/openpgp-keys-coreutils )
74 hostname? ( !sys-apps/net-tools[hostname] )
76 !sys-apps/util-linux[kill]
77 !sys-process/procps[kill]
79 !<sys-apps/util-linux-2.13
80 !<sys-apps/sandbox-2.10-r4
84 !<app-forensics/tct-1.18-r1
85 !<net-fs/netatalk-2.0.3-r4
88 QA_CONFIG_IMPL_DECL_SKIP=(
89 # gnulib FPs (bug #898370)
90 unreachable MIN alignof static_assert
95 python-any-r1_pkg_setup
100 if [[ ${PV} == 9999 ]] ; then
106 sed -i -e "s:submodule-checks ?= no-submodule-changes public-submodule-commit:submodule-checks ?= no-submodule-changes:" gnulib/top/maint.mk || die
107 elif use verify-sig ; then
108 # Needed for downloaded patch (which is unsigned, which is fine)
109 verify-sig_verify_detached "${DISTDIR}"/${P}.tar.xz{,.sig}
116 # TODO: past 2025, we may need to add our own hack for bug #907474.
121 if ! use vanilla && [[ -d "${WORKDIR}"/${MY_PATCH} ]] ; then
122 PATCHES+=( "${WORKDIR}"/${MY_PATCH} )
127 # Since we've patched many .c files, the make process will try to
128 # re-build the manpages by running `./bin --help`. When doing a
129 # cross-compile, we can't do that since 'bin' isn't a native bin.
131 # Also, it's not like we changed the usage on any of these things,
132 # so let's just update the timestamps and skip the help2man step.
134 touch ${@/%x/1} || die
136 # Avoid perl dep for compiled in dircolors default (bug #348642)
137 if ! has_version dev-lang/perl ; then
138 touch src/dircolors.h || die
139 touch ${@/%x/1} || die
144 # TODO: in future (>9.4?), we may want to wire up USE=systemd:
145 # still experimental at the moment, but:
146 # https://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=85edb4afbd119fb69a0d53e1beb71f46c9525dd0
148 --with-packager="Gentoo"
149 --with-packager-version="${PVR} (p${PATCH_VER:-0})"
150 --with-packager-bug-reports="https://bugs.gentoo.org/"
151 # kill/uptime - procps
153 # hostname - net-tools
154 --enable-install-program="arch,$(usev hostname),$(usev kill)"
155 --enable-no-install-program="groups,$(usev !hostname),$(usev !kill),su,uptime"
156 $(usev !caps --disable-libcap)
159 $(use_enable multicall single-binary)
161 $(use_with gmp libgmp)
166 myconf+=( --with-libgmp-prefix="${ESYSROOT}"/usr )
169 if tc-is-cross-compiler && [[ ${CHOST} == *linux* ]] ; then
171 export fu_cv_sys_stat_statfs2_bsize=yes
173 export gl_cv_func_realpath_works=yes
177 export gl_cv_func_mknod_works=yes
180 append-ldflags -static
182 sed -i '/elf_sys=yes/s:yes:no:' configure || die
185 if ! use selinux ; then
187 export ac_cv_{header_selinux_{context,flash,selinux}_h,search_setfilecon}=no
194 # Non-root tests will fail if the full path isn't
195 # accessible to non-root users
196 chmod -R go-w "${WORKDIR}" || die
197 chmod a+rx "${WORKDIR}" || die
199 # coreutils tests like to do `mount` and such with temp dirs,
201 # - /etc/mtab is writable (bug #265725)
202 # - /dev/loop* can be mounted (bug #269758)
203 mkdir -p "${T}"/mount-wrappers || die
207 ww="${T}/mount-wrappers/${w}"
210 exec env SANDBOX_WRITE="\${SANDBOX_WRITE}:/etc/mtab:/dev/loop" $(type -P ${w}) "\$@"
212 chmod a+rx "${ww}" || die
219 #local -x RUN_EXPENSIVE_TESTS="yes"
220 #local -x COREUTILS_GROUPS="portage wheel"
221 local -x PATH="${T}/mount-wrappers:${PATH}"
222 local -x gl_public_submodule_commit=
226 # Commented out again in 9.6 as it XPASSes on linux-6.12.10
227 # with sandbox-2.43 on tmpfs. Let's see if it lasts..
228 #tests/dd/no-allocate.sh
234 # bug #413621 and bug #548250
235 tests/du/long-from-unreadable.sh
236 tests/ls/removed-directory
237 tests/ls/removed-directory.sh
238 tests/ls/stat-free-symlinks
239 tests/ls/stat-free-symlinks.sh
243 # We have a patch which fixes this (bug #259876)
244 #tests/touch/not-owner
245 #tests/touch/not-owner.sh
248 # This test is flaky (bug #910640).
249 cat > tests/tty/tty-eof.pl <<-EOF || die
254 # We set DISABLE_HARD_ERRORS because some of the tests hard error-out
255 # because of sandbox. They're skipped above but DISABLE_HARD_ERRORS is needed
256 # to downgrade them to FAIL.
259 DISABLE_HARD_ERRORS=yes \
260 XFAIL_TESTS="${xfail_tests[*]}"
267 newins src/dircolors.hin DIR_COLORS
269 if use split-usr ; then
270 cd "${ED}"/usr/bin || die
273 # Move critical binaries into /bin (required by FHS)
274 local fhs="cat chgrp chmod chown cp date dd df echo false ln ls
275 mkdir mknod mv pwd rm rmdir stty sync true uname"
276 mv ${fhs} ../../bin/ || die "Could not move FHS bins!"
278 if use hostname ; then
279 mv hostname ../../bin/ || die
283 mv kill ../../bin/ || die
286 # Move critical binaries into /bin (common scripts)
287 # (Why are these required for booting?)
288 local com="basename chroot cut dir dirname du env expr head mkfifo
289 mktemp readlink seq sleep sort tail touch tr tty vdir wc yes"
290 mv ${com} ../../bin/ || die "Could not move common bins!"
292 # Create a symlink for uname in /usr/bin/ since autotools require it.
293 # (Other than uname, we need to figure out why we are
294 # creating symlinks for these in /usr/bin instead of leaving
295 # the files there in the first place...)
297 for x in ${com} uname ; do
298 dosym ../../bin/${x} /usr/bin/${x}
304 ewarn "Make sure you run 'hash -r' in your active shells."
305 ewarn "You should also re-source your shell settings for LS_COLORS"
306 ewarn " changes, such as: source /etc/profile"