From 63bfe3cc6d526f9fcbf4e249531f6a48c53ef823 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sun, 22 Sep 2024 17:00:25 -0400 Subject: [PATCH] darwin.text_cmds: 99 -> 190.0.1 https://github.com/apple-oss-distributions/text_cmds/compare/text_cmds-99...text_cmds-190.0.1 --- .../text_cmds/meson.build.in | 71 +++++++++++-------- .../text_cmds/package.nix | 34 +++++++-- ...ability-check-for-__collate_lookup_l.patch | 54 ++++++++++++++ .../apple-source-releases/versions.json | 4 +- 4 files changed, 128 insertions(+), 35 deletions(-) create mode 100644 pkgs/os-specific/darwin/apple-source-releases/text_cmds/patches/0001-Use-availability-check-for-__collate_lookup_l.patch diff --git a/pkgs/os-specific/darwin/apple-source-releases/text_cmds/meson.build.in b/pkgs/os-specific/darwin/apple-source-releases/text_cmds/meson.build.in index d9933092fb22..6f89b31236b4 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/text_cmds/meson.build.in +++ b/pkgs/os-specific/darwin/apple-source-releases/text_cmds/meson.build.in @@ -6,6 +6,9 @@ project('text_cmds', 'c', version : '@version@') add_global_arguments( # Many programs use old prototypes '-Wno-deprecated-non-prototype', + # Needed to build errx functions from Libc + '-include', 'crt_externs.h', + '-D_getprogname()=(*_NSGetProgname())', language : 'c', ) @@ -16,6 +19,7 @@ cc = meson.get_compiler('c') bzip2 = dependency('bzip2') libbsd = dependency('libbsd-overlay', required : false) +libmd = dependency('libmd') libresolv = cc.find_library('resolv') libutil = cc.find_library('util') libxo = dependency('libxo') @@ -42,6 +46,7 @@ executable( 'bintrans/qp.c', 'bintrans/uudecode.c', 'bintrans/uuencode.c', + fs.exists('err-libc.c') ? 'err-libc.c' : [ ], ], ) install_man( @@ -78,14 +83,20 @@ executable( 'col', dependencies : [ libbsd ], install : true, - sources : [ 'col/col.c' ], + sources : [ + 'col/col.c', + fs.exists('err-libc.c') ? 'err-libc.c' : [ ], + ], ) install_man('col/col.1') executable( 'colrm', install : true, - sources : [ 'colrm/colrm.c' ], + sources : [ + 'colrm/colrm.c', + fs.exists('err-libc.c') ? 'err-libc.c' : [ ], + ], ) install_man('colrm/colrm.1') @@ -99,14 +110,20 @@ install_man('column/column.1') executable( 'comm', install : true, - sources : [ 'comm/comm.c' ], + sources : [ + 'comm/comm.c', + fs.exists('err-libc.c') ? 'err-libc.c' : [ ], + ], ) install_man('comm/comm.1') executable( 'csplit', install : true, - sources : [ 'csplit/csplit.c' ], + sources : [ + 'csplit/csplit.c', + fs.exists('err-libc.c') ? 'err-libc.c' : [ ], + ], ) install_man('csplit/csplit.1') @@ -135,26 +152,6 @@ install_man( 'ed/red.1', ) -executable( - 'ee', - c_args : [ '-Wno-format-security' ], - dependencies : [ ncurses ], - c_args : [ - '-DHAS_NCURSES', - '-DHAS_STDARG', - '-DHAS_STDLIB', - '-DHAS_SYS_WAIT', - '-DHAS_UNISTD', - '-DNO_CATGETS', - ], - install : true, - sources : [ - 'ee/ee.c', - 'ee/new_curse.c', - ], -) -install_man('ee/ee.1') - executable( 'expand', install : true, @@ -227,13 +224,28 @@ install_man('look/look.1') executable( 'md5', + dependencies : [ libmd ], install : true, - sources : [ - 'md5/commoncrypto.c', - 'md5/md5.c', - ], + sources : [ 'md5/md5.c' ], ) install_man('md5/md5.1') +foreach cmd : [ 'md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512' ] + foreach suffix : [ '', 'sum' ] + cmd += suffix + if cmd != 'md5' + install_symlink( + cmd, + install_dir : get_option('bindir'), + pointing_to : 'md5', + ) + install_symlink( + f'@cmd@.1', + install_dir : get_option('mandir') + '/man1', + pointing_to : 'md5.1', + ) + endif + endforeach +endforeach executable( 'nl', @@ -304,7 +316,7 @@ executable( executable( 'split', - dependencies : [ libutil ], + dependencies : [ libbsd, libutil ], install : true, sources : [ 'split/split.c' ], ) @@ -354,6 +366,7 @@ executable( executable( 'uniq', + dependencies : [ libbsd ], install : true, sources : [ 'uniq/uniq.c' ], ) diff --git a/pkgs/os-specific/darwin/apple-source-releases/text_cmds/package.nix b/pkgs/os-specific/darwin/apple-source-releases/text_cmds/package.nix index c7bf601df595..e97ca8081b75 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/text_cmds/package.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/text_cmds/package.nix @@ -5,13 +5,14 @@ apple-sdk_13, bzip2, libbsd, + libmd, libresolv, libutil, libxo, mkAppleDerivation, - shell_cmds, ncurses, pkg-config, + shell_cmds, stdenvNoCC, xz, zlib, @@ -56,12 +57,36 @@ mkAppleDerivation { "man" ]; - xcodeHash = "sha256-DzLrQ8CbInXj7PrV9jp3nHfE84A09ZwS729c9WXFV4Y="; + xcodeHash = "sha256-dZ+yJyfflhmUyx3gitRXC115QxS87SGC4/HjMa199Ts="; + + patches = lib.optionals (lib.versionOlder (lib.getVersion apple-sdk) "11.0") [ + ./patches/0001-Use-availability-check-for-__collate_lookup_l.patch + ]; postPatch = '' - # Fix format security errors - sed -e 's/wprintw(\([^,]*\), \([^)]*\))/wprintw(\1, "%s", \2)/g' -i ee/ee.c + # Improve compatiblity with libmd in nixpkgs. + substituteInPlace md5/md5.c \ + --replace-fail '' '' \ + --replace-fail SHA224_Init SHA224Init \ + --replace-fail SHA224_Update SHA224Update \ + --replace-fail SHA224_End SHA224End \ + --replace-fail SHA224_Data SHA224Data \ + --replace-fail SHA224_CTX SHA2_CTX \ + --replace-fail '' '' \ + --replace-fail 'const void *, unsigned int, char *' 'const uint8_t *, size_t, char *' + '' + + lib.optionalString (lib.versionOlder (lib.getVersion apple-sdk) "13.0") '' + # Backport vis APIs from the 13.3 SDK (needed by vis). + cp '${Libc_13}/gen/FreeBSD/vis.c' vis/vis-libc.c + # Backport errx APIs from the 13.3 SDK (needed by lots of things). + mkdir sys + cp '${Libc_13}/gen/FreeBSD/err.c' err-libc.c + cp '${Libc_13}/include/err.h' err.h + cp '${Libc_13}/fbsdcompat/sys/cdefs.h' sys/cdefs.h + substituteInPlace err.h \ + --replace-fail '__cold' "" + touch namespace.h un-namespace.h libc_private.h ''; env.NIX_CFLAGS_COMPILE = "-I${privateHeaders}/include"; @@ -70,6 +95,7 @@ mkAppleDerivation { buildInputs = [ bzip2 + libmd libresolv libutil libxo diff --git a/pkgs/os-specific/darwin/apple-source-releases/text_cmds/patches/0001-Use-availability-check-for-__collate_lookup_l.patch b/pkgs/os-specific/darwin/apple-source-releases/text_cmds/patches/0001-Use-availability-check-for-__collate_lookup_l.patch new file mode 100644 index 000000000000..55d24e5e27e6 --- /dev/null +++ b/pkgs/os-specific/darwin/apple-source-releases/text_cmds/patches/0001-Use-availability-check-for-__collate_lookup_l.patch @@ -0,0 +1,54 @@ +From 11ad41c2d3af88b5cf85d4bc2f5388b65e5ff347 Mon Sep 17 00:00:00 2001 +From: Randy Eckenrode +Date: Mon, 16 Sep 2024 12:42:59 -0400 +Subject: [PATCH] Use availability check for __collate_lookup_l + +--- + tr/str.c | 17 +++++++++++++++-- + 1 file changed, 15 insertions(+), 2 deletions(-) + +diff --git a/tr/str.c b/tr/str.c +index 6a79df2..8226abe 100644 +--- a/tr/str.c ++++ b/tr/str.c +@@ -69,6 +69,7 @@ static void genseq(STR *); + * Using libc internal function __collate_lookup_l for character + * equivalence + */ ++void __collate_lookup(const __darwin_wchar_t *, int *, int *, int *); + void __collate_lookup_l(const __darwin_wchar_t *, int *, int *, int *, + locale_t); + /* +@@ -255,7 +256,13 @@ genequiv(STR *s) + */ + int tprim, tsec; + int len; +- __collate_lookup_l(s->equiv, &len, &tprim, &tsec, LC_GLOBAL_LOCALE); ++ if (__builtin_available(macOS 11.0, *)) { ++ __collate_lookup_l(s->equiv, &len, &tprim, &tsec, LC_GLOBAL_LOCALE); ++ } else { ++ locale_t old = uselocale(LC_GLOBAL_LOCALE); ++ __collate_lookup(s->equiv, &len, &tprim, &tsec); ++ uselocale(old); ++ } + + if (tprim != -1) { + for (p = 1, i = 1; i < NCHARS_SB; i++) { +@@ -270,7 +277,13 @@ genequiv(STR *s) + * perform lookup of primary weight and fill cache + */ + int csec; +- __collate_lookup_l((__darwin_wchar_t *)&i, &len, &cprim, &csec, LC_GLOBAL_LOCALE); ++ if (__builtin_available(macOS 11.0, *)) { ++ __collate_lookup_l((__darwin_wchar_t *)&i, &len, &cprim, &csec, LC_GLOBAL_LOCALE); ++ } else { ++ locale_t old = uselocale(LC_GLOBAL_LOCALE); ++ __collate_lookup((__darwin_wchar_t *)&i, &len, &cprim, &csec); ++ uselocale(old); ++ } + collation_weight_cache[i] = cprim; + } + +-- +2.46.0 + diff --git a/pkgs/os-specific/darwin/apple-source-releases/versions.json b/pkgs/os-specific/darwin/apple-source-releases/versions.json index d158be455199..12675eac0885 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/versions.json +++ b/pkgs/os-specific/darwin/apple-source-releases/versions.json @@ -100,8 +100,8 @@ "version": "1012" }, "text_cmds": { - "hash": "sha256-KSebU7ZyUsPeqn51nzuGNaNxs9pvmlIQQdkWXIVzDxw=", - "version": "99" + "hash": "sha256-76dagwRcAf5fpoyH5FDR5kdCldv6Mgre6aFBzxaCRkg=", + "version": "190.0.1" }, "top": { "hash": "sha256-jbz64ODogtpNyLpXGSZj1jCBdFPVXcVcBkL1vc7g5qQ=",