mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 08:53:21 +00:00
darwin.diskdev_cmds: convert to Meson and use mkAppleDerivation
This commit is contained in:
parent
83807dc4e9
commit
97454b46d5
@ -310,9 +310,7 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
|
||||
adv_cmds = callPackage ./adv_cmds/package.nix { };
|
||||
basic_cmds = callPackage ./basic_cmds/package.nix { };
|
||||
developer_cmds = callPackage ./developer_cmds/package.nix { };
|
||||
diskdev_cmds = applePackage "diskdev_cmds" "osx-10.11.6" "sha256-VX+hcZ7JhOA8EhwLloPlM3Yx79RXp9OYHV9Mi10uw3Q=" {
|
||||
macosPackages_11_0_1 = macosPackages_11_0_1;
|
||||
};
|
||||
diskdev_cmds = callPackage ./diskdev_cmds/package.nix { };
|
||||
network_cmds = if isSdk10_12 then
|
||||
applePackage "network_cmds" "osx-10.11.6" "sha256-I89CLIswGheewOjiNZwQTgWvWbhm0qtB5+KUqzxnQ5M=" {}
|
||||
else macosPackages_11_0_1.network_cmds;
|
||||
|
@ -1,46 +0,0 @@
|
||||
{ lib, appleDerivation, xcbuildHook, Libc, stdenv, macosPackages_11_0_1, xnu
|
||||
, libutil }:
|
||||
|
||||
let
|
||||
xnu-src = if stdenv.hostPlatform.isAarch64 then macosPackages_11_0_1.xnu.src else xnu.src;
|
||||
arch = if stdenv.hostPlatform.isAarch64 then "arm" else "i386";
|
||||
in appleDerivation {
|
||||
patches = [
|
||||
# Fixes a build failure with newer versions of clang that make implicit int an error.
|
||||
./fix-implicit-int.patch
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ xcbuildHook ];
|
||||
buildInputs = [ libutil ];
|
||||
|
||||
env.NIX_CFLAGS_COMPILE = "-I.";
|
||||
NIX_LDFLAGS = "-lutil";
|
||||
prePatch = ''
|
||||
# ugly hacks for missing headers
|
||||
# most are bsd related - probably should make this a drv
|
||||
unpackFile ${Libc.src}
|
||||
unpackFile ${xnu-src}
|
||||
mkdir System sys machine ${arch}
|
||||
cp xnu-*/bsd/sys/disklabel.h sys
|
||||
cp xnu-*/bsd/machine/disklabel.h machine
|
||||
cp xnu-*/bsd/${arch}/disklabel.h ${arch}
|
||||
cp -r xnu-*/bsd/sys System
|
||||
cp -r Libc-*/uuid System
|
||||
substituteInPlace diskdev_cmds.xcodeproj/project.pbxproj \
|
||||
--replace 'DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";' ""
|
||||
'';
|
||||
installPhase = ''
|
||||
install -D Products/Release/libdisk.a $out/lib/libdisk.a
|
||||
rm Products/Release/libdisk.a
|
||||
for f in Products/Release/*; do
|
||||
if [ -f $f ]; then
|
||||
install -D $f $out/bin/$(basename $f)
|
||||
fi
|
||||
done
|
||||
'';
|
||||
|
||||
meta = {
|
||||
platforms = lib.platforms.darwin;
|
||||
maintainers = with lib.maintainers; [ matthewbauer ];
|
||||
};
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
diff -ur a/diskdev_cmds.xcodeproj/project.pbxproj b/diskdev_cmds.xcodeproj/project.pbxproj
|
||||
--- a/quota.tproj/quota.c 2021-10-06 01:13:40.000000000 -0400
|
||||
+++ b/quota.tproj/quota.c 2023-10-27 08:24:05.960965958 -0400
|
||||
@@ -115,6 +115,7 @@
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
+ int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int ngroups;
|
@ -0,0 +1,221 @@
|
||||
# Build settings based on the upstream Xcode project.
|
||||
# See: https://github.com/apple-oss-distributions/diskdev_cmds/blob/main/diskdev_cmds.xcodeproj/project.pbxproj
|
||||
|
||||
# Project settings
|
||||
project('diskdev_cmds', 'c', version : '@version@')
|
||||
|
||||
|
||||
# Dependencies
|
||||
cc = meson.get_compiler('c')
|
||||
|
||||
apfs = dependency('appleframeworks', modules : 'APFS')
|
||||
removefile = cc.find_library('removefile')
|
||||
|
||||
|
||||
# Static Libraries
|
||||
libdisk = declare_dependency(
|
||||
include_directories : 'disklib',
|
||||
link_with : static_library(
|
||||
'disk',
|
||||
include_directories : 'disklib',
|
||||
sources : [
|
||||
'disklib/dkcksum.c',
|
||||
'disklib/dkdisklabel.c',
|
||||
'disklib/dkopen.c',
|
||||
'disklib/dksecsize.c',
|
||||
'disklib/preen.c',
|
||||
'disklib/vfslist.c',
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
# Binaries
|
||||
executable(
|
||||
'dev_mkdb',
|
||||
install : true,
|
||||
sources : [ 'dev_mkdb.tproj/dev_mkdb.c' ],
|
||||
)
|
||||
install_man('dev_mkdb.tproj/dev_mkdb.8')
|
||||
|
||||
executable(
|
||||
'dirs_cleaner',
|
||||
dependencies : [ removefile ],
|
||||
install : true,
|
||||
install_dir : get_option('libexecdir'),
|
||||
sources : [ 'dirs_cleaner/dirs_cleaner.c' ],
|
||||
)
|
||||
install_man('dirs_cleaner/dirs_cleaner.8')
|
||||
|
||||
executable(
|
||||
'edquota',
|
||||
dependencies : [ libdisk ],
|
||||
install : true,
|
||||
sources : [ 'edquota.tproj/edquota.c' ],
|
||||
)
|
||||
install_man('edquota.tproj/edquota.8')
|
||||
|
||||
executable(
|
||||
'fdisk',
|
||||
install : true,
|
||||
sources : [
|
||||
'fdisk.tproj/auto.c',
|
||||
'fdisk.tproj/cmd.c',
|
||||
'fdisk.tproj/disk.c',
|
||||
'fdisk.tproj/fdisk.c',
|
||||
'fdisk.tproj/getrawpartition.c',
|
||||
'fdisk.tproj/mbr.c',
|
||||
'fdisk.tproj/misc.c',
|
||||
'fdisk.tproj/opendev.c',
|
||||
'fdisk.tproj/part.c',
|
||||
'fdisk.tproj/user.c',
|
||||
],
|
||||
)
|
||||
install_man('fdisk.tproj/fdisk.8')
|
||||
|
||||
executable(
|
||||
'fsck',
|
||||
include_directories : [ 'edt_fstab', 'fsck.tproj' ],
|
||||
install : true,
|
||||
sources : [
|
||||
'edt_fstab/edt_fstab.c',
|
||||
'fsck.tproj/fsck.c',
|
||||
],
|
||||
)
|
||||
install_man('fsck.tproj/fsck.8')
|
||||
|
||||
foreach fstyp : [ 'fstyp', 'fstyp_msdos', 'fstyp_ntfs', 'fstyp_udf' ]
|
||||
executable(
|
||||
f'@fstyp@',
|
||||
install : true,
|
||||
sources : [ f'fstyp.tproj/@fstyp@.c' ],
|
||||
)
|
||||
install_man(f'fstyp.tproj/@fstyp@.8')
|
||||
endforeach
|
||||
|
||||
install_man('fuser.tproj/fuser.1')
|
||||
|
||||
executable(
|
||||
'mount',
|
||||
c_args : [
|
||||
# https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/sys/mount.h#L107
|
||||
'-DMNT_EXT_ROOT_DATA_VOL=0x00000001',
|
||||
# https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/sys/mount.h#L108
|
||||
'-DMNT_EXT_FSKIT=0x00000002',
|
||||
# https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/sys/mount.h#L337
|
||||
'-DMNT_NOFOLLOW=0x08000000',
|
||||
# https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/sys/mount.h#L340
|
||||
'-DMNT_STRICTATIME=0x80000000',
|
||||
# https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/sys/attr.h#L300
|
||||
'-DVOL_CAP_FMT_SEALED=0x02000000',
|
||||
'-D_DARWIN_USE_64_BIT_INODE=1', # Needed with older SDKs to ensure 64-bit `struct statfs`.
|
||||
],
|
||||
dependencies : [ apfs, libdisk ],
|
||||
include_directories : [ 'edt_fstab', 'fsck.tproj', 'mount_flags_dir' ],
|
||||
install : true,
|
||||
link_args : host_machine.cpu_family() == 'x86_64' ? [ '-Wl,-undefined,dynamic_lookup' ] : [ ],
|
||||
sources : [
|
||||
'edt_fstab/edt_fstab.c',
|
||||
'mount.tproj/mount.c',
|
||||
'mount.tproj/mount_tmpfs.c',
|
||||
'mount_flags_dir/mount_flags.c',
|
||||
],
|
||||
)
|
||||
install_man(
|
||||
'mount.tproj/fstab.5',
|
||||
'mount.tproj/mount.8',
|
||||
)
|
||||
|
||||
# executable(
|
||||
# 'mount_devfs',
|
||||
# install : true,
|
||||
# sources : [ 'mount_devfs.tproj/mount_devfs.c' ],
|
||||
# )
|
||||
|
||||
# executable(
|
||||
# 'mount_fdesc',
|
||||
# install : true,
|
||||
# sources : [ 'mount_fdesc.tproj/mount_fdesc.c' ],
|
||||
# )
|
||||
# install_man('mount_fdesc.tproj/mount_fdesc.8')
|
||||
|
||||
executable(
|
||||
'quota',
|
||||
install : true,
|
||||
sources : [ 'quota.tproj/quota.c' ],
|
||||
)
|
||||
install_man('quota.tproj/quota.1')
|
||||
|
||||
executable(
|
||||
'quotacheck',
|
||||
dependencies : [ libdisk ],
|
||||
install : true,
|
||||
sources : [
|
||||
'quotacheck.tproj/hfs_quotacheck.c',
|
||||
'quotacheck.tproj/quotacheck.c',
|
||||
],
|
||||
)
|
||||
install_man('quotacheck.tproj/quotacheck.8')
|
||||
|
||||
executable(
|
||||
'quotaon',
|
||||
install : true,
|
||||
sources : [ 'quotaon.tproj/quotaon.c' ],
|
||||
)
|
||||
install_man('quotaon.tproj/quotaon.8')
|
||||
install_symlink(
|
||||
'quotaoff',
|
||||
install_dir : get_option('bindir'),
|
||||
pointing_to : 'quotaon',
|
||||
)
|
||||
|
||||
executable(
|
||||
'repquota',
|
||||
install : true,
|
||||
sources : [ 'repquota.tproj/repquota.c' ],
|
||||
)
|
||||
install_man('repquota.tproj/repquota.8')
|
||||
|
||||
executable(
|
||||
'setclass',
|
||||
install : true,
|
||||
sources : [ 'setclass.tproj/setclass.c' ],
|
||||
)
|
||||
install_man('setclass.tproj/setclass.8')
|
||||
|
||||
# tmp_cleaner
|
||||
install_man('tmp_cleaner/tmp_cleaner.8')
|
||||
|
||||
executable(
|
||||
'umount',
|
||||
dependencies : [ libdisk ],
|
||||
include_directories : 'edt_fstab',
|
||||
install : true,
|
||||
sources : [
|
||||
'edt_fstab/edt_fstab.c',
|
||||
'umount.tproj/umount.c',
|
||||
],
|
||||
)
|
||||
install_man('umount.tproj/umount.8')
|
||||
|
||||
executable(
|
||||
'vsdbutil',
|
||||
c_args : [
|
||||
# https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/sys/mount.h#L107
|
||||
'-DMNT_EXT_ROOT_DATA_VOL=0x00000001',
|
||||
# https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/sys/mount.h#L108
|
||||
'-DMNT_EXT_FSKIT=0x00000002',
|
||||
# https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/sys/mount.h#L337
|
||||
'-DMNT_NOFOLLOW=0x08000000',
|
||||
# https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/sys/mount.h#L340
|
||||
'-DMNT_STRICTATIME=0x80000000',
|
||||
# https://github.com/apple-oss-distributions/xnu/blob/94d3b452840153a99b38a3a9659680b2a006908e/bsd/sys/attr.h#L300
|
||||
'-DVOL_CAP_FMT_SEALED=0x02000000',
|
||||
],
|
||||
dependencies : [ apfs ],
|
||||
install : true,
|
||||
sources : [
|
||||
'mount_flags_dir/mount_flags.c',
|
||||
'vsdbutil.tproj/vsdbutil_main.c',
|
||||
],
|
||||
)
|
||||
install_man('vsdbutil.tproj/vsdbutil.8')
|
@ -0,0 +1,76 @@
|
||||
{
|
||||
lib,
|
||||
apple-sdk,
|
||||
apple-sdk_11,
|
||||
libutil,
|
||||
mkAppleDerivation,
|
||||
removefile,
|
||||
stdenvNoCC,
|
||||
}:
|
||||
|
||||
let
|
||||
Libc = apple-sdk_11.sourceRelease "Libc";
|
||||
xnu = apple-sdk_11.sourceRelease "xnu";
|
||||
|
||||
privateHeaders = stdenvNoCC.mkDerivation {
|
||||
name = "diskdev_cmds-deps-private-headers";
|
||||
|
||||
buildCommand = ''
|
||||
for dir in arm i386 machine sys; do
|
||||
install -D -t "$out/include/$dir" '${xnu}'"/bsd/$dir/disklabel.h"
|
||||
done
|
||||
install -D -t "$out/include/os" \
|
||||
'${Libc}/os/api.h' \
|
||||
'${Libc}/os/variant_private.h' \
|
||||
'${Libc}/libdarwin/h/bsd.h' \
|
||||
'${Libc}/libdarwin/h/errno.h'
|
||||
install -D -t "$out/include/System/sys" \
|
||||
'${xnu}/bsd/sys/fsctl.h' \
|
||||
'${xnu}/bsd/sys/reason.h'
|
||||
install -D -t "$out/include/System/uuid" \
|
||||
'${Libc}/uuid/namespace.h'
|
||||
mkdir -p "$out/include/APFS"
|
||||
touch "$out/include/APFS/APFS.h"
|
||||
touch "$out/include/APFS/APFSConstants.h"
|
||||
|
||||
substituteInPlace "$out/include/os/variant_private.h" \
|
||||
--replace-fail ', bridgeos(4.0)' "" \
|
||||
--replace-fail ', bridgeos' ""
|
||||
'';
|
||||
};
|
||||
in
|
||||
mkAppleDerivation {
|
||||
releaseName = "diskdev_cmds";
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"man"
|
||||
];
|
||||
|
||||
xcodeHash = "sha256-Y4Lrr6gtbMj6+HDqmT5A+t59EIE5u780+0fLKoXaiIo=";
|
||||
|
||||
postPatch =
|
||||
# Fix incompatible pointer to integer conversion. The last parameter is size_t not a pointer.
|
||||
# https://developer.apple.com/documentation/kernel/1387446-sysctlbyname
|
||||
''
|
||||
substituteInPlace mount.tproj/mount.c \
|
||||
--replace-fail 'sysctlbyname ("vfs.generic.apfs.rosp", &is_rosp, &rospsize, NULL, NULL);' 'sysctlbyname ("vfs.generic.apfs.rosp", &is_rosp, &rospsize, NULL, 0);'
|
||||
''
|
||||
# The first reserved uint32 is used for the extended flags on 11.0 and newer, and
|
||||
# only use sysexit_np when the version is 10.14 or newer.
|
||||
+ lib.optionalString (lib.versionOlder (lib.getVersion apple-sdk) "11.0") ''
|
||||
substituteInPlace mount.tproj/mount.c \
|
||||
--replace-fail 'sfp->f_flags_ext' 'sfp->f_reserved[0]' \
|
||||
--replace-fail 'sysexit == -1' '__builtin_available(macOS 10.14, *) && sysexit == -1'
|
||||
'';
|
||||
|
||||
env.NIX_CFLAGS_COMPILE = "-I${privateHeaders}/include";
|
||||
|
||||
buildInputs = [
|
||||
apple-sdk.privateFrameworksHook
|
||||
libutil
|
||||
removefile
|
||||
];
|
||||
|
||||
meta.description = "Disk commands for Darwin";
|
||||
}
|
@ -26,5 +26,9 @@
|
||||
"developer_cmds": {
|
||||
"hash": "sha256-h0wMVlS6QdRvKOVJ74W9ziHYGApjvnk77AIR6ukYBRo=",
|
||||
"version": "62"
|
||||
},
|
||||
"diskdev_cmds": {
|
||||
"hash": "sha256-VX+hcZ7JhOA8EhwLloPlM3Yx79RXp9OYHV9Mi10uw3Q=",
|
||||
"version": "593"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user