diff options
author | Dmitry Kalinkin <dmitry.kalinkin@gmail.com> | 2021-12-25 17:16:26 -0500 |
---|---|---|
committer | Dmitry Kalinkin <dmitry.kalinkin@gmail.com> | 2021-12-25 17:16:26 -0500 |
commit | 2ddda439248897bf11e7d6d7fa5fb1b69dbe4704 (patch) | |
tree | 469dea13a28e68cfbb52978bbac9693212d2c44b /pkgs/tools/misc/coreutils | |
parent | bfe3ae8db7b395964d0f0d8f759bb9af97e10988 (diff) | |
parent | cafbe8171c8a36d8f4fa843c1d4d893a61489112 (diff) |
Merge branch 'staging' into staging-next
Conflicts: pkgs/os-specific/linux/kernel/common-config.nix
Diffstat (limited to 'pkgs/tools/misc/coreutils')
-rw-r--r-- | pkgs/tools/misc/coreutils/default.nix | 3 | ||||
-rw-r--r-- | pkgs/tools/misc/coreutils/fix-arm64-macos.patch | 124 |
2 files changed, 127 insertions, 0 deletions
diff --git a/pkgs/tools/misc/coreutils/default.nix b/pkgs/tools/misc/coreutils/default.nix index e6809b474ea2f..befe53b9d907a 100644 --- a/pkgs/tools/misc/coreutils/default.nix +++ b/pkgs/tools/misc/coreutils/default.nix @@ -33,6 +33,9 @@ stdenv.mkDerivation (rec { ./fix-chmod-exit-code.patch # Workaround for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=51433 ./disable-seek-hole.patch + # Workaround for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=52330 + # This patch can be dropped, once we upgrade to the next coreutils version after 9.0 + ./fix-arm64-macos.patch ]; postPatch = '' diff --git a/pkgs/tools/misc/coreutils/fix-arm64-macos.patch b/pkgs/tools/misc/coreutils/fix-arm64-macos.patch new file mode 100644 index 0000000000000..d8880b23dcbfc --- /dev/null +++ b/pkgs/tools/misc/coreutils/fix-arm64-macos.patch @@ -0,0 +1,124 @@ +diff --git a/src/uname.c b/src/uname.c +index ae9b8e29d..e84fc477a 100644 +--- a/src/uname.c ++++ b/src/uname.c +@@ -27,7 +27,7 @@ + # include <sys/systeminfo.h> + #endif + +-#if HAVE_SYS_SYSCTL_H && ! defined __GLIBC__ ++#if HAVE_SYS_SYSCTL_H && ! defined __GLIBC__ && ! defined __APPLE__ + # if HAVE_SYS_PARAM_H + # include <sys/param.h> /* needed for OpenBSD 3.0 */ + # endif +@@ -44,11 +44,6 @@ + # endif + #endif + +-#ifdef __APPLE__ +-# include <mach/machine.h> +-# include <mach-o/arch.h> +-#endif +- + #include "system.h" + #include "die.h" + #include "error.h" +@@ -167,6 +162,24 @@ print_element (char const *element) + fputs (element, stdout); + } + ++/* Print ELEMENT, preceded by a space if something has already been ++ printed. But if the environment variable ENVVAR is set, print its ++ value instead of ELEMENT. */ ++ ++static void ++print_element_env (char const *element, char const *envvar) ++{ ++#ifdef __APPLE__ ++ if (envvar) ++ { ++ char const *val = getenv (envvar); ++ if (val) ++ element = val; ++ } ++#endif ++ print_element (element); ++} ++ + + /* Set all the option flags according to the switches specified. + Return the mask indicating which elements to print. */ +@@ -287,26 +300,36 @@ main (int argc, char **argv) + die (EXIT_FAILURE, errno, _("cannot get system name")); + + if (toprint & PRINT_KERNEL_NAME) +- print_element (name.sysname); ++ print_element_env (name.sysname, "UNAME_SYSNAME"); + if (toprint & PRINT_NODENAME) +- print_element (name.nodename); ++ print_element_env (name.nodename, "UNAME_NODENAME"); + if (toprint & PRINT_KERNEL_RELEASE) +- print_element (name.release); ++ print_element_env (name.release, "UNAME_RELEASE"); + if (toprint & PRINT_KERNEL_VERSION) +- print_element (name.version); ++ print_element_env (name.version, "UNAME_VERSION"); + if (toprint & PRINT_MACHINE) +- print_element (name.machine); ++ print_element_env (name.machine, "UNAME_MACHINE"); + } + + if (toprint & PRINT_PROCESSOR) + { + char const *element = unknown; ++#ifdef __APPLE__ ++# if defined __arm__ || defined __arm64__ ++ element = "arm"; ++# elif defined __i386__ || defined __x86_64__ ++ element = "i386"; ++# elif defined __ppc__ || defined __ppc64__ ++ element = "powerpc"; ++# endif ++#endif + #if HAVE_SYSINFO && defined SI_ARCHITECTURE +- { +- static char processor[257]; +- if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor)) +- element = processor; +- } ++ if (element == unknown) ++ { ++ static char processor[257]; ++ if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor)) ++ element = processor; ++ } + #endif + #ifdef UNAME_PROCESSOR + if (element == unknown) +@@ -316,26 +339,6 @@ main (int argc, char **argv) + static int mib[] = { CTL_HW, UNAME_PROCESSOR }; + if (sysctl (mib, 2, processor, &s, 0, 0) >= 0) + element = processor; +- +-# ifdef __APPLE__ +- /* This kludge works around a bug in Mac OS X. */ +- if (element == unknown) +- { +- cpu_type_t cputype; +- size_t cs = sizeof cputype; +- NXArchInfo const *ai; +- if (sysctlbyname ("hw.cputype", &cputype, &cs, NULL, 0) == 0 +- && (ai = NXGetArchInfoFromCpuType (cputype, +- CPU_SUBTYPE_MULTIPLE)) +- != NULL) +- element = ai->name; +- +- /* Hack "safely" around the ppc vs. powerpc return value. */ +- if (cputype == CPU_TYPE_POWERPC +- && STRNCMP_LIT (element, "ppc") == 0) +- element = "powerpc"; +- } +-# endif + } + #endif + if (! (toprint == UINT_MAX && element == unknown)) |