darwin.text_cmds: convert to Meson and use mkAppleDerivation
This commit is contained in:
@@ -315,7 +315,7 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
|
||||
file_cmds = callPackage ./file_cmds/package.nix { };
|
||||
shell_cmds = callPackage ./shell_cmds/package.nix { };
|
||||
system_cmds = callPackage ./system_cmds/package.nix { };
|
||||
text_cmds = applePackage "text_cmds" "osx-10.11.6" "sha256-KSebU7ZyUsPeqn51nzuGNaNxs9pvmlIQQdkWXIVzDxw=" {};
|
||||
text_cmds = callPackage ./text_cmds/package.nix { };
|
||||
top = applePackage "top" "osx-10.11.6" "sha256-jbz64ODogtpNyLpXGSZj1jCBdFPVXcVcBkL1vc7g5qQ=" {};
|
||||
PowerManagement = callPackage ./PowerManagement/package.nix { };
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
{ lib, appleDerivation, xcbuildHook, ncurses, bzip2, zlib, xz }:
|
||||
|
||||
appleDerivation {
|
||||
nativeBuildInputs = [ xcbuildHook ];
|
||||
buildInputs = [ ncurses bzip2 zlib xz ];
|
||||
|
||||
# patches to use ncursees
|
||||
# disables md5
|
||||
patchPhase = ''
|
||||
substituteInPlace text_cmds.xcodeproj/project.pbxproj \
|
||||
--replace 'FC6C98FB149A94EB00DDCC47 /* libcurses.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcurses.dylib; path = /usr/lib/libcurses.dylib; sourceTree = "<absolute>"; };' 'FC6C98FB149A94EB00DDCC47 /* libncurses.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libncurses.dylib; path = /usr/lib/libncurses.dylib; sourceTree = "<absolute>"; };' \
|
||||
--replace 'FC7A7EB5149875E00086576A /* PBXTargetDependency */,' ""
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
for f in Products/Release/*; do
|
||||
if [ -f $f ]; then
|
||||
install -D $f $out/bin/$(basename $f)
|
||||
fi
|
||||
done
|
||||
'';
|
||||
|
||||
env.NIX_CFLAGS_COMPILE = toString [
|
||||
# hardeningDisable doesn't cut it
|
||||
"-Wno-error=format-security"
|
||||
# Required to build with clang 16
|
||||
"-Wno-error=deprecated-non-prototype"
|
||||
];
|
||||
|
||||
meta = {
|
||||
platforms = lib.platforms.darwin;
|
||||
maintainers = with lib.maintainers; [ matthewbauer ];
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,386 @@
|
||||
# Build settings based on the upstream Xcode project.
|
||||
# See: https://github.com/apple-oss-distributions/text_cmds/blob/main/text_cmds.xcodeproj/project.pbxproj
|
||||
|
||||
# Project settings
|
||||
project('text_cmds', 'c', version : '@version@')
|
||||
add_global_arguments(
|
||||
# Many programs use old prototypes
|
||||
'-Wno-deprecated-non-prototype',
|
||||
language : 'c',
|
||||
)
|
||||
|
||||
fs = import('fs')
|
||||
|
||||
# Dependencies
|
||||
cc = meson.get_compiler('c')
|
||||
|
||||
bzip2 = dependency('bzip2')
|
||||
libbsd = dependency('libbsd-overlay', required : false)
|
||||
libresolv = cc.find_library('resolv')
|
||||
libutil = cc.find_library('util')
|
||||
libxo = dependency('libxo')
|
||||
ncurses = dependency('ncurses')
|
||||
xz = dependency('liblzma')
|
||||
zlib = dependency('zlib')
|
||||
|
||||
|
||||
# Binaries
|
||||
executable(
|
||||
'banner',
|
||||
install : true,
|
||||
sources : [ 'banner/banner.c' ],
|
||||
)
|
||||
install_man('banner/banner.6')
|
||||
|
||||
executable(
|
||||
'bintrans',
|
||||
dependencies : [ libresolv ],
|
||||
install : true,
|
||||
sources : [
|
||||
'bintrans/apple_base64.c',
|
||||
'bintrans/bintrans.c',
|
||||
'bintrans/qp.c',
|
||||
'bintrans/uudecode.c',
|
||||
'bintrans/uuencode.c',
|
||||
],
|
||||
)
|
||||
install_man(
|
||||
'bintrans/base64.1',
|
||||
'bintrans/bintrans.1',
|
||||
'bintrans/uuencode.format.5',
|
||||
)
|
||||
install_symlink(
|
||||
'base64',
|
||||
install_dir : get_option('bindir'),
|
||||
pointing_to : 'bintrans',
|
||||
)
|
||||
foreach cmd : [ 'b64decode', 'b64encode', 'uudecode', 'uuencode' ]
|
||||
install_symlink(
|
||||
cmd,
|
||||
install_dir : get_option('bindir'),
|
||||
pointing_to : 'bintrans',
|
||||
)
|
||||
install_symlink(
|
||||
f'@cmd@.1',
|
||||
install_dir : get_option('mandir') + '/man1',
|
||||
pointing_to : 'bintrans.1',
|
||||
)
|
||||
endforeach
|
||||
|
||||
executable(
|
||||
'cat',
|
||||
install : true,
|
||||
sources : [ 'cat/cat.c' ],
|
||||
)
|
||||
install_man('cat/cat.1')
|
||||
|
||||
executable(
|
||||
'col',
|
||||
dependencies : [ libbsd ],
|
||||
install : true,
|
||||
sources : [ 'col/col.c' ],
|
||||
)
|
||||
install_man('col/col.1')
|
||||
|
||||
executable(
|
||||
'colrm',
|
||||
install : true,
|
||||
sources : [ 'colrm/colrm.c' ],
|
||||
)
|
||||
install_man('colrm/colrm.1')
|
||||
|
||||
executable(
|
||||
'column',
|
||||
install : true,
|
||||
sources : [ 'column/column.c' ],
|
||||
)
|
||||
install_man('column/column.1')
|
||||
|
||||
executable(
|
||||
'comm',
|
||||
install : true,
|
||||
sources : [ 'comm/comm.c' ],
|
||||
)
|
||||
install_man('comm/comm.1')
|
||||
|
||||
executable(
|
||||
'csplit',
|
||||
install : true,
|
||||
sources : [ 'csplit/csplit.c' ],
|
||||
)
|
||||
install_man('csplit/csplit.1')
|
||||
|
||||
executable(
|
||||
'cut',
|
||||
install : true,
|
||||
sources : [ 'cut/cut.c' ],
|
||||
)
|
||||
install_man('cut/cut.1')
|
||||
|
||||
executable(
|
||||
'ed',
|
||||
install : true,
|
||||
sources : [
|
||||
'ed/buf.c',
|
||||
'ed/glbl.c',
|
||||
'ed/io.c',
|
||||
'ed/main.c',
|
||||
'ed/re.c',
|
||||
'ed/sub.c',
|
||||
'ed/undo.c',
|
||||
],
|
||||
)
|
||||
install_man(
|
||||
'ed/ed.1',
|
||||
'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,
|
||||
sources : [ 'expand/expand.c' ],
|
||||
)
|
||||
install_man('expand/expand.1')
|
||||
|
||||
executable(
|
||||
'fmt',
|
||||
install : true,
|
||||
sources : [ 'fmt/fmt.c' ],
|
||||
)
|
||||
install_man('fmt/fmt.1')
|
||||
|
||||
executable(
|
||||
'fold',
|
||||
install : true,
|
||||
sources : [ 'fold/fold.c' ],
|
||||
)
|
||||
install_man('fold/fold.1')
|
||||
|
||||
executable(
|
||||
'grep',
|
||||
dependencies : [ bzip2, xz, zlib ],
|
||||
install : true,
|
||||
sources : [
|
||||
'grep/file.c',
|
||||
'grep/grep.c',
|
||||
'grep/queue.c',
|
||||
'grep/util.c',
|
||||
],
|
||||
)
|
||||
install_man('grep/grep.1')
|
||||
|
||||
install_data(
|
||||
'grep/zgrep.sh',
|
||||
install_dir : get_option('bindir'),
|
||||
install_mode : 'r-xr-xr-x',
|
||||
rename : 'zgrep',
|
||||
)
|
||||
install_man('grep/zgrep.1')
|
||||
|
||||
executable(
|
||||
'head',
|
||||
install : true,
|
||||
sources : [ 'head/head.c' ],
|
||||
)
|
||||
install_man('head/head.1')
|
||||
|
||||
executable(
|
||||
'join',
|
||||
install : true,
|
||||
sources : [ 'join/join.c' ],
|
||||
)
|
||||
install_man('join/join.1')
|
||||
|
||||
executable(
|
||||
'lam',
|
||||
install : true,
|
||||
sources : [ 'lam/lam.c' ],
|
||||
)
|
||||
install_man('lam/lam.1')
|
||||
|
||||
executable(
|
||||
'look',
|
||||
install : true,
|
||||
sources : [ 'look/look.c' ],
|
||||
)
|
||||
install_man('look/look.1')
|
||||
|
||||
executable(
|
||||
'md5',
|
||||
install : true,
|
||||
sources : [
|
||||
'md5/commoncrypto.c',
|
||||
'md5/md5.c',
|
||||
],
|
||||
)
|
||||
install_man('md5/md5.1')
|
||||
|
||||
executable(
|
||||
'nl',
|
||||
install : true,
|
||||
sources : [ 'nl/nl.c' ],
|
||||
)
|
||||
install_man('nl/nl.1')
|
||||
|
||||
executable(
|
||||
'paste',
|
||||
install : true,
|
||||
sources : [ 'paste/paste.c' ],
|
||||
)
|
||||
install_man('paste/paste.1')
|
||||
|
||||
executable(
|
||||
'pr',
|
||||
install : true,
|
||||
sources : [
|
||||
'pr/egetopt.c',
|
||||
'pr/pr.c',
|
||||
],
|
||||
)
|
||||
install_man('pr/pr.1')
|
||||
|
||||
executable(
|
||||
'rev',
|
||||
install : true,
|
||||
sources : [
|
||||
'rev/rev.c',
|
||||
],
|
||||
)
|
||||
install_man('rev/rev.1')
|
||||
|
||||
executable(
|
||||
'rs',
|
||||
install : true,
|
||||
sources : [ 'rs/rs.c' ],
|
||||
)
|
||||
install_man('rs/rs.1')
|
||||
|
||||
executable(
|
||||
'sed',
|
||||
install : true,
|
||||
sources : [
|
||||
'sed/compile.c',
|
||||
'sed/main.c',
|
||||
'sed/misc.c',
|
||||
'sed/process.c',
|
||||
],
|
||||
)
|
||||
install_man('sed/sed.1')
|
||||
|
||||
executable(
|
||||
'sort',
|
||||
c_args : [ '-DSORT_VERSION="@version@"' ],
|
||||
install : true,
|
||||
sources : [
|
||||
'sort/bwstring.c',
|
||||
'sort/coll.c',
|
||||
'sort/file.c',
|
||||
'sort/mem.c',
|
||||
'sort/radixsort.c',
|
||||
'sort/sort.c',
|
||||
'sort/vsort.c',
|
||||
],
|
||||
)
|
||||
|
||||
executable(
|
||||
'split',
|
||||
dependencies : [ libutil ],
|
||||
install : true,
|
||||
sources : [ 'split/split.c' ],
|
||||
)
|
||||
install_man('split/split.1')
|
||||
|
||||
executable(
|
||||
'tail',
|
||||
dependencies : [ libutil ],
|
||||
install : true,
|
||||
sources : [
|
||||
'tail/forward.c',
|
||||
'tail/misc.c',
|
||||
'tail/read.c',
|
||||
'tail/reverse.c',
|
||||
'tail/tail.c',
|
||||
],
|
||||
)
|
||||
install_man('tail/tail.1')
|
||||
|
||||
executable(
|
||||
'tr',
|
||||
install : true,
|
||||
link_args : [ '-Wl,-undefined,dynamic_lookup' ],
|
||||
sources : [
|
||||
'tr/cmap.c',
|
||||
'tr/cset.c',
|
||||
'tr/str.c',
|
||||
'tr/tr.c',
|
||||
fs.exists('tr/collate-libc.c') ? 'tr/collate-libc.c' : [ ]
|
||||
],
|
||||
)
|
||||
install_man('tr/tr.1')
|
||||
|
||||
executable(
|
||||
'ul',
|
||||
dependencies : [ ncurses ],
|
||||
install : true,
|
||||
sources : [ 'ul/ul.c' ],
|
||||
)
|
||||
install_man('ul/ul.1')
|
||||
|
||||
executable(
|
||||
'unexpand',
|
||||
install : true,
|
||||
sources : [ 'unexpand/unexpand.c' ],
|
||||
)
|
||||
|
||||
executable(
|
||||
'uniq',
|
||||
install : true,
|
||||
sources : [ 'uniq/uniq.c' ],
|
||||
)
|
||||
install_man('uniq/uniq.1')
|
||||
|
||||
executable(
|
||||
'unvis',
|
||||
install : true,
|
||||
sources : [ 'unvis/unvis.c' ],
|
||||
)
|
||||
install_man('unvis/unvis.1')
|
||||
|
||||
executable(
|
||||
'vis',
|
||||
install : true,
|
||||
sources : [
|
||||
'vis/foldit.c',
|
||||
'vis/vis.c',
|
||||
fs.exists('vis/vis-libc.c') ? 'vis/vis-libc.c' : [ ],
|
||||
],
|
||||
)
|
||||
install_man('vis/vis.1')
|
||||
|
||||
executable(
|
||||
'wc',
|
||||
dependencies : [ libxo ],
|
||||
install : true,
|
||||
sources : [ 'wc/wc.c' ],
|
||||
)
|
||||
install_man('wc/wc.1')
|
||||
@@ -0,0 +1,89 @@
|
||||
{
|
||||
lib,
|
||||
apple-sdk,
|
||||
apple-sdk_11,
|
||||
apple-sdk_13,
|
||||
bzip2,
|
||||
libbsd,
|
||||
libresolv,
|
||||
libutil,
|
||||
libxo,
|
||||
mkAppleDerivation,
|
||||
shell_cmds,
|
||||
ncurses,
|
||||
pkg-config,
|
||||
stdenvNoCC,
|
||||
xz,
|
||||
zlib,
|
||||
}:
|
||||
|
||||
let
|
||||
Libc = apple-sdk.sourceRelease "Libc";
|
||||
Libc_13 = apple-sdk_13.sourceRelease "Libc";
|
||||
|
||||
# The 10.12 SDK doesn’t have the files needed in the same places or possibly at all.
|
||||
# Just use the 11.0 SDK to make things easier.
|
||||
CommonCrypto = apple-sdk_11.sourceRelease "CommonCrypto";
|
||||
libplatform = apple-sdk_11.sourceRelease "libplatform";
|
||||
xnu = apple-sdk_11.sourceRelease "xnu";
|
||||
|
||||
privateHeaders = stdenvNoCC.mkDerivation {
|
||||
name = "text_cmds-deps-private-headers";
|
||||
|
||||
buildCommand = ''
|
||||
install -D -t "$out/include" \
|
||||
'${libplatform}/private/_simple.h' \
|
||||
'${Libc_13}/include/vis.h'
|
||||
install -D -t "$out/include/os" \
|
||||
'${Libc}/os/assumes.h' \
|
||||
'${xnu}/libkern/os/base_private.h'
|
||||
install -D -t "$out/include/CommonCrypto" \
|
||||
'${CommonCrypto}/include/Private/CommonDigestSPI.h'
|
||||
|
||||
# Prevent an error when using the old availability headers from the 10.12 SDK.
|
||||
substituteInPlace "$out/include/CommonCrypto/CommonDigestSPI.h" \
|
||||
--replace-fail 'API_DEPRECATED(CC_DIGEST_DEPRECATION_WARNING, macos(10.4, 10.13), ios(5.0, 11.0))' "" \
|
||||
--replace-fail 'API_DEPRECATED(CC_DIGEST_DEPRECATION_WARNING, macos(10.4, 10.15), ios(5.0, 13.0))' ""
|
||||
touch "$out/include/CrashReporterClient.h" # Needed by older SDK `os/assumes.h`
|
||||
'';
|
||||
};
|
||||
in
|
||||
mkAppleDerivation {
|
||||
releaseName = "text_cmds";
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"man"
|
||||
];
|
||||
|
||||
xcodeHash = "sha256-DzLrQ8CbInXj7PrV9jp3nHfE84A09ZwS729c9WXFV4Y=";
|
||||
|
||||
postPatch =
|
||||
''
|
||||
# Fix format security errors
|
||||
sed -e 's/wprintw(\([^,]*\), \([^)]*\))/wprintw(\1, "%s", \2)/g' -i ee/ee.c
|
||||
'';
|
||||
|
||||
env.NIX_CFLAGS_COMPILE = "-I${privateHeaders}/include";
|
||||
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
|
||||
buildInputs = [
|
||||
bzip2
|
||||
libresolv
|
||||
libutil
|
||||
libxo
|
||||
ncurses
|
||||
xz
|
||||
zlib
|
||||
] ++ lib.optionals (lib.versionOlder (lib.getVersion apple-sdk) "11.0") [ libbsd ];
|
||||
|
||||
postInstall = ''
|
||||
# Patch the shebangs to use `sh` from shell_cmds.
|
||||
HOST_PATH='${lib.getBin shell_cmds}/bin' patchShebangs --host "$out/bin"
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Text commands for Darwin";
|
||||
};
|
||||
}
|
||||
@@ -70,5 +70,9 @@
|
||||
"system_cmds": {
|
||||
"hash": "sha256-qFp9nkzsq9uQ7zoyfvO+3gvDlc7kaPvn6luvmO/Io30=",
|
||||
"version": "970.0.4"
|
||||
},
|
||||
"text_cmds": {
|
||||
"hash": "sha256-KSebU7ZyUsPeqn51nzuGNaNxs9pvmlIQQdkWXIVzDxw=",
|
||||
"version": "99"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user