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