blob: 62ecdea6ec1f98eb67d1353a6a18eee2bb5b16de [file] [log] [blame]
Andrew Geisslereff27472021-10-29 15:35:00 -05001SUMMARY = "The basic file, shell and text manipulation utilities"
2DESCRIPTION = "The GNU Core Utilities provide the basic file, shell and text \
3manipulation utilities. These are the core utilities which are expected to exist on \
4every system."
5HOMEPAGE = "http://www.gnu.org/software/coreutils/"
6BUGTRACKER = "http://debbugs.gnu.org/coreutils"
Andrew Geissler7e0e3c02022-02-25 20:34:39 +00007LICENSE = "GPL-3.0-or-later"
Andrew Geisslereff27472021-10-29 15:35:00 -05008LIC_FILES_CHKSUM = "file://COPYING;md5=1ebbd3e34237af26da5dc08a4e440464 \
Patrick Williams520786c2023-06-25 16:20:36 -05009 file://src/ls.c;beginline=1;endline=15;md5=b720a8b317035d66c555fc6d89e3674c \
Andrew Geisslereff27472021-10-29 15:35:00 -050010 "
11DEPENDS = "gmp libcap"
12DEPENDS:class-native = ""
13
14inherit autotools gettext texinfo
15
16SRC_URI = "${GNU_MIRROR}/coreutils/${BP}.tar.xz \
17 file://remove-usr-local-lib-from-m4.patch \
Andrew Geisslereff27472021-10-29 15:35:00 -050018 file://0001-local.mk-fix-cross-compiling-problem.patch \
Patrick Williamsf52e3dd2024-01-26 13:04:43 -060019 file://0001-posixtm-pacify-clang-18.patch \
Patrick Williamsb58112e2024-03-07 11:16:36 -060020 file://CVE-2024-0684.patch \
Andrew Geisslereff27472021-10-29 15:35:00 -050021 file://run-ptest \
22 "
Andrew Geissler220dafd2023-10-04 10:18:08 -050023SRC_URI[sha256sum] = "ea613a4cf44612326e917201bbbcdfbd301de21ffc3b59b6e5c07e040b275e52"
Andrew Geisslereff27472021-10-29 15:35:00 -050024
25# http://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=v8.27-101-gf5d7c0842
Patrick Williams03514f12024-04-05 07:04:11 -050026#
Andrew Geissler8f840682023-07-21 09:09:43 -050027CVE_STATUS[CVE-2016-2781] = "disputed: runcon is not really a sandbox command, use `runcon ... setsid ...` to avoid this particular issue."
Andrew Geisslereff27472021-10-29 15:35:00 -050028
29EXTRA_OECONF:class-target = "--enable-install-program=arch,hostname --libexecdir=${libdir}"
30EXTRA_OECONF:class-nativesdk = "--enable-install-program=arch,hostname"
31
32# acl and xattr are not default features
33#
34PACKAGECONFIG:class-target ??= "\
35 ${@bb.utils.filter('DISTRO_FEATURES', 'acl xattr', d)} \
36"
37
38# The lib/oe/path.py requires xattr
39PACKAGECONFIG:class-native ??= "xattr"
40
41# oe-core builds need xattr support
42PACKAGECONFIG:class-nativesdk ??= "xattr"
43
44# with, without, depends, rdepends
45#
46PACKAGECONFIG[acl] = "--enable-acl,--disable-acl,acl,"
47PACKAGECONFIG[xattr] = "--enable-xattr,--disable-xattr,attr,"
48PACKAGECONFIG[single-binary] = "--enable-single-binary,--disable-single-binary,,"
49PACKAGECONFIG[selinux] = "--with-selinux,--without-selinux,libselinux"
Andrew Geissler87f5cff2022-09-30 13:13:31 -050050PACKAGECONFIG[openssl] = "--with-openssl=yes,--with-openssl=no,openssl"
Andrew Geisslereff27472021-10-29 15:35:00 -050051
52# [ df mktemp nice printenv base64 gets a special treatment and is not included in this
53bindir_progs = "arch basename chcon cksum comm csplit cut dir dircolors dirname du \
54 env expand expr factor fmt fold groups head hostid id install \
55 join link logname md5sum mkfifo nl nohup nproc od paste pathchk \
56 pinky pr printf ptx readlink realpath runcon seq sha1sum sha224sum sha256sum \
57 sha384sum sha512sum shred shuf sort split sum tac tail tee test timeout \
58 tr truncate tsort tty unexpand uniq unlink uptime users vdir wc who whoami yes"
59
60# hostname gets a special treatment and is not included in this
61base_bindir_progs = "cat chgrp chmod chown cp date dd echo false hostname kill ln ls mkdir \
62 mknod mv pwd rm rmdir sleep stty sync touch true uname stat"
63
64sbindir_progs= "chroot"
65
66# Split stdbuf into its own package, so one can include
67# coreutils-stdbuf without getting the rest of coreutils, but make
68# coreutils itself pull in stdbuf, so IMAGE_INSTALL += "coreutils"
69# always provides all coreutils
70PACKAGE_BEFORE_PN:class-target += "${@bb.utils.contains('PACKAGECONFIG', 'single-binary', '', 'coreutils-stdbuf', d)}"
71FILES:coreutils-stdbuf = "${bindir}/stdbuf ${libdir}/coreutils/libstdbuf.so"
72RDEPENDS:coreutils:class-target += "${@bb.utils.contains('PACKAGECONFIG', 'single-binary', '', 'coreutils-stdbuf', d)}"
73
74# However, when the single-binary PACKAGECONFIG is used, stdbuf
75# functionality is built into the single coreutils binary, so there's
76# no point splitting /usr/bin/stdbuf to its own package. Instead, add
77# an RPROVIDE so that rdepending on coreutils-stdbuf will work
78# regardless of whether single-binary is in effect.
79RPROVIDES:coreutils += "${@bb.utils.contains('PACKAGECONFIG', 'single-binary', 'coreutils-stdbuf', '', d)}"
80
81# Let aclocal use the relative path for the m4 file rather than the
82# absolute since coreutils has a lot of m4 files, otherwise there might
83# be an "Argument list too long" error when it is built in a long/deep
84# directory.
85acpaths = "-I ./m4"
86
87# Deal with a separate builddir failure if src doesn't exist when creating version.c/version.h
88do_compile:prepend () {
89 mkdir -p ${B}/src
90}
91
92do_install:class-native() {
93 autotools_do_install
94 # remove groups to fix conflict with shadow-native
95 rm -f ${D}${STAGING_BINDIR_NATIVE}/groups
96 # The return is a must since native doesn't need the
97 # do_install:append() in the below.
98 return
99}
100
101do_install:append() {
102 for i in df mktemp nice printenv base64; do mv ${D}${bindir}/$i ${D}${bindir}/$i.${BPN}; done
103
104 install -d ${D}${base_bindir}
105 [ "${base_bindir}" != "${bindir}" ] && for i in ${base_bindir_progs}; do mv ${D}${bindir}/$i ${D}${base_bindir}/$i.${BPN}; done
106
107 install -d ${D}${sbindir}
108 [ "${sbindir}" != "${bindir}" ] && for i in ${sbindir_progs}; do mv ${D}${bindir}/$i ${D}${sbindir}/$i.${BPN}; done
109
110 # [ requires special handling because [.coreutils will cause the sed stuff
111 # in update-alternatives to fail, therefore use lbracket - the name used
112 # for the actual source file.
113 mv ${D}${bindir}/[ ${D}${bindir}/lbracket.${BPN}
114}
115
116inherit update-alternatives
117
118ALTERNATIVE_PRIORITY = "100"
119# Make hostname's priority higher than busybox but lower than net-tools
120ALTERNATIVE_PRIORITY[hostname] = "90"
121ALTERNATIVE:${PN} = "lbracket ${bindir_progs} ${base_bindir_progs} ${sbindir_progs} base32 base64 nice printenv mktemp df"
122ALTERNATIVE:${PN}-doc = "base64.1 nice.1 mktemp.1 df.1 groups.1 kill.1 uptime.1 stat.1 hostname.1"
123
124ALTERNATIVE_LINK_NAME[hostname.1] = "${mandir}/man1/hostname.1"
125
126ALTERNATIVE_LINK_NAME[base64] = "${base_bindir}/base64"
127ALTERNATIVE_TARGET[base64] = "${bindir}/base64.${BPN}"
128ALTERNATIVE_LINK_NAME[base64.1] = "${mandir}/man1/base64.1"
129
130ALTERNATIVE_LINK_NAME[mktemp] = "${base_bindir}/mktemp"
131ALTERNATIVE_TARGET[mktemp] = "${bindir}/mktemp.${BPN}"
132ALTERNATIVE_LINK_NAME[mktemp.1] = "${mandir}/man1/mktemp.1"
133
134ALTERNATIVE_LINK_NAME[df] = "${base_bindir}/df"
135ALTERNATIVE_TARGET[df] = "${bindir}/df.${BPN}"
136ALTERNATIVE_LINK_NAME[df.1] = "${mandir}/man1/df.1"
137
138ALTERNATIVE_LINK_NAME[nice] = "${base_bindir}/nice"
139ALTERNATIVE_TARGET[nice] = "${bindir}/nice.${BPN}"
140ALTERNATIVE_LINK_NAME[nice.1] = "${mandir}/man1/nice.1"
141
142ALTERNATIVE_LINK_NAME[printenv] = "${base_bindir}/printenv"
143ALTERNATIVE_TARGET[printenv] = "${bindir}/printenv.${BPN}"
144
145ALTERNATIVE_LINK_NAME[lbracket] = "${bindir}/["
146ALTERNATIVE_TARGET[lbracket] = "${bindir}/lbracket.${BPN}"
147
148ALTERNATIVE_LINK_NAME[groups.1] = "${mandir}/man1/groups.1"
149ALTERNATIVE_LINK_NAME[uptime.1] = "${mandir}/man1/uptime.1"
150ALTERNATIVE_LINK_NAME[kill.1] = "${mandir}/man1/kill.1"
151ALTERNATIVE_LINK_NAME[stat.1] = "${mandir}/man1/stat.1"
152
Andrew Geissler9aee5002022-03-30 16:27:02 +0000153# The statx() requires glibc >= 2.28 and linux kernel >= 4.11, it doesn't work
154# when glibc >= 2.28 ((Ubuntu 20.04 in docker) and kernel < 4.11 (Host OS
155# CentOS 7), we can check kernel version and disable it, but that would cause
156# two different signatures for coreutils-native, so disable it unconditionally
157# for deterministic build.
158EXTRA_OECONF:append:class-native = " ac_cv_func_statx=0"
159
Andrew Geisslereff27472021-10-29 15:35:00 -0500160python __anonymous() {
161 for prog in d.getVar('base_bindir_progs').split():
162 d.setVarFlag('ALTERNATIVE_LINK_NAME', prog, '%s/%s' % (d.getVar('base_bindir'), prog))
163
164 for prog in d.getVar('sbindir_progs').split():
165 d.setVarFlag('ALTERNATIVE_LINK_NAME', prog, '%s/%s' % (d.getVar('sbindir'), prog))
166}
167
168BBCLASSEXTEND = "native nativesdk"
169
170inherit ptest
171
Patrick Williams03514f12024-04-05 07:04:11 -0500172RDEPENDS:${PN}-ptest += "bash findutils gawk make perl perl-modules python3-core sed shadow"
Andrew Geisslereff27472021-10-29 15:35:00 -0500173
174# -dev automatic dependencies fails as we don't want libmodule-build-perl-dev, its too heavy
175# may need tweaking if DEPENDS changes
Andrew Geissler615f2f12022-07-15 14:00:58 -0500176# Can't use ${PN}-dev here since flags with overrides and key expansion not supported
Andrew Geisslereff27472021-10-29 15:35:00 -0500177RRECOMMENDS:coreutils-dev[nodeprrecs] = "1"
Andrew Geissler615f2f12022-07-15 14:00:58 -0500178RRECOMMENDS:${PN}-dev += "acl-dev attr-dev gmp-dev libcap-dev bash-dev findutils-dev gawk-dev shadow-dev"
Andrew Geisslereff27472021-10-29 15:35:00 -0500179
180do_install_ptest () {
181 install -d ${D}${PTEST_PATH}/tests
182 cp -r ${S}/tests/* ${D}${PTEST_PATH}/tests
183 sed -i 's/ginstall/install/g' `grep -R ginstall ${D}${PTEST_PATH}/tests | awk -F: '{print $1}' | uniq`
184 install -d ${D}${PTEST_PATH}/build-aux
185 install ${S}/build-aux/test-driver ${D}${PTEST_PATH}/build-aux/
Andrew Geissler220dafd2023-10-04 10:18:08 -0500186 install -Dm 0644 ${B}/lib/config.h ${D}${PTEST_PATH}/lib/config.h
Andrew Geisslereff27472021-10-29 15:35:00 -0500187 cp ${B}/Makefile ${D}${PTEST_PATH}/
188 cp ${S}/init.cfg ${D}${PTEST_PATH}/
189 cp -r ${B}/src ${D}${PTEST_PATH}/
190 cp -r ${S}/src/*.c ${D}${PTEST_PATH}/src
191 sed -i '/^VPATH/s/= .*$/= ./g' ${D}${PTEST_PATH}/Makefile
192 sed -i '/^PROGRAMS/s/^/#/g' ${D}${PTEST_PATH}/Makefile
193 sed -i '/^Makefile: /s/^.*$/Makefile:/g' ${D}${PTEST_PATH}/Makefile
194 sed -i '/^abs_srcdir/s/= .*$/= \$\{PWD\}/g' ${D}${PTEST_PATH}/Makefile
195 sed -i '/^abs_top_builddir/s/= .*$/= \$\{PWD\}/g' ${D}${PTEST_PATH}/Makefile
196 sed -i '/^abs_top_srcdir/s/= .*$/= \$\{PWD\}/g' ${D}${PTEST_PATH}/Makefile
197 sed -i '/^built_programs/s/ginstall/install/g' ${D}${PTEST_PATH}/Makefile
Patrick Williams8e7b46e2023-05-01 14:19:06 -0500198 sed -i '/^CC =/s/ --sysroot=.*recipe-sysroot/ /g' ${D}${PTEST_PATH}/Makefile
Andrew Geisslereff27472021-10-29 15:35:00 -0500199 chmod -R 777 ${D}${PTEST_PATH}
200
201 # Disable subcase stty-pairs.sh, it will cause test framework hang
202 sed -i '/stty-pairs.sh/d' ${D}${PTEST_PATH}/Makefile
203
204 # Disable subcase tail-2/assert.sh as it has issues on 32-bit systems
205 sed -i '/assert.sh/d' ${D}${PTEST_PATH}/Makefile
206
207 # Tweak test d_type-check to use python3 instead of python
208 sed -i "1s@.*@#!/usr/bin/python3@" ${D}${PTEST_PATH}/tests/d_type-check
209 install ${B}/src/getlimits ${D}/${bindir}
210
211 # handle multilib
212 sed -i s:@libdir@:${libdir}:g ${D}${PTEST_PATH}/run-ptest
213}
214
Patrick Williams705982a2024-01-12 09:51:57 -0600215do_install_ptest:append:libc-musl () {
216 # these tests fail due to bash on musl systems
217 # xmalloc: cannot allocate 16146 bytes
218 sed -i -e '/tests\/dd\/no-allocate.sh/d' ${D}${PTEST_PATH}/Makefile
219 sed -i -e '/tests\/split\/line-bytes.sh/d' ${D}${PTEST_PATH}/Makefile
220}
Andrew Geisslereff27472021-10-29 15:35:00 -0500221FILES:${PN}-ptest += "${bindir}/getlimits"