darwin.copyfile: convert to Meson and use mkAppleDerivation
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
{ appleDerivation', stdenvNoCC }:
|
||||
|
||||
appleDerivation' stdenvNoCC {
|
||||
dontBuild = true;
|
||||
installPhase = ''
|
||||
mkdir -p $out/include/
|
||||
cp copyfile.h $out/include/
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
# Build settings based on the upstream Xcode project.
|
||||
# See: https://github.com/apple-oss-distributions/copyfile/blob/main/copyfile.xcodeproj/project.pbxproj
|
||||
|
||||
# Project settings
|
||||
project('copyfile', 'c', version : '@version@')
|
||||
|
||||
|
||||
# Dependencies
|
||||
cc = meson.get_compiler('c')
|
||||
|
||||
|
||||
# Libraries
|
||||
library(
|
||||
'copyfile',
|
||||
c_args : [
|
||||
'-D__DARWIN_NOW_CANCELABLE=1',
|
||||
# https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/sys/kdebug.h#L691
|
||||
'-DDBG_DECMP=0x12',
|
||||
# https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/libkern/os/base.h#L129
|
||||
'-DOS_FALLTHROUGH=__attribute__((__fallthrough__))',
|
||||
],
|
||||
install : true,
|
||||
sources : [
|
||||
'copyfile.c',
|
||||
'xattr_flags.c',
|
||||
],
|
||||
)
|
||||
install_headers(
|
||||
'copyfile.h',
|
||||
'xattr_flags.h',
|
||||
'xattr_properties.h',
|
||||
)
|
||||
install_man(
|
||||
'copyfile.3',
|
||||
'xattr_name_with_flags.3',
|
||||
)
|
||||
@@ -0,0 +1,94 @@
|
||||
{
|
||||
lib,
|
||||
apple-sdk,
|
||||
apple-sdk_10_13,
|
||||
apple-sdk_11,
|
||||
mkAppleDerivation,
|
||||
stdenvNoCC,
|
||||
}:
|
||||
|
||||
let
|
||||
# The 10.12 SDK doesn’t have the files needed in the same places or possibly at all.
|
||||
# Just use the 11.x SDK to make things easier.
|
||||
xnu = apple-sdk_11.sourceRelease "xnu";
|
||||
|
||||
privateHeaders = stdenvNoCC.mkDerivation {
|
||||
name = "copyfile-deps-private-headers";
|
||||
|
||||
buildCommand = ''
|
||||
install -D -t "$out/include/Kernel/sys" \
|
||||
'${xnu}/bsd/sys/decmpfs.h'
|
||||
|
||||
install -D -t "$out/include/System/sys" \
|
||||
'${xnu}/bsd/sys/content_protection.h' \
|
||||
'${xnu}/bsd/sys/fsctl.h'
|
||||
substituteInPlace "$out/include/System/sys/content_protection.h" \
|
||||
--replace-fail '#ifdef PRIVATE' '#if 1'
|
||||
|
||||
mkdir -p "$out/include/xpc"
|
||||
cat <<EOF > "$out/include/xpc/private.h"
|
||||
#pragma once
|
||||
extern int _xpc_runtime_is_app_sandboxed();
|
||||
EOF
|
||||
|
||||
# https://github.com/apple-oss-distributions/copyfile/blob/ed3f0a8bf8b6bac6838c92c297afcc826fec75f4/copyfile.c#L64-L74
|
||||
cat <<EOF > "$out/include/quarantine.h"
|
||||
#pragma once
|
||||
typedef void* qtn_file_t;
|
||||
#define QTN_SERIALIZED_DATA_MAX 4096
|
||||
#define qtn_file_alloc _qtn_file_alloc
|
||||
#define qtn_file_init_with_fd _qtn_file_init_with_fd
|
||||
#define qtn_file_init_with_path _qtn_file_init_with_path
|
||||
#define qtn_file_init_with_data _qtn_file_init_with_data
|
||||
#define qtn_file_free _qtn_file_free
|
||||
#define qtn_file_apply_to_fd _qtn_file_apply_to_fd
|
||||
#define qtn_error _qtn_error
|
||||
#define qtn_file_to_data _qtn_file_to_data
|
||||
#define qtn_file_clone _qtn_file_clone
|
||||
#define qtn_file_get_flags _qtn_file_get_flags
|
||||
#define qtn_file_set_flags _qtn_file_set_flags
|
||||
extern void * qtn_file_alloc(void);
|
||||
extern int qtn_file_init_with_fd(void *x, int y);
|
||||
extern int qtn_file_init_with_path(void *x, const char *path);
|
||||
extern int qtn_file_init_with_data(void *x, const void *data, size_t len);
|
||||
extern void qtn_file_free(void *);
|
||||
extern int qtn_file_apply_to_fd(void *x, int y);
|
||||
extern char *qtn_error(int x);
|
||||
extern int qtn_file_to_data(void *x, char *y, size_t *z);
|
||||
extern void *qtn_file_clone(void *x);
|
||||
extern uint32_t qtn_file_get_flags(void *x);
|
||||
extern int qtn_file_set_flags(void *x, uint32_t flags);
|
||||
#define qtn_xattr_name "com.apple.quarantine"
|
||||
#define QTN_FLAG_DO_NOT_TRANSLOCATE 0x100
|
||||
EOF
|
||||
'';
|
||||
};
|
||||
in
|
||||
mkAppleDerivation {
|
||||
releaseName = "copyfile";
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"dev"
|
||||
"man"
|
||||
];
|
||||
|
||||
xcodeHash = "sha256-RClwLwWuieJzKJl1YRCrGBxPgWy0MDwFwN1VZ4GBxGY=";
|
||||
|
||||
postPatch = ''
|
||||
# Disable experimental bounds safety stuff that’s not available in LLVM 16.
|
||||
for header in copyfile.h xattr_flags.h; do
|
||||
substituteInPlace "$header" \
|
||||
--replace-fail '__ptrcheck_abi_assume_single()' "" \
|
||||
--replace-fail '__unsafe_indexable' ""
|
||||
done
|
||||
'';
|
||||
|
||||
env.NIX_CFLAGS_COMPILE = "-I${privateHeaders}/include";
|
||||
|
||||
buildInputs = lib.optionals (lib.versionOlder (lib.getVersion apple-sdk) "10.13") [
|
||||
apple-sdk_10_13
|
||||
];
|
||||
|
||||
meta.description = "Darwin file copying library";
|
||||
}
|
||||
@@ -267,7 +267,7 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
|
||||
Security = applePackage "Security/boot.nix" "osx-10.9.5" "sha256-7qr0IamjCXCobIJ6V9KtvbMBkJDfRCy4C5eqpHJlQLI=" {};
|
||||
inherit (pkgs.darwin.apple_sdk.libs) xpc;
|
||||
};
|
||||
copyfile = applePackage "copyfile" "osx-10.12.6" "sha256-uHqLFOIpXK+n0RHyOZzVsP2DDZcFDivKCnqHBaXvHns=" {};
|
||||
copyfile = callPackage ./copyfile/package.nix { };
|
||||
Csu = applePackage "Csu" "osx-10.11.6" "sha256-h6a/sQMEVeFxKNWAPgKBXjWhyL2L2nvX9BQUMaTQ6sY=" {};
|
||||
dtrace = applePackage "dtrace" "osx-10.12.6" "sha256-Icr22ozixHquI0kRB2XZ+LlxD6V46sJHsHy4L/tDXZg=" {};
|
||||
dyld = applePackage "dyld" "osx-10.12.6" "sha256-JmKnOZtBPf96zEx7vhYHLBSTOPyKN71IdYE3R0IeJww=" {};
|
||||
|
||||
@@ -14,5 +14,9 @@
|
||||
"bootstrap_cmds": {
|
||||
"hash": "sha256-dJmwRgUoBilkfgEeebsJBTbB/YqSHPtSrbifLSN/62E=",
|
||||
"version": "121"
|
||||
},
|
||||
"copyfile": {
|
||||
"hash": "sha256-uHqLFOIpXK+n0RHyOZzVsP2DDZcFDivKCnqHBaXvHns=",
|
||||
"version": "138"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user