darwin.adv_cmds: convert to Meson and use mkAppleDerivation
This commit is contained in:
parent
b7442b9066
commit
4624bd7959
@ -1,101 +0,0 @@
|
||||
{ lib, stdenv, buildPackages, appleDerivation, fetchFromGitHub, bsdmake, perl, flex, bison
|
||||
}:
|
||||
|
||||
# this derivation sucks
|
||||
# locale data was removed after adv_cmds-118, so our base is that because it's easier than
|
||||
# replicating the bizarre bsdmake file structure
|
||||
#
|
||||
# sadly adv_cmds-118 builds a mklocale and colldef that generate files that our libc can no
|
||||
# longer understand
|
||||
#
|
||||
# the more recent adv_cmds release is used for everything else in this package
|
||||
|
||||
let recentAdvCmds = fetchFromGitHub {
|
||||
owner = "apple-oss-distributions";
|
||||
repo = "adv_cmds";
|
||||
rev = "adv_cmds-158";
|
||||
hash = "sha256-1qL69pGHIaefooJJ8eT83XGz9+bW7Yg3k+X9fNkMCHw=";
|
||||
};
|
||||
|
||||
in appleDerivation {
|
||||
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
||||
nativeBuildInputs = [ bsdmake perl bison flex ];
|
||||
buildInputs = [ flex ];
|
||||
|
||||
patchPhase = ''
|
||||
substituteInPlace BSDmakefile \
|
||||
--replace chgrp true \
|
||||
--replace /Developer/Makefiles/bin/compress-man-pages.pl true \
|
||||
--replace "ps.tproj" "" --replace "gencat.tproj" "" --replace "md.tproj" "" \
|
||||
--replace "tabs.tproj" "" --replace "cap_mkdb.tproj" "" \
|
||||
--replace "!= tconf --test TARGET_OS_EMBEDDED" "= NO"
|
||||
|
||||
substituteInPlace Makefile --replace perl true
|
||||
|
||||
substituteInPlace colldef.tproj/scan.l \
|
||||
--replace 'static orderpass = 0;' 'static int orderpass = 0;'
|
||||
|
||||
for subproject in colldef mklocale monetdef msgdef numericdef timedef; do
|
||||
substituteInPlace usr-share-locale.tproj/$subproject/BSDmakefile \
|
||||
--replace /usr/share/locale "" \
|
||||
--replace '-o ''${BINOWN} -g ''${BINGRP}' "" \
|
||||
--replace "rsync -a" "cp -r"
|
||||
done
|
||||
'';
|
||||
|
||||
preBuild = ''
|
||||
cp -r --no-preserve=all ${recentAdvCmds}/colldef .
|
||||
|
||||
substituteInPlace colldef/scan.l \
|
||||
--replace 'static orderpass = 0;' 'static int orderpass = 0;'
|
||||
|
||||
pushd colldef
|
||||
mv locale/collate.h .
|
||||
flex -t -8 -i scan.l > scan.c
|
||||
yacc -d parse.y
|
||||
clang *.c -o colldef -lfl
|
||||
popd
|
||||
mv colldef/colldef colldef.tproj/colldef
|
||||
|
||||
cp -r --no-preserve=all ${recentAdvCmds}/mklocale .
|
||||
pushd mklocale
|
||||
flex -t -8 -i lex.l > lex.c
|
||||
yacc -d yacc.y
|
||||
clang *.c -o mklocale -lfl
|
||||
popd
|
||||
mv mklocale/mklocale mklocale.tproj/mklocale
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
bsdmake -C usr-share-locale.tproj
|
||||
|
||||
${stdenv.cc.targetPrefix}clang ${recentAdvCmds}/ps/*.c -o ps
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
bsdmake -C usr-share-locale.tproj install DESTDIR="$locale/share/locale"
|
||||
|
||||
# need to get rid of runtime dependency on flex
|
||||
# install -d 0755 $locale/bin
|
||||
# install -m 0755 colldef.tproj/colldef $locale/bin
|
||||
# install -m 0755 mklocale.tproj/mklocale $locale/bin
|
||||
|
||||
install -d 0755 $ps/bin
|
||||
install ps $ps/bin/ps
|
||||
touch "$out"
|
||||
'';
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"ps"
|
||||
"locale"
|
||||
];
|
||||
setOutputFlags = false;
|
||||
|
||||
meta = {
|
||||
platforms = lib.platforms.darwin;
|
||||
maintainers = with lib.maintainers; [ gridaphobe ];
|
||||
};
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
{ stdenv, lib, appleDerivation, xcbuild, ncurses, libutil, Libc }:
|
||||
|
||||
let
|
||||
# Libc conflicts with libc++ 16, so provide only the header from it that’s needed to build.
|
||||
msgcat = stdenv.mkDerivation {
|
||||
pname = "Libc-msgcat";
|
||||
version = lib.getVersion Libc;
|
||||
|
||||
buildCommand = ''
|
||||
mkdir -p "$out/include"
|
||||
ln -s ${lib.getDev Libc}/include/msgcat.h "$out/include/"
|
||||
'';
|
||||
};
|
||||
in
|
||||
appleDerivation {
|
||||
# We can't just run the root build, because https://github.com/facebook/xcbuild/issues/264
|
||||
|
||||
patchPhase = ''
|
||||
substituteInPlace adv_cmds.xcodeproj/project.pbxproj \
|
||||
--replace '/usr/lib/libtermcap.dylib' 'libncurses.dylib'
|
||||
substituteInPlace colldef/scan.l \
|
||||
--replace 'static orderpass = 0;' 'static int orderpass = 0;'
|
||||
'';
|
||||
|
||||
# pkill requires special private headers that are unavailable in
|
||||
# NixPkgs. These ones are needed:
|
||||
# - xpc/xpxc.h
|
||||
# - os/base_private.h
|
||||
# - _simple.h
|
||||
# We disable it here for now. TODO: build pkill inside adv_cmds
|
||||
buildPhase = ''
|
||||
targets=$(xcodebuild -list \
|
||||
| awk '/Targets:/{p=1;print;next} p&&/^\s*$/{p=0};p' \
|
||||
| tail -n +2 | sed 's/^[ \t]*//' \
|
||||
| grep -v -e Desktop -e Embedded -e mklocale -e pkill -e pgrep -e colldef)
|
||||
|
||||
for i in $targets; do
|
||||
xcodebuild SYMROOT=$PWD/Products OBJROOT=$PWD/Intermediates -target $i
|
||||
done
|
||||
'';
|
||||
|
||||
# temporary install phase until xcodebuild has "install" support
|
||||
installPhase = ''
|
||||
for f in Products/Release/*; do
|
||||
if [ -f $f ]; then
|
||||
install -D $f $out/bin/$(basename $f)
|
||||
fi
|
||||
done
|
||||
|
||||
mkdir -p $out/System/Library/LaunchDaemons
|
||||
install fingerd/finger.plist $out/System/Library/LaunchDaemons
|
||||
|
||||
# from variant_links.sh
|
||||
# ln -s $out/bin/pkill $out/bin/pgrep
|
||||
# ln -s $out/share/man/man1/pkill.1 $out/share/man/man1/pgrep.1
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [ xcbuild ];
|
||||
buildInputs = [ ncurses libutil msgcat ];
|
||||
|
||||
meta = {
|
||||
platforms = lib.platforms.darwin;
|
||||
maintainers = with lib.maintainers; [ matthewbauer ];
|
||||
};
|
||||
}
|
@ -0,0 +1,220 @@
|
||||
# Build settings based on the upstream Xcode project.
|
||||
# See: https://github.com/apple-oss-distributions/adv_cmds/blob/main/adv_cmds.xcodeproj/project.pbxproj
|
||||
|
||||
# Project settings
|
||||
project('adv_cmds', 'c', 'cpp', version : '@version@')
|
||||
|
||||
sdk_version = get_option('sdk_version')
|
||||
|
||||
|
||||
# Dependencies
|
||||
cc = meson.get_compiler('c')
|
||||
cxx = meson.get_compiler('cpp')
|
||||
|
||||
dbm = cc.find_library('dbm')
|
||||
ncurses = dependency('ncurses')
|
||||
|
||||
|
||||
# Generators
|
||||
bison_bin = find_program('bison', required : true)
|
||||
flex_bin = find_program('flex', required : true)
|
||||
|
||||
bison = generator(
|
||||
bison_bin,
|
||||
arguments : ['@INPUT@', '--header=@OUTPUT0@', '--output=@OUTPUT1@'],
|
||||
output : [ '@BASENAME@.tab.h', '@BASENAME@.tab.c'],
|
||||
)
|
||||
|
||||
flex = generator(
|
||||
flex_bin,
|
||||
arguments : ['--header-file=@OUTPUT0@', '--outfile=@OUTPUT1@', '@INPUT@'],
|
||||
output : ['@BASENAME@.yy.h', '@BASENAME@.yy.c'],
|
||||
)
|
||||
|
||||
|
||||
# Binaries
|
||||
executable(
|
||||
'cap_mkdb',
|
||||
dependencies : dbm,
|
||||
install : true,
|
||||
sources : ['cap_mkdb/cap_mkdb.c'],
|
||||
)
|
||||
install_man('cap_mkdb/cap_mkdb.1')
|
||||
|
||||
executable(
|
||||
'colldef',
|
||||
dependencies : dbm,
|
||||
include_directories : [
|
||||
'colldef',
|
||||
'colldef/locale',
|
||||
],
|
||||
install : true,
|
||||
sources : [
|
||||
bison.process('colldef/parse.y'),
|
||||
flex.process('colldef/scan.l'),
|
||||
],
|
||||
)
|
||||
install_man('colldef/colldef.1')
|
||||
|
||||
executable(
|
||||
'finger',
|
||||
dependencies : dbm,
|
||||
install : true,
|
||||
sources : [
|
||||
'finger/finger.c',
|
||||
'finger/lprint.c',
|
||||
'finger/net.c',
|
||||
'finger/sprint.c',
|
||||
'finger/util.c',
|
||||
],
|
||||
)
|
||||
install_man(
|
||||
'finger/finger.1',
|
||||
'finger/finger.conf.5'
|
||||
)
|
||||
|
||||
executable(
|
||||
'gencat',
|
||||
install : true,
|
||||
sources : [
|
||||
'gencat/gencat.c',
|
||||
'gencat/genlib.c',
|
||||
],
|
||||
)
|
||||
install_man('gencat/gencat.1')
|
||||
|
||||
executable(
|
||||
'genwrap',
|
||||
include_directories : 'genwrap',
|
||||
install : true,
|
||||
sources : [
|
||||
'genwrap/genwrap.c',
|
||||
bison.process('genwrap/genwrap.y'),
|
||||
flex.process('genwrap/lex.l'),
|
||||
],
|
||||
)
|
||||
install_data(
|
||||
'genwrap/wrapper-head.c',
|
||||
'genwrap/wrapper-tail.c',
|
||||
install_dir : get_option('datadir') + '/genwrap'
|
||||
)
|
||||
install_data(
|
||||
'genwrap/sample.make',
|
||||
'genwrap/sample.rsync',
|
||||
install_dir : get_option('datadir') + '/genwrap/examples'
|
||||
)
|
||||
install_man('genwrap/genwrap.8')
|
||||
|
||||
executable(
|
||||
'last',
|
||||
install : true,
|
||||
sources : ['last/last.c'],
|
||||
)
|
||||
install_man('last/last.1')
|
||||
|
||||
executable(
|
||||
'locale',
|
||||
install : true,
|
||||
sources : ['locale/locale.cc'],
|
||||
)
|
||||
install_man('locale/locale.1')
|
||||
|
||||
# TODO(@reckenrode) Requires Perl. Needs separate packaging.
|
||||
custom_target(
|
||||
'localedef',
|
||||
command : [ 'cp', '@INPUT@', '@OUTPUT@' ],
|
||||
install : true,
|
||||
install_dir : get_option('bindir'),
|
||||
install_mode : 'r-xr-xr-x',
|
||||
input : 'localedef/localedef.pl',
|
||||
output : 'localedef',
|
||||
)
|
||||
install_man('localedef/localedef.1')
|
||||
|
||||
executable(
|
||||
'lsvfs',
|
||||
install : true,
|
||||
sources : ['lsvfs/lsvfs.c'],
|
||||
)
|
||||
install_man('lsvfs/lsvfs.1')
|
||||
|
||||
executable(
|
||||
'mklocale',
|
||||
include_directories : 'mklocale',
|
||||
install : true,
|
||||
sources : [
|
||||
bison.process('mklocale/yacc.y'),
|
||||
flex.process('mklocale/lex.l'),
|
||||
],
|
||||
)
|
||||
install_man('mklocale/mklocale.1')
|
||||
|
||||
executable(
|
||||
'pkill',
|
||||
# Requires undocumented, private sysmon.h.
|
||||
build_by_default : false,
|
||||
install : false,
|
||||
sources : ['pkill/pkill.c'],
|
||||
)
|
||||
# install_man('pkill/pkill.1')
|
||||
|
||||
executable(
|
||||
'ps',
|
||||
c_args : [
|
||||
# Needed for `persona.h`
|
||||
'-DPRIVATE',
|
||||
# From bsd/sys/event_private.h
|
||||
'-Dkqueue_id_t=uint64_t'
|
||||
],
|
||||
install : true,
|
||||
sources : [
|
||||
'ps/fmt.c',
|
||||
'ps/keyword.c',
|
||||
'ps/nlist.c',
|
||||
'ps/print.c',
|
||||
'ps/ps.c',
|
||||
'ps/tasks.c',
|
||||
],
|
||||
)
|
||||
install_man('ps/ps.1')
|
||||
|
||||
executable(
|
||||
'stty',
|
||||
build_by_default : sdk_version.version_compare('>=11.3'),
|
||||
install : sdk_version.version_compare('>=11.3'),
|
||||
sources : [
|
||||
'stty/cchar.c',
|
||||
'stty/gfmt.c',
|
||||
'stty/key.c',
|
||||
'stty/modes.c',
|
||||
'stty/print.c',
|
||||
'stty/stty.c',
|
||||
'stty/util.c',
|
||||
],
|
||||
)
|
||||
if sdk_version.version_compare('>=11.3')
|
||||
install_man('stty/stty.1')
|
||||
endif
|
||||
|
||||
executable(
|
||||
'tabs',
|
||||
dependencies : ncurses,
|
||||
install : true,
|
||||
sources : ['tabs/tabs.c'],
|
||||
)
|
||||
install_man('tabs/tabs.1')
|
||||
|
||||
executable(
|
||||
'tty',
|
||||
install : true,
|
||||
sources : ['tty/tty.c'],
|
||||
)
|
||||
install_man('tty/tty.1')
|
||||
|
||||
executable(
|
||||
'whois',
|
||||
install : true,
|
||||
sources : ['whois/whois.c'],
|
||||
)
|
||||
install_man('whois/whois.1')
|
||||
|
@ -0,0 +1 @@
|
||||
option('sdk_version', type : 'string')
|
@ -0,0 +1,105 @@
|
||||
{
|
||||
lib,
|
||||
apple-sdk,
|
||||
apple-sdk_11,
|
||||
bison,
|
||||
flex,
|
||||
mkAppleDerivation,
|
||||
ncurses,
|
||||
perl,
|
||||
pkg-config,
|
||||
stdenvNoCC,
|
||||
}:
|
||||
|
||||
let
|
||||
Libc = apple-sdk_11.sourceRelease "Libc";
|
||||
libplatform = apple-sdk_11.sourceRelease "libplatform";
|
||||
xnu = apple-sdk_11.sourceRelease "xnu";
|
||||
|
||||
privateHeaders = stdenvNoCC.mkDerivation {
|
||||
name = "adv_cmds-deps-private-headers";
|
||||
|
||||
buildCommand = ''
|
||||
install -D -m644 -t "$out/include" \
|
||||
'${libplatform}/private/_simple.h' \
|
||||
'${Libc}/nls/FreeBSD/msgcat.h'
|
||||
|
||||
install -D -m644 -t "$out/include/System/sys" \
|
||||
'${xnu}/bsd/sys/persona.h' \
|
||||
'${xnu}/bsd/sys/proc.h'
|
||||
'';
|
||||
};
|
||||
in
|
||||
mkAppleDerivation {
|
||||
releaseName = "adv_cmds";
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"locale"
|
||||
"ps"
|
||||
"man"
|
||||
];
|
||||
|
||||
xcodeHash = "sha256-cpoHF++eko3NHGJlKnFONKnGkVRD0zI+bg/XLzWtpN8=";
|
||||
|
||||
postPatch = ''
|
||||
# Meson generators require using @BASENAME@ in the output.
|
||||
substituteInPlace mklocale/lex.l \
|
||||
--replace-fail y.tab.h yacc.tab.h
|
||||
substituteInPlace genwrap/lex.l \
|
||||
--replace-fail y.tab.h genwrap.tab.h
|
||||
substituteInPlace colldef/scan.l \
|
||||
--replace-fail y.tab.h parse.tab.h
|
||||
|
||||
# Fix paths to point to the store
|
||||
for file in genwrap.c genwrap.8; do
|
||||
substituteInPlace genwrap/$file \
|
||||
--replace-fail '/usr/local' "$out"
|
||||
done
|
||||
|
||||
substituteInPlace localedef/localedef.pl \
|
||||
--replace-fail '/usr/bin/perl' '${lib.getExe perl}' \
|
||||
--replace-fail '/usr/bin' "$out/bin" \
|
||||
--replace-fail '/usr/share/locale' "$locale/share/locale"
|
||||
'';
|
||||
|
||||
env.NIX_CFLAGS_COMPILE = "-I${privateHeaders}/include";
|
||||
|
||||
buildInputs = [
|
||||
# Use the 11.3 SDK because CMake depends on adv_cmds.ps, so it can’t simply be omitted when using an older SDK.
|
||||
apple-sdk_11
|
||||
ncurses
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
bison
|
||||
flex
|
||||
perl
|
||||
pkg-config
|
||||
];
|
||||
|
||||
mesonFlags = [
|
||||
# Even though adv_cmds is built with a newer SDK, the default SDK is still the deployment target.
|
||||
# Don’t build packages that use newer APIs unnecessarily.
|
||||
(lib.mesonOption "sdk_version" (lib.getVersion apple-sdk))
|
||||
];
|
||||
|
||||
postBuild = ''
|
||||
# Build the locales TODO
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
moveToOutput share/locale "$locale"
|
||||
moveToOutput bin/ps "$ps"
|
||||
ln -s "$ps/bin/ps" "$out/bin/ps"
|
||||
mkdir -p "$locale/share/locale"
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Advanced commands package for Darwin";
|
||||
license = [
|
||||
lib.licenses.apsl10
|
||||
lib.licenses.apsl20
|
||||
];
|
||||
};
|
||||
}
|
@ -253,15 +253,12 @@ let
|
||||
inherit (pkgs.darwin) bootstrapStdenv xcodeProjectCheckHook;
|
||||
};
|
||||
|
||||
# Only used for bootstrapping. It’s convenient because it was the last version to come with a real makefile.
|
||||
adv_cmds-boot = applePackage "adv_cmds/boot.nix" "osx-10.5.8" "sha256-/OJLNpATyS31W5nWfJgSVO5itp8j55TRwG57/QLT5Fg=" {};
|
||||
|
||||
in
|
||||
|
||||
developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
|
||||
# TODO: shorten this list, we should cut down to a minimum set of bootstrap or necessary packages here.
|
||||
|
||||
inherit (adv_cmds-boot) ps locale;
|
||||
inherit (self.adv_cmds) ps locale;
|
||||
architecture = applePackage "architecture" "osx-10.11.6" "sha256-cUKeMx6mOAxBSRHIdfzsrR65Qv86m7+20XvpKqVfwVI=" {};
|
||||
AvailabilityVersions = applePackage "AvailabilityVersions" "macos-14.4" "sha256-O9/EOsbK5ZXxh6iDSTwGWWrY5GX/viUwdfG3tdvZwcQ=" {};
|
||||
bsdmake = applePackage "bsdmake" "dev-tools-3.2.6" "sha256-CW8zP5QZMhWTGp+rhrm8oHE/vSLsRlv1VRAGe1OUDmI=" {};
|
||||
@ -311,7 +308,7 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
|
||||
else macosPackages_11_0_1.xnu;
|
||||
hfs = applePackage "hfs" "osx-10.12.6" "sha256-eGi18HQFJrU5UHoBOE0LqO5gQ0xOf8+OJuAWQljfKE4=" {};
|
||||
Librpcsvc = applePackage "Librpcsvc" "osx-10.11.6" "sha256-YHbGws901xONzAbo6sB5zSea4Wp0sgYUJ8YgwVfWxnE=" {};
|
||||
adv_cmds = applePackage "adv_cmds" "osx-10.11.6" "sha256-Ztp8ALWcviEpthoiY8ttWzGI8OcsLzsULjlqe8GIzw8=" {};
|
||||
adv_cmds = callPackage ./adv_cmds/package.nix { };
|
||||
basic_cmds = applePackage "basic_cmds" "osx-10.11.6" "sha256-BYPPTg4/7x6RPs0WwwQlkNiZxxArV+7EVe6bM+a/I6Q=" {};
|
||||
developer_cmds = applePackage "developer_cmds" "osx-10.11.6" "sha256-h0wMVlS6QdRvKOVJ74W9ziHYGApjvnk77AIR6ukYBRo=" {};
|
||||
diskdev_cmds = applePackage "diskdev_cmds" "osx-10.11.6" "sha256-VX+hcZ7JhOA8EhwLloPlM3Yx79RXp9OYHV9Mi10uw3Q=" {
|
||||
|
@ -1,2 +1,6 @@
|
||||
{
|
||||
"adv_cmds": {
|
||||
"hash": "sha256-Ztp8ALWcviEpthoiY8ttWzGI8OcsLzsULjlqe8GIzw8=",
|
||||
"version": "163"
|
||||
}
|
||||
}
|
||||
|
@ -77,6 +77,8 @@ impure-cmds // appleSourcePackages // stubs // {
|
||||
extraBuildInputs = [];
|
||||
};
|
||||
|
||||
inherit (self.adv_cmds) locale ps;
|
||||
|
||||
binutils-unwrapped = callPackage ../os-specific/darwin/binutils {
|
||||
inherit (pkgs) cctools;
|
||||
inherit (pkgs.llvmPackages) clang-unwrapped llvm llvm-manpages;
|
||||
|
Loading…
Reference in New Issue
Block a user