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