summary refs log tree commit diff
path: root/pkgs/os-specific/darwin/apple-source-releases/adv_cmds
diff options
context:
space:
mode:
authorJude Taylor <me@jude.bio>2015-11-06 17:44:02 -0800
committerJude Taylor <me@jude.bio>2015-11-19 11:31:06 -0800
commit914e9baefe9b606ed331ba427af50c41715f973d (patch)
treeaaf1afe2ffc94e9235330b0af168d0cd7778a351 /pkgs/os-specific/darwin/apple-source-releases/adv_cmds
parentc296f64f196bbd69c4fdc336d17b553f3845cb1c (diff)
downloadnixlib-914e9baefe9b606ed331ba427af50c41715f973d.tar
nixlib-914e9baefe9b606ed331ba427af50c41715f973d.tar.gz
nixlib-914e9baefe9b606ed331ba427af50c41715f973d.tar.bz2
nixlib-914e9baefe9b606ed331ba427af50c41715f973d.tar.lz
nixlib-914e9baefe9b606ed331ba427af50c41715f973d.tar.xz
nixlib-914e9baefe9b606ed331ba427af50c41715f973d.tar.zst
nixlib-914e9baefe9b606ed331ba427af50c41715f973d.zip
start on sandbox stuff
Diffstat (limited to 'pkgs/os-specific/darwin/apple-source-releases/adv_cmds')
-rw-r--r--pkgs/os-specific/darwin/apple-source-releases/adv_cmds/default.nix67
1 files changed, 45 insertions, 22 deletions
diff --git a/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/default.nix b/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/default.nix
index 4bc3a7a7fa42..baeca0f6fe3b 100644
--- a/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/default.nix
+++ b/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/default.nix
@@ -1,32 +1,55 @@
-{ stdenv, appleDerivation, version }:
+{ stdenv, appleDerivation, fetchzip, version, bsdmake, perl, flex, yacc, writeScriptBin
+}:
+
+let recentAdvCmds = fetchzip {
+  url = "http://opensource.apple.com/tarballs/adv_cmds/adv_cmds-158.tar.gz";
+  sha256 = "0z081kcprzg5jcvqivfnwvvv6wfxzkjg2jc2lagsf8c7j7vgm8nn";
+};
+
+in appleDerivation {
+  buildInputs = [ bsdmake perl yacc flex (writeScriptBin "lex" "exec ${flex}/bin/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/BSDmakefile --replace "-ll" "-lfl"
+
+    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
+  '';
 
-appleDerivation {
-  # Will override the name until we provide all of adv_cmds
   buildPhase = ''
-    pushd ps
-    cc -Os -Wall -I. -c -o fmt.o fmt.c
-    cc -Os -Wall -I. -c -o keyword.o keyword.c
-    cc -Os -Wall -I. -c -o nlist.o nlist.c
-    cc -Os -Wall -I. -c -o print.o print.c
-    cc -Os -Wall -I. -c -o ps.o ps.c
-    cc -Os -Wall -I. -c -o tasks.o tasks.c
-    cc -o ps fmt.o keyword.o nlist.o print.o ps.o tasks.o
-    popd
-
-    pushd locale
-    c++ -o locale locale.cc
-    popd
+    bsdmake -C colldef.tproj
+    bsdmake -C mklocale.tproj
+    bsdmake -C usr-share-locale.tproj
+
+    clang ${recentAdvCmds}/ps/*.c -o ps
   '';
 
   installPhase = ''
-    mkdir -p $out/bin $out/share/man/man1
-
-    cp ps/ps   $out/bin/ps
-    cp ps/ps.1 $out/share/man/man1
-    cp locale/locale   $out/bin/locale
-    cp locale/locale.1 $out/share/man/man1
+    bsdmake -C usr-share-locale.tproj install DESTDIR="$locale/share/locale"
+    install -d 0755 $ps/bin
+    install ps $ps/bin/ps
   '';
 
+  outputs = [
+    "ps"
+    "locale"
+  ];
+
+  # ps uses this syscall to get process info
+  __propagatedSandboxProfile = stdenv.lib.sandbox.allow "mach-priv-task-port";
 
   meta = {
     platforms = stdenv.lib.platforms.darwin;