dev-python/agate: Bump to 1.13.0
[gentoo/gentoo.git] / sys-apps / coreutils / coreutils-9.6.ebuild
blob6630d91c84d56237335c00da3755fa0e86e51158
1 # Copyright 1999-2025 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 EAPI=8
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"
22         inherit git-r3
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}
30 else
31         SRC_URI="
32                 mirror://gnu/${PN}/${P}.tar.xz
33                 verify-sig? ( mirror://gnu/${PN}/${P}.tar.xz.sig )
34         "
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 )"
41 LICENSE="GPL-3+"
42 SLOT="0"
43 IUSE="acl caps gmp hostname kill multicall nls +openssl selinux +split-usr static test vanilla xattr"
44 RESTRICT="!test? ( test )"
46 LIB_DEPEND="
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] )
53 RDEPEND="
54         !static? ( ${LIB_DEPEND//\[static-libs]} )
55         selinux? ( sys-libs/libselinux )
56         nls? ( virtual/libintl )
58 DEPEND="
59         ${RDEPEND}
60         static? ( ${LIB_DEPEND} )
62 BDEPEND="
63         app-arch/xz-utils
64         dev-lang/perl
65         test? (
66                 dev-debug/strace
67                 dev-lang/perl
68                 dev-perl/Expect
69                 ${PYTHON_DEPS}
70         )
71         verify-sig? ( sec-keys/openpgp-keys-coreutils )
73 RDEPEND+="
74         hostname? ( !sys-apps/net-tools[hostname] )
75         kill? (
76                 !sys-apps/util-linux[kill]
77                 !sys-process/procps[kill]
78         )
79         !<sys-apps/util-linux-2.13
80         !<sys-apps/sandbox-2.10-r4
81         !sys-apps/stat
82         !net-mail/base64
83         !sys-apps/mktemp
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
93 pkg_setup() {
94         if use test ; then
95                 python-any-r1_pkg_setup
96         fi
99 src_unpack() {
100         if [[ ${PV} == 9999 ]] ; then
101                 git-r3_src_unpack
103                 cd "${S}" || die
104                 ./bootstrap || die
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}
110         fi
112         default
115 src_prepare() {
116         # TODO: past 2025, we may need to add our own hack for bug #907474.
117         local PATCHES=(
118                 # Upstream patches
119         )
121         if ! use vanilla && [[ -d "${WORKDIR}"/${MY_PATCH} ]] ; then
122                 PATCHES+=( "${WORKDIR}"/${MY_PATCH} )
123         fi
125         default
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.
130         #
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.
133         set -- man/*.x
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
140         fi
143 src_configure() {
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
147         local myconf=(
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
152                 # groups/su   - shadow
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)
157                 $(use_enable nls)
158                 $(use_enable acl)
159                 $(use_enable multicall single-binary)
160                 $(use_enable xattr)
161                 $(use_with gmp libgmp)
162                 $(use_with openssl)
163         )
165         if use gmp ; then
166                 myconf+=( --with-libgmp-prefix="${ESYSROOT}"/usr )
167         fi
169         if tc-is-cross-compiler && [[ ${CHOST} == *linux* ]] ; then
170                 # bug #311569
171                 export fu_cv_sys_stat_statfs2_bsize=yes
172                 # bug #416629
173                 export gl_cv_func_realpath_works=yes
174         fi
176         # bug #409919
177         export gl_cv_func_mknod_works=yes
179         if use static ; then
180                 append-ldflags -static
181                 # bug #321821
182                 sed -i '/elf_sys=yes/s:yes:no:' configure || die
183         fi
185         if ! use selinux ; then
186                 # bug #301782
187                 export ac_cv_{header_selinux_{context,flash,selinux}_h,search_setfilecon}=no
188         fi
190         econf "${myconf[@]}"
193 src_test() {
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,
200         # so make sure:
201         # - /etc/mtab is writable (bug #265725)
202         # - /dev/loop* can be mounted (bug #269758)
203         mkdir -p "${T}"/mount-wrappers || die
204         mkwrap() {
205                 local w ww
206                 for w in "${@}" ; do
207                         ww="${T}/mount-wrappers/${w}"
208                         cat <<-EOF > "${ww}"
209                                 #!${EPREFIX}/bin/sh
210                                 exec env SANDBOX_WRITE="\${SANDBOX_WRITE}:/etc/mtab:/dev/loop" $(type -P ${w}) "\$@"
211                         EOF
212                         chmod a+rx "${ww}" || die
213                 done
214         }
215         mkwrap mount umount
217         addwrite /dev/full
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=
224         local xfail_tests=(
225                 # bug #629660
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
230                 # bug #675802
231                 tests/env/env-S
232                 tests/env/env-S.pl
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
240                 tests/rm/deep-2
241                 tests/rm/deep-2.sh
243                 # We have a patch which fixes this (bug #259876)
244                 #tests/touch/not-owner
245                 #tests/touch/not-owner.sh
246         )
248         # This test is flaky (bug #910640).
249         cat > tests/tty/tty-eof.pl <<-EOF || die
250         #!/usr/bin/perl
251         exit 77;
252         EOF
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.
257         emake -k check \
258                 VERBOSE=yes \
259                 DISABLE_HARD_ERRORS=yes \
260                 XFAIL_TESTS="${xfail_tests[*]}"
263 src_install() {
264         default
266         insinto /etc
267         newins src/dircolors.hin DIR_COLORS
269         if use split-usr ; then
270                 cd "${ED}"/usr/bin || die
271                 dodir /bin
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
280                 fi
282                 if use kill ; then
283                         mv kill ../../bin/ || die
284                 fi
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...)
296                 local x
297                 for x in ${com} uname ; do
298                         dosym ../../bin/${x} /usr/bin/${x}
299                 done
300         fi
303 pkg_postinst() {
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"