summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/coreutils')
-rw-r--r--meta/recipes-core/coreutils/coreutils/0001-local.mk-fix-cross-compiling-problem.patch26
-rw-r--r--meta/recipes-core/coreutils/coreutils/0001-ls-restore-8.31-behavior-on-removed-directories.patch99
-rw-r--r--meta/recipes-core/coreutils/coreutils/0001-sort-fix-buffer-under-read-CWE-127.patch112
-rw-r--r--meta/recipes-core/coreutils/coreutils/0001-uname-report-processor-and-hardware-correctly.patch64
-rw-r--r--meta/recipes-core/coreutils/coreutils/disable-ls-output-quoting.patch49
-rw-r--r--meta/recipes-core/coreutils/coreutils/fix-selinux-flask.patch36
-rw-r--r--meta/recipes-core/coreutils/coreutils/remove-usr-local-lib-from-m4.patch7
-rw-r--r--meta/recipes-core/coreutils/coreutils_9.7.bb (renamed from meta/recipes-core/coreutils/coreutils_8.32.bb)105
8 files changed, 176 insertions, 322 deletions
diff --git a/meta/recipes-core/coreutils/coreutils/0001-local.mk-fix-cross-compiling-problem.patch b/meta/recipes-core/coreutils/coreutils/0001-local.mk-fix-cross-compiling-problem.patch
deleted file mode 100644
index 66f9a716c9..0000000000
--- a/meta/recipes-core/coreutils/coreutils/0001-local.mk-fix-cross-compiling-problem.patch
+++ /dev/null
@@ -1,26 +0,0 @@
1Subject: local.mk: fix cross compiling problem
2
3We meet the following error when cross compiling.
4| Makefile:3418: *** Recursive variable 'INSTALL' references itself (eventually). Stop.
5This patch fixes this problem.
6
7Upstream-Status: Pending
8
9Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
10---
11 src/local.mk | 2 +-
12 1 file changed, 1 insertion(+), 1 deletion(-)
13
14diff --git a/src/local.mk b/src/local.mk
15index 36dfa4e..c5898cc 100644
16--- a/src/local.mk
17+++ b/src/local.mk
18@@ -649,4 +649,4 @@ cu_install_program = @INSTALL_PROGRAM@
19 else
20 cu_install_program = src/ginstall
21 endif
22-INSTALL = $(cu_install_program) -c
23+INSTALL_PROGRAM = $(cu_install_program)
24--
252.1.0
26
diff --git a/meta/recipes-core/coreutils/coreutils/0001-ls-restore-8.31-behavior-on-removed-directories.patch b/meta/recipes-core/coreutils/coreutils/0001-ls-restore-8.31-behavior-on-removed-directories.patch
deleted file mode 100644
index fa900e3a76..0000000000
--- a/meta/recipes-core/coreutils/coreutils/0001-ls-restore-8.31-behavior-on-removed-directories.patch
+++ /dev/null
@@ -1,99 +0,0 @@
1From 7c273e5c6041f8c70f73f5b280fbb8f27d9b5a36 Mon Sep 17 00:00:00 2001
2From: Paul Eggert <eggert@cs.ucla.edu>
3Date: Thu, 5 Mar 2020 17:25:29 -0800
4Subject: [PATCH] ls: restore 8.31 behavior on removed directories
5
6* NEWS: Mention this.
7* src/ls.c: Do not include <sys/sycall.h>
8(print_dir): Don't worry about whether the directory is removed.
9* tests/ls/removed-directory.sh: Adjust to match new (i.e., old)
10behavior.
11
12Upstream-Status: Backport [https://github.com/coreutils/coreutils/commit/10fcb97bd728f09d4a027eddf8ad2900f0819b0a]
13Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
14---
15 src/ls.c | 22 ----------------------
16 tests/ls/removed-directory.sh | 10 ++--------
17 2 files changed, 2 insertions(+), 30 deletions(-)
18
19diff --git a/src/ls.c b/src/ls.c
20index 637fe7a..0111f49 100644
21--- a/src/ls.c
22+++ b/src/ls.c
23@@ -49,10 +49,6 @@
24 # include <sys/ptem.h>
25 #endif
26
27-#ifdef __linux__
28-# include <sys/syscall.h>
29-#endif
30-
31 #include <stdio.h>
32 #include <assert.h>
33 #include <setjmp.h>
34@@ -2895,7 +2891,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
35 struct dirent *next;
36 uintmax_t total_blocks = 0;
37 static bool first = true;
38- bool found_any_entries = false;
39
40 errno = 0;
41 dirp = opendir (name);
42@@ -2971,7 +2966,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
43 next = readdir (dirp);
44 if (next)
45 {
46- found_any_entries = true;
47 if (! file_ignored (next->d_name))
48 {
49 enum filetype type = unknown;
50@@ -3017,22 +3011,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
51 if (errno != EOVERFLOW)
52 break;
53 }
54-#ifdef __linux__
55- else if (! found_any_entries)
56- {
57- /* If readdir finds no directory entries at all, not even "." or
58- "..", then double check that the directory exists. */
59- if (syscall (SYS_getdents, dirfd (dirp), NULL, 0) == -1
60- && errno != EINVAL)
61- {
62- /* We exclude EINVAL as that pertains to buffer handling,
63- and we've passed NULL as the buffer for simplicity.
64- ENOENT is returned if appropriate before buffer handling. */
65- file_failure (command_line_arg, _("reading directory %s"), name);
66- }
67- break;
68- }
69-#endif
70 else
71 break;
72
73diff --git a/tests/ls/removed-directory.sh b/tests/ls/removed-directory.sh
74index e8c835d..fe8f929 100755
75--- a/tests/ls/removed-directory.sh
76+++ b/tests/ls/removed-directory.sh
77@@ -26,20 +26,14 @@ case $host_triplet in
78 *) skip_ 'non linux kernel' ;;
79 esac
80
81-LS_FAILURE=2
82-
83-cat <<\EOF >exp-err || framework_failure_
84-ls: reading directory '.': No such file or directory
85-EOF
86-
87 cwd=$(pwd)
88 mkdir d || framework_failure_
89 cd d || framework_failure_
90 rmdir ../d || framework_failure_
91
92-returns_ $LS_FAILURE ls >../out 2>../err || fail=1
93+ls >../out 2>../err || fail=1
94 cd "$cwd" || framework_failure_
95 compare /dev/null out || fail=1
96-compare exp-err err || fail=1
97+compare /dev/null err || fail=1
98
99 Exit $fail
diff --git a/meta/recipes-core/coreutils/coreutils/0001-sort-fix-buffer-under-read-CWE-127.patch b/meta/recipes-core/coreutils/coreutils/0001-sort-fix-buffer-under-read-CWE-127.patch
new file mode 100644
index 0000000000..41be1635b5
--- /dev/null
+++ b/meta/recipes-core/coreutils/coreutils/0001-sort-fix-buffer-under-read-CWE-127.patch
@@ -0,0 +1,112 @@
1From 8763c305c29d0abb7e2be4695212b42917d054b2 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
3Date: Tue, 20 May 2025 16:03:44 +0100
4Subject: [PATCH] sort: fix buffer under-read (CWE-127)
5
6* src/sort.c (begfield): Check pointer adjustment
7to avoid Out-of-range pointer offset (CWE-823).
8(limfield): Likewise.
9* tests/sort/sort-field-limit.sh: Add a new test,
10which triggers with ASAN or Valgrind.
11* tests/local.mk: Reference the new test.
12* NEWS: Mention bug fix introduced in v7.2 (2009).
13Fixes https://bugs.gnu.org/78507
14
15CVE: CVE-2025-5278
16
17Upstream-Status: Backport [https://cgit.git.savannah.gnu.org/cgit/coreutils.git/commit/?id=8c9602e3a145e9596dc1a63c6ed67865814b6633]
18
19Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
20---
21 src/sort.c | 12 ++++++++++--
22 tests/local.mk | 1 +
23 tests/sort/sort-field-limit.sh | 35 ++++++++++++++++++++++++++++++++++
24 3 files changed, 46 insertions(+), 2 deletions(-)
25 create mode 100755 tests/sort/sort-field-limit.sh
26
27diff --git a/src/sort.c b/src/sort.c
28index b10183b6f..7af1a2512 100644
29--- a/src/sort.c
30+++ b/src/sort.c
31@@ -1644,7 +1644,11 @@ begfield (struct line const *line, struct keyfield const *key)
32 ++ptr;
33
34 /* Advance PTR by SCHAR (if possible), but no further than LIM. */
35- ptr = MIN (lim, ptr + schar);
36+ size_t remaining_bytes = lim - ptr;
37+ if (schar < remaining_bytes)
38+ ptr += schar;
39+ else
40+ ptr = lim;
41
42 return ptr;
43 }
44@@ -1746,7 +1750,11 @@ limfield (struct line const *line, struct keyfield const *key)
45 ++ptr;
46
47 /* Advance PTR by ECHAR (if possible), but no further than LIM. */
48- ptr = MIN (lim, ptr + echar);
49+ size_t remaining_bytes = lim - ptr;
50+ if (echar < remaining_bytes)
51+ ptr += echar;
52+ else
53+ ptr = lim;
54 }
55
56 return ptr;
57diff --git a/tests/local.mk b/tests/local.mk
58index 4da6756ac..642d225fa 100644
59--- a/tests/local.mk
60+++ b/tests/local.mk
61@@ -388,6 +388,7 @@ all_tests = \
62 tests/sort/sort-debug-keys.sh \
63 tests/sort/sort-debug-warn.sh \
64 tests/sort/sort-discrim.sh \
65+ tests/sort/sort-field-limit.sh \
66 tests/sort/sort-files0-from.pl \
67 tests/sort/sort-float.sh \
68 tests/sort/sort-h-thousands-sep.sh \
69diff --git a/tests/sort/sort-field-limit.sh b/tests/sort/sort-field-limit.sh
70new file mode 100755
71index 000000000..52d8e1d17
72--- /dev/null
73+++ b/tests/sort/sort-field-limit.sh
74@@ -0,0 +1,35 @@
75+#!/bin/sh
76+# From 7.2-9.7, this would trigger an out of bounds mem read
77+
78+# Copyright (C) 2025 Free Software Foundation, Inc.
79+
80+# This program is free software: you can redistribute it and/or modify
81+# it under the terms of the GNU General Public License as published by
82+# the Free Software Foundation, either version 3 of the License, or
83+# (at your option) any later version.
84+
85+# This program is distributed in the hope that it will be useful,
86+# but WITHOUT ANY WARRANTY; without even the implied warranty of
87+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
88+# GNU General Public License for more details.
89+
90+# You should have received a copy of the GNU General Public License
91+# along with this program. If not, see <https://www.gnu.org/licenses/>.
92+
93+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
94+print_ver_ sort
95+getlimits_
96+
97+# This issue triggers with valgrind or ASAN
98+valgrind --error-exitcode=1 sort --version 2>/dev/null &&
99+ VALGRIND='valgrind --error-exitcode=1'
100+
101+{ printf '%s\n' aa bb; } > in || framework_failure_
102+
103+_POSIX2_VERSION=200809 $VALGRIND sort +0.${SIZE_MAX}R in > out || fail=1
104+compare in out || fail=1
105+
106+_POSIX2_VERSION=200809 $VALGRIND sort +1 -1.${SIZE_MAX}R in > out || fail=1
107+compare in out || fail=1
108+
109+Exit $fail
110--
1112.34.1
112
diff --git a/meta/recipes-core/coreutils/coreutils/0001-uname-report-processor-and-hardware-correctly.patch b/meta/recipes-core/coreutils/coreutils/0001-uname-report-processor-and-hardware-correctly.patch
deleted file mode 100644
index 3c43e1d5da..0000000000
--- a/meta/recipes-core/coreutils/coreutils/0001-uname-report-processor-and-hardware-correctly.patch
+++ /dev/null
@@ -1,64 +0,0 @@
1Upstream-Status: Denied
2
3Subject: uname: report processor and hardware correctly
4
5This patch is rejected by coreutils upstream, but distros like debian and fedora
6uses this patch to make `uname -i' and `uname -p' to not report 'unknown'.
7
8Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
9---
10 src/uname.c | 18 ++++++++++++++++--
11 1 file changed, 16 insertions(+), 2 deletions(-)
12
13diff --git a/src/uname.c b/src/uname.c
14index 39bd28c..c84582d 100644
15--- a/src/uname.c
16+++ b/src/uname.c
17@@ -299,13 +299,19 @@ main (int argc, char **argv)
18
19 if (toprint & PRINT_PROCESSOR)
20 {
21- char const *element = unknown;
22+ char *element = unknown;
23 #if HAVE_SYSINFO && defined SI_ARCHITECTURE
24 {
25 static char processor[257];
26 if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor))
27 element = processor;
28 }
29+#else
30+ {
31+ static struct utsname u;
32+ uname(&u);
33+ element = u.machine;
34+ }
35 #endif
36 #ifdef UNAME_PROCESSOR
37 if (element == unknown)
38@@ -343,7 +349,7 @@ main (int argc, char **argv)
39
40 if (toprint & PRINT_HARDWARE_PLATFORM)
41 {
42- char const *element = unknown;
43+ char *element = unknown;
44 #if HAVE_SYSINFO && defined SI_PLATFORM
45 {
46 static char hardware_platform[257];
47@@ -361,6 +367,14 @@ main (int argc, char **argv)
48 if (sysctl (mib, 2, hardware_platform, &s, 0, 0) >= 0)
49 element = hardware_platform;
50 }
51+#else
52+ {
53+ static struct utsname u;
54+ uname(&u);
55+ element = u.machine;
56+ if(strlen(element)==4 && element[0]=='i' && element[2]=='8' && element[3]=='6')
57+ element[1]='3';
58+ }
59 #endif
60 if (! (toprint == UINT_MAX && element == unknown))
61 print_element (element);
62--
631.9.1
64
diff --git a/meta/recipes-core/coreutils/coreutils/disable-ls-output-quoting.patch b/meta/recipes-core/coreutils/coreutils/disable-ls-output-quoting.patch
deleted file mode 100644
index e68c213550..0000000000
--- a/meta/recipes-core/coreutils/coreutils/disable-ls-output-quoting.patch
+++ /dev/null
@@ -1,49 +0,0 @@
1Subject: revert inconsistent ls quoting
2
3This is a revert of upstream commit 109b9220cead6e979d22d16327c4d9f8350431cc.
4
5Bug-Debian: https://bugs.debian.org/813164
6
7Upstream-Status: Submitted
8
9Originally-by: Adam Borowski <kilobyte@angband.pl>
10[PG: patch from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=813164#78 ]
11Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
12
13---
14
15--- coreutils-8.25.orig/NEWS
16+++ coreutils-8.25/NEWS
17@@ -71,9 +71,6 @@ GNU coreutils NEWS
18 df now prefers sources towards the root of a device when
19 eliding duplicate bind mounted entries.
20
21- ls now quotes file names unambiguously and appropriate for use in a shell,
22- when outputting to a terminal.
23-
24 join, sort, uniq with --zero-terminated, now treat '\n' as a field delimiter.
25
26 ** Improvements
27--- coreutils-8.25.orig/doc/coreutils.texi
28+++ coreutils-8.25/doc/coreutils.texi
29@@ -7750,8 +7750,8 @@ this"} in the default C locale. This lo
30
31 You can specify the default value of the @option{--quoting-style} option
32 with the environment variable @env{QUOTING_STYLE}@. If that environment
33-variable is not set, the default value is @samp{shell-escape} when the
34-output is a terminal, and @samp{literal} otherwise.
35+variable is not set, the default value is @samp{literal}, but this
36+default may change to @samp{shell} in a future version of this package.
37
38 @item --show-control-chars
39 @opindex --show-control-chars
40--- coreutils-8.25.orig/src/ls.c
41+++ coreutils-8.25/src/ls.c
42@@ -1581,7 +1581,6 @@ decode_switches (int argc, char **argv)
43 if (isatty (STDOUT_FILENO))
44 {
45 format = many_per_line;
46- set_quoting_style (NULL, shell_escape_quoting_style);
47 /* See description of qmark_funny_chars, above. */
48 qmark_funny_chars = true;
49 }
diff --git a/meta/recipes-core/coreutils/coreutils/fix-selinux-flask.patch b/meta/recipes-core/coreutils/coreutils/fix-selinux-flask.patch
deleted file mode 100644
index 173a57925b..0000000000
--- a/meta/recipes-core/coreutils/coreutils/fix-selinux-flask.patch
+++ /dev/null
@@ -1,36 +0,0 @@
1From 7e20a7242ba2657f73311bbf5278093da67f0721 Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Tue, 16 Sep 2014 01:59:08 -0700
4Subject: [PATCH] gnulib-comp.m4: selinux/flask.h should respect to
5 with_selinux
6
7Fixed when build with meta-selinux even when --without-selinux:
8runcon.c:49:28: fatal error: selinux/flask.h: No such file or directory
9 # include <selinux/flask.h>
10 ^
11compilation terminated.
12
13Upstream-Status: Pending
14
15Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
16
17---
18 m4/gnulib-comp.m4 | 2 +-
19 1 file changed, 1 insertion(+), 1 deletion(-)
20
21diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
22index dead90e..0abf0bd 100644
23--- a/m4/gnulib-comp.m4
24+++ b/m4/gnulib-comp.m4
25@@ -1860,10 +1860,10 @@ AC_DEFUN([gl_INIT],
26 AC_LIBOBJ([select])
27 fi
28 gl_SYS_SELECT_MODULE_INDICATOR([select])
29- AC_CHECK_HEADERS([selinux/flask.h])
30 gl_HEADERS_SELINUX_SELINUX_H
31 gl_HEADERS_SELINUX_CONTEXT_H
32 if test "$with_selinux" != no && test "$ac_cv_header_selinux_selinux_h" = yes; then
33+ AC_CHECK_HEADERS([selinux/flask.h])
34 AC_LIBOBJ([getfilecon])
35 fi
36 gl_SERVENT
diff --git a/meta/recipes-core/coreutils/coreutils/remove-usr-local-lib-from-m4.patch b/meta/recipes-core/coreutils/coreutils/remove-usr-local-lib-from-m4.patch
index 1a8a9b9983..718de0ab78 100644
--- a/meta/recipes-core/coreutils/coreutils/remove-usr-local-lib-from-m4.patch
+++ b/meta/recipes-core/coreutils/coreutils/remove-usr-local-lib-from-m4.patch
@@ -1,4 +1,4 @@
1From a26530083a29eeee910bfd606ecc621acecd547a Mon Sep 17 00:00:00 2001 1From f53ffb5b27ab7d4a4c62df00ebd6a1a6936d1709 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 3 Aug 2011 14:12:30 -0700 3Date: Wed, 3 Aug 2011 14:12:30 -0700
4Subject: [PATCH] coreutils: Fix build on uclibc 4Subject: [PATCH] coreutils: Fix build on uclibc
@@ -12,16 +12,15 @@ and make life easier for cross compilation process.
12Signed-off-by: Khem Raj <raj.khem@gmail.com> 12Signed-off-by: Khem Raj <raj.khem@gmail.com>
13 13
14Upstream-Status: Inappropriate [Upstream does care for AIX while we may not] 14Upstream-Status: Inappropriate [Upstream does care for AIX while we may not]
15
16--- 15---
17 m4/getloadavg.m4 | 12 ------------ 16 m4/getloadavg.m4 | 12 ------------
18 1 file changed, 12 deletions(-) 17 1 file changed, 12 deletions(-)
19 18
20diff --git a/m4/getloadavg.m4 b/m4/getloadavg.m4 19diff --git a/m4/getloadavg.m4 b/m4/getloadavg.m4
21index 8e96965..63782a2 100644 20index 9d0236f..68f7c52 100644
22--- a/m4/getloadavg.m4 21--- a/m4/getloadavg.m4
23+++ b/m4/getloadavg.m4 22+++ b/m4/getloadavg.m4
24@@ -41,18 +41,6 @@ AC_CHECK_FUNC([getloadavg], [], 23@@ -46,18 +46,6 @@ if test $ac_cv_func_getloadavg != yes; then
25 [LIBS="-lutil $LIBS" gl_func_getloadavg_done=yes]) 24 [LIBS="-lutil $LIBS" gl_func_getloadavg_done=yes])
26 fi 25 fi
27 26
diff --git a/meta/recipes-core/coreutils/coreutils_8.32.bb b/meta/recipes-core/coreutils/coreutils_9.7.bb
index c1962ccb90..5a6456d65e 100644
--- a/meta/recipes-core/coreutils/coreutils_8.32.bb
+++ b/meta/recipes-core/coreutils/coreutils_9.7.bb
@@ -4,51 +4,50 @@ manipulation utilities. These are the core utilities which are expected to exist
4every system." 4every system."
5HOMEPAGE = "http://www.gnu.org/software/coreutils/" 5HOMEPAGE = "http://www.gnu.org/software/coreutils/"
6BUGTRACKER = "http://debbugs.gnu.org/coreutils" 6BUGTRACKER = "http://debbugs.gnu.org/coreutils"
7LICENSE = "GPLv3+" 7LICENSE = "GPL-3.0-or-later"
8LIC_FILES_CHKSUM = "file://COPYING;md5=1ebbd3e34237af26da5dc08a4e440464 \ 8LIC_FILES_CHKSUM = "file://COPYING;md5=1ebbd3e34237af26da5dc08a4e440464 \
9 file://src/ls.c;beginline=1;endline=15;md5=b7d80abf5b279320fb0e4b1007ed108b \ 9 file://src/ls.c;beginline=1;endline=15;md5=824c1997414aea9f344747bd81cf5a31 \
10 " 10 "
11DEPENDS = "gmp libcap" 11DEPENDS = "gmp libcap"
12DEPENDS_class-native = "" 12DEPENDS:class-native = ""
13 13
14inherit autotools gettext texinfo 14inherit autotools gettext texinfo
15 15
16SRC_URI = "${GNU_MIRROR}/coreutils/${BP}.tar.xz \ 16SRC_URI = "${GNU_MIRROR}/coreutils/${BP}.tar.xz \
17 file://remove-usr-local-lib-from-m4.patch \ 17 file://remove-usr-local-lib-from-m4.patch \
18 file://fix-selinux-flask.patch \ 18 file://0001-sort-fix-buffer-under-read-CWE-127.patch \
19 file://0001-uname-report-processor-and-hardware-correctly.patch \
20 file://disable-ls-output-quoting.patch \
21 file://0001-local.mk-fix-cross-compiling-problem.patch \
22 file://run-ptest \ 19 file://run-ptest \
23 file://0001-ls-restore-8.31-behavior-on-removed-directories.patch \
24 " 20 "
21SRC_URI[sha256sum] = "e8bb26ad0293f9b5a1fc43fb42ba970e312c66ce92c1b0b16713d7500db251bf"
25 22
26SRC_URI[md5sum] = "022042695b7d5bcf1a93559a9735e668" 23# http://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=v8.27-101-gf5d7c0842
27SRC_URI[sha256sum] = "4458d8de7849df44ccab15e16b1548b285224dbba5f08fac070c1c0e0bcc4cfa" 24#
25CVE_STATUS[CVE-2016-2781] = "disputed: runcon is not really a sandbox command, use `runcon ... setsid ...` to avoid this particular issue."
28 26
29EXTRA_OECONF_class-native = "--without-gmp" 27EXTRA_OECONF:class-target = "--enable-install-program=arch,hostname --libexecdir=${libdir}"
30EXTRA_OECONF_class-target = "--enable-install-program=arch,hostname --libexecdir=${libdir}" 28EXTRA_OECONF:class-nativesdk = "--enable-install-program=arch,hostname"
31EXTRA_OECONF_class-nativesdk = "--enable-install-program=arch,hostname"
32 29
33# acl and xattr are not default features 30# acl and xattr are not default features
34# 31#
35PACKAGECONFIG_class-target ??= "\ 32PACKAGECONFIG:class-target ??= "\
36 ${@bb.utils.filter('DISTRO_FEATURES', 'acl xattr', d)} \ 33 ${@bb.utils.filter('DISTRO_FEATURES', 'acl xattr', d)} \
37" 34"
38 35
39# The lib/oe/path.py requires xattr 36# The lib/oe/path.py requires xattr
40PACKAGECONFIG_class-native ??= "xattr" 37PACKAGECONFIG:class-native ??= "xattr"
41 38
42# oe-core builds need xattr support 39# oe-core builds need xattr support
43PACKAGECONFIG_class-nativesdk ??= "xattr" 40PACKAGECONFIG:class-nativesdk ??= "xattr"
44 41
45# with, without, depends, rdepends 42# with, without, depends, rdepends
46# 43#
47PACKAGECONFIG[acl] = "--enable-acl,--disable-acl,acl," 44PACKAGECONFIG[acl] = "--enable-acl,--disable-acl,acl,"
48PACKAGECONFIG[xattr] = "--enable-xattr,--disable-xattr,attr," 45PACKAGECONFIG[xattr] = "--enable-xattr,--disable-xattr,attr,"
49PACKAGECONFIG[single-binary] = "--enable-single-binary,--disable-single-binary,," 46PACKAGECONFIG[single-binary] = "--enable-single-binary,--disable-single-binary,,"
47PACKAGECONFIG[selinux] = "--with-selinux,--without-selinux,libselinux"
48PACKAGECONFIG[openssl] = "--with-openssl=yes,--with-openssl=no,openssl"
50 49
51# [ df mktemp nice printenv base64 gets a special treatment and is not included in this 50# [ base32 base64 df mktemp nice printenv get a special treatment and are not included in this
52bindir_progs = "arch basename chcon cksum comm csplit cut dir dircolors dirname du \ 51bindir_progs = "arch basename chcon cksum comm csplit cut dir dircolors dirname du \
53 env expand expr factor fmt fold groups head hostid id install \ 52 env expand expr factor fmt fold groups head hostid id install \
54 join link logname md5sum mkfifo nl nohup nproc od paste pathchk \ 53 join link logname md5sum mkfifo nl nohup nproc od paste pathchk \
@@ -56,48 +55,41 @@ bindir_progs = "arch basename chcon cksum comm csplit cut dir dircolors dirname
56 sha384sum sha512sum shred shuf sort split sum tac tail tee test timeout \ 55 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" 56 tr truncate tsort tty unexpand uniq unlink uptime users vdir wc who whoami yes"
58 57
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 \ 58base_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" 59 mknod mv pwd rm rmdir sleep stty sync touch true uname stat"
62 60
63sbindir_progs= "chroot" 61sbindir_progs = "chroot"
64 62
65# Split stdbuf into its own package, so one can include 63# Split stdbuf into its own package, so one can include
66# coreutils-stdbuf without getting the rest of coreutils, but make 64# coreutils-stdbuf without getting the rest of coreutils, but make
67# coreutils itself pull in stdbuf, so IMAGE_INSTALL += "coreutils" 65# coreutils itself pull in stdbuf, so IMAGE_INSTALL += "coreutils"
68# always provides all coreutils 66# always provides all coreutils
69PACKAGE_BEFORE_PN_class-target += "${@bb.utils.contains('PACKAGECONFIG', 'single-binary', '', 'coreutils-stdbuf', d)}" 67PACKAGE_BEFORE_PN:class-target += "${@bb.utils.contains('PACKAGECONFIG', 'single-binary', '', 'coreutils-stdbuf', d)}"
70FILES_coreutils-stdbuf = "${bindir}/stdbuf ${libdir}/coreutils/libstdbuf.so" 68FILES:coreutils-stdbuf = "${bindir}/stdbuf ${libdir}/coreutils/libstdbuf.so"
71RDEPENDS_coreutils_class-target += "${@bb.utils.contains('PACKAGECONFIG', 'single-binary', '', 'coreutils-stdbuf', d)}" 69RDEPENDS:coreutils:class-target += "${@bb.utils.contains('PACKAGECONFIG', 'single-binary', '', 'coreutils-stdbuf', d)}"
72 70
73# However, when the single-binary PACKAGECONFIG is used, stdbuf 71# However, when the single-binary PACKAGECONFIG is used, stdbuf
74# functionality is built into the single coreutils binary, so there's 72# functionality is built into the single coreutils binary, so there's
75# no point splitting /usr/bin/stdbuf to its own package. Instead, add 73# no point splitting /usr/bin/stdbuf to its own package. Instead, add
76# an RPROVIDE so that rdepending on coreutils-stdbuf will work 74# an RPROVIDE so that rdepending on coreutils-stdbuf will work
77# regardless of whether single-binary is in effect. 75# regardless of whether single-binary is in effect.
78RPROVIDES_coreutils += "${@bb.utils.contains('PACKAGECONFIG', 'single-binary', 'coreutils-stdbuf', '', d)}" 76RPROVIDES: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 77
86# Deal with a separate builddir failure if src doesn't exist when creating version.c/version.h 78# Deal with a separate builddir failure if src doesn't exist when creating version.c/version.h
87do_compile_prepend () { 79do_compile:prepend () {
88 mkdir -p ${B}/src 80 mkdir -p ${B}/src
89} 81}
90 82
91do_install_class-native() { 83do_install:class-native() {
92 autotools_do_install 84 autotools_do_install
93 # remove groups to fix conflict with shadow-native 85 # remove groups to fix conflict with shadow-native
94 rm -f ${D}${STAGING_BINDIR_NATIVE}/groups 86 rm -f ${D}${STAGING_BINDIR_NATIVE}/groups
95 # The return is a must since native doesn't need the 87 # The return is a must since native doesn't need the
96 # do_install_append() in the below. 88 # do_install:append() in the below.
97 return 89 return
98} 90}
99 91
100do_install_append() { 92do_install:append() {
101 for i in df mktemp nice printenv base64; do mv ${D}${bindir}/$i ${D}${bindir}/$i.${BPN}; done 93 for i in df mktemp nice printenv base64; do mv ${D}${bindir}/$i ${D}${bindir}/$i.${BPN}; done
102 94
103 install -d ${D}${base_bindir} 95 install -d ${D}${base_bindir}
@@ -117,8 +109,8 @@ inherit update-alternatives
117ALTERNATIVE_PRIORITY = "100" 109ALTERNATIVE_PRIORITY = "100"
118# Make hostname's priority higher than busybox but lower than net-tools 110# Make hostname's priority higher than busybox but lower than net-tools
119ALTERNATIVE_PRIORITY[hostname] = "90" 111ALTERNATIVE_PRIORITY[hostname] = "90"
120ALTERNATIVE_${PN} = "lbracket ${bindir_progs} ${base_bindir_progs} ${sbindir_progs} base32 base64 nice printenv mktemp df" 112ALTERNATIVE:${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" 113ALTERNATIVE:${PN}-doc = "base64.1 nice.1 mktemp.1 df.1 groups.1 kill.1 uptime.1 stat.1 hostname.1"
122 114
123ALTERNATIVE_LINK_NAME[hostname.1] = "${mandir}/man1/hostname.1" 115ALTERNATIVE_LINK_NAME[hostname.1] = "${mandir}/man1/hostname.1"
124 116
@@ -149,6 +141,13 @@ ALTERNATIVE_LINK_NAME[uptime.1] = "${mandir}/man1/uptime.1"
149ALTERNATIVE_LINK_NAME[kill.1] = "${mandir}/man1/kill.1" 141ALTERNATIVE_LINK_NAME[kill.1] = "${mandir}/man1/kill.1"
150ALTERNATIVE_LINK_NAME[stat.1] = "${mandir}/man1/stat.1" 142ALTERNATIVE_LINK_NAME[stat.1] = "${mandir}/man1/stat.1"
151 143
144# The statx() requires glibc >= 2.28 and linux kernel >= 4.11, it doesn't work
145# when glibc >= 2.28 ((Ubuntu 20.04 in docker) and kernel < 4.11 (Host OS
146# CentOS 7), we can check kernel version and disable it, but that would cause
147# two different signatures for coreutils-native, so disable it unconditionally
148# for deterministic build.
149EXTRA_OECONF:append:class-native = " ac_cv_func_statx=0"
150
152python __anonymous() { 151python __anonymous() {
153 for prog in d.getVar('base_bindir_progs').split(): 152 for prog in d.getVar('base_bindir_progs').split():
154 d.setVarFlag('ALTERNATIVE_LINK_NAME', prog, '%s/%s' % (d.getVar('base_bindir'), prog)) 153 d.setVarFlag('ALTERNATIVE_LINK_NAME', prog, '%s/%s' % (d.getVar('base_bindir'), prog))
@@ -161,19 +160,22 @@ BBCLASSEXTEND = "native nativesdk"
161 160
162inherit ptest 161inherit ptest
163 162
164RDEPENDS_${PN}-ptest += "bash findutils gawk liberror-perl make perl perl-modules python3-core sed shadow" 163RDEPENDS:${PN}-ptest += "bash findutils gawk make perl perl-modules python3-core sed shadow"
165 164
166# -dev automatic dependencies fails as we don't want libmodule-build-perl-dev, its too heavy 165# -dev automatic dependencies fails as we don't want libmodule-build-perl-dev, its too heavy
167# may need tweaking if DEPENDS changes 166# may need tweaking if DEPENDS changes
168RRECOMMENDS_coreutils-dev[nodeprrecs] = "1" 167# Can't use ${PN}-dev here since flags with overrides and key expansion not supported
169RRECOMMENDS_coreutils-dev = "acl-dev attr-dev gmp-dev libcap-dev bash-dev findutils-dev gawk-dev shadow-dev" 168RRECOMMENDS:coreutils-dev[nodeprrecs] = "1"
169DEVDEPS = "acl-dev attr-dev gmp-dev libcap-dev bash-dev findutils-dev gawk-dev shadow-dev"
170DEVDEPS:class-native = ""
171RRECOMMENDS:${PN}-dev += "${DEVDEPS}"
170 172
171do_install_ptest () { 173do_install_ptest () {
172 install -d ${D}${PTEST_PATH}/tests 174 install -d ${D}${PTEST_PATH}/tests
173 cp -r ${S}/tests/* ${D}${PTEST_PATH}/tests 175 cp -r ${S}/tests/* ${D}${PTEST_PATH}/tests
174 sed -i 's/ginstall/install/g' `grep -R ginstall ${D}${PTEST_PATH}/tests | awk -F: '{print $1}' | uniq`
175 install -d ${D}${PTEST_PATH}/build-aux 176 install -d ${D}${PTEST_PATH}/build-aux
176 install ${S}/build-aux/test-driver ${D}${PTEST_PATH}/build-aux/ 177 install ${S}/build-aux/test-driver ${D}${PTEST_PATH}/build-aux/
178 install -Dm 0644 ${B}/lib/config.h ${D}${PTEST_PATH}/lib/config.h
177 cp ${B}/Makefile ${D}${PTEST_PATH}/ 179 cp ${B}/Makefile ${D}${PTEST_PATH}/
178 cp ${S}/init.cfg ${D}${PTEST_PATH}/ 180 cp ${S}/init.cfg ${D}${PTEST_PATH}/
179 cp -r ${B}/src ${D}${PTEST_PATH}/ 181 cp -r ${B}/src ${D}${PTEST_PATH}/
@@ -184,7 +186,8 @@ do_install_ptest () {
184 sed -i '/^abs_srcdir/s/= .*$/= \$\{PWD\}/g' ${D}${PTEST_PATH}/Makefile 186 sed -i '/^abs_srcdir/s/= .*$/= \$\{PWD\}/g' ${D}${PTEST_PATH}/Makefile
185 sed -i '/^abs_top_builddir/s/= .*$/= \$\{PWD\}/g' ${D}${PTEST_PATH}/Makefile 187 sed -i '/^abs_top_builddir/s/= .*$/= \$\{PWD\}/g' ${D}${PTEST_PATH}/Makefile
186 sed -i '/^abs_top_srcdir/s/= .*$/= \$\{PWD\}/g' ${D}${PTEST_PATH}/Makefile 188 sed -i '/^abs_top_srcdir/s/= .*$/= \$\{PWD\}/g' ${D}${PTEST_PATH}/Makefile
187 sed -i '/^built_programs/s/ginstall/install/g' ${D}${PTEST_PATH}/Makefile 189 sed -i '/^CC =/s/ --sysroot=.*recipe-sysroot/ /g' ${D}${PTEST_PATH}/Makefile
190 sed -i '/^BUILD_LDFLAGS =/d' ${D}${PTEST_PATH}/Makefile
188 chmod -R 777 ${D}${PTEST_PATH} 191 chmod -R 777 ${D}${PTEST_PATH}
189 192
190 # Disable subcase stty-pairs.sh, it will cause test framework hang 193 # Disable subcase stty-pairs.sh, it will cause test framework hang
@@ -195,13 +198,27 @@ do_install_ptest () {
195 198
196 # Tweak test d_type-check to use python3 instead of python 199 # Tweak test d_type-check to use python3 instead of python
197 sed -i "1s@.*@#!/usr/bin/python3@" ${D}${PTEST_PATH}/tests/d_type-check 200 sed -i "1s@.*@#!/usr/bin/python3@" ${D}${PTEST_PATH}/tests/d_type-check
201
202 # Fix for single-binary
203 for prog in ${D}${PTEST_PATH}/src/*; do
204 if [ -f $prog ]; then
205 sed -i "1s@#!.*/src/coreutils @#!${bindir}/coreutils @" $prog
206 fi
207 done
208
198 install ${B}/src/getlimits ${D}/${bindir} 209 install ${B}/src/getlimits ${D}/${bindir}
199
200 # handle multilib 210 # handle multilib
201 sed -i s:@libdir@:${libdir}:g ${D}${PTEST_PATH}/run-ptest 211 sed -i s:@libdir@:${libdir}:g ${D}${PTEST_PATH}/run-ptest
202} 212}
203 213
204FILES_${PN}-ptest += "${bindir}/getlimits" 214do_install_ptest:append:libc-musl () {
215 # these tests fail due to bash on musl systems
216 # xmalloc: cannot allocate 16146 bytes
217 sed -i -e '/tests\/dd\/no-allocate.sh/d' ${D}${PTEST_PATH}/Makefile
218 sed -i -e '/tests\/split\/line-bytes.sh/d' ${D}${PTEST_PATH}/Makefile
219}
205 220
206# These are specific to Opensuse 221RDEPENDS:${PN}-ptest += "xz \
207CVE_WHITELIST += "CVE-2013-0221 CVE-2013-0222 CVE-2013-0223" 222 ${@bb.utils.contains('PACKAGECONFIG', 'acl', 'acl', '', d)} \
223 ${@bb.utils.contains('PACKAGECONFIG', 'xattr', 'attr', '', d)}"
224FILES:${PN}-ptest += "${bindir}/getlimits"