*/*: Drop stable ia64 keywords
[gentoo.git] / sys-apps / coreutils / coreutils-8.30.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="6"
5
6 PYTHON_COMPAT=( python3_6 )
7
8 inherit eutils flag-o-matic python-any-r1 toolchain-funcs
9
10 PATCH_VER="01"
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"
16
17 LICENSE="GPL-3"
18 SLOT="0"
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 )"
22
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 )"
30 DEPEND="${RDEPEND}
31         static? ( ${LIB_DEPEND} )
32         app-arch/xz-utils
33         test? (
34                 dev-lang/perl
35                 dev-perl/Expect
36                 !userland_BSD? (
37                         dev-util/strace
38                 )
39                 ${PYTHON_DEPS}
40                 $(python_gen_any_dep 'dev-python/pyinotify[${PYTHON_USEDEP}]')
41         )"
42 RDEPEND+="
43         hostname? ( !sys-apps/net-tools[hostname] )
44         kill? (
45                 !sys-apps/util-linux[kill]
46                 !sys-process/procps[kill]
47         )
48         !app-misc/realpath
49         !<sys-apps/util-linux-2.13
50         !<sys-apps/sandbox-2.10-r4
51         !sys-apps/stat
52         !net-mail/base64
53         !sys-apps/mktemp
54         !<app-forensics/tct-1.18-r1
55         !<net-fs/netatalk-2.0.3-r4"
56
57 python_check_deps() {
58         has_version --host-root "dev-python/pyinotify[${PYTHON_USEDEP}]"
59 }
60
61 pkg_setup() {
62         if use test ; then
63                 python-any-r1_pkg_setup
64         fi
65 }
66
67 src_prepare() {
68         if ! use vanilla ; then
69                 eapply "${WORKDIR}"/patch/*.patch
70         fi
71
72         eapply_user
73
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.
79         set -- man/*.x
80         touch ${@/%x/1}
81
82         # Avoid perl dep for compiled in dircolors default #348642
83         if ! has_version dev-lang/perl ; then
84                 touch src/dircolors.h
85                 touch ${@/%x/1}
86         fi
87 }
88
89 src_configure() {
90         local myconf=(
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"
96                 --enable-largefile
97                 $(usex caps '' --disable-libcap)
98                 $(use_enable nls)
99                 $(use_enable acl)
100                 $(use_enable multicall single-binary)
101                 $(use_enable xattr)
102                 $(use_with gmp)
103         )
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
107         fi
108
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
114         # groups/su   - shadow
115         # hostname    - net-tools
116         econf "${myconf[@]}"
117 }
118
119 src_test() {
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'!"
127         fi
128
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}"
133
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
138         mkwrap() {
139                 local w ww
140                 for w in "$@" ; do
141                         ww="${T}/mount-wrappers/${w}"
142                         cat <<-EOF > "${ww}"
143                                 #!${EPREFIX}/bin/sh
144                                 exec env SANDBOX_WRITE="\${SANDBOX_WRITE}:/etc/mtab:/dev/loop" $(type -P $w) "\$@"
145                         EOF
146                         chmod a+rx "${ww}"
147                 done
148         }
149         mkwrap mount umount
150
151         addwrite /dev/full
152         #export RUN_EXPENSIVE_TESTS="yes"
153         #export FETISH_GROUPS="portage wheel"
154         env PATH="${T}/mount-wrappers:${PATH}" \
155         emake -j1 -k check
156 }
157
158 src_install() {
159         default
160
161         insinto /etc
162         newins src/dircolors.hin DIR_COLORS
163
164         if [[ ${USERLAND} == "GNU" ]] ; then
165                 cd "${ED%/}"/usr/bin || die
166                 dodir /bin
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
173                 fi
174                 if use kill; then
175                         mv kill ../../bin/ || die
176                 fi
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
183                         local x
184                         for x in ${com} uname ; do
185                                 dosym ../../bin/${x} /usr/bin/${x}
186                         done
187                 fi
188         else
189                 # For now, drop the man pages, collides with the ones of the system.
190                 rm -rf "${ED%/}"/usr/share/man
191         fi
192
193 }
194
195 pkg_postinst() {
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"
199
200         # Help out users using experimental filesystems
201         if grep -qs btrfs "${EROOT%/}"/etc/fstab /proc/mounts ; then
202                 case $(uname -r) in
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"
207                         ;;
208                 esac
209         fi
210 }