2022-10-21 18:38:19 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
2023-02-02 18:25:31 +00:00
|
|
|
, fetchFromGitHub
|
2022-10-21 18:38:19 +00:00
|
|
|
, fetchpatch
|
|
|
|
, installShellFiles
|
|
|
|
, libbsd
|
|
|
|
, CoreFoundation
|
|
|
|
, IOKit
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "pdisk";
|
|
|
|
version = "0.9";
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "apple-oss-distributions";
|
|
|
|
repo = pname;
|
|
|
|
rev = "${pname}-${lib.versions.minor version}";
|
|
|
|
hash = "sha256-+gBgnk/1juEHE0nXaz7laUaH7sxrX5SzsLGr0PHsdHs=";
|
2022-10-21 18:38:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
# Fix makefile for Unix
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://aur.archlinux.org/cgit/aur.git/plain/makefile.patch?h=pdisk&id=39dc371712d2f7dbd38f6e8ddc6ba661faa1a7a9";
|
|
|
|
sha256 = "sha256-mLFclu8IlDN/gxNTI7Kei6ARketlAhJRu8ForFUzFU0=";
|
|
|
|
})
|
|
|
|
# Fix lseek usage in file_media.c
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://aur.archlinux.org/cgit/aur.git/plain/file_media.c.patch?h=pdisk&id=39dc371712d2f7dbd38f6e8ddc6ba661faa1a7a9";
|
|
|
|
sha256 = "sha256-CCq5fApwx6w1GKDrgP+0nUdQy/5z5ON7/fdp4M63nko=";
|
|
|
|
})
|
|
|
|
# Fix open_partition_map call in cvt_pt.c
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://aur.archlinux.org/cgit/aur.git/plain/cvt_pt.c.patch?h=pdisk&id=39dc371712d2f7dbd38f6e8ddc6ba661faa1a7a9";
|
|
|
|
sha256 = "sha256-jScPfzt9/fQHkf2MfHLvYsh/Rw2NZZXkzZiiVo8F5Mc=";
|
|
|
|
})
|
|
|
|
# Replace removed sys_nerr and sys_errlist with strerror
|
|
|
|
(fetchpatch {
|
2023-03-08 16:32:21 +00:00
|
|
|
url = "https://aur.archlinux.org/cgit/aur.git/plain/linux_strerror.patch?h=pdisk&id=d0c930ea8bcac008bbd0ade1811133a625caea54";
|
2022-10-21 18:38:19 +00:00
|
|
|
sha256 = "sha256-HGJIS+vTn6456KtaETutIgTPPBm2C9OHf1anG8yaJPo=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace makefile \
|
|
|
|
--replace 'cc' '${stdenv.cc.targetPrefix}cc'
|
|
|
|
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
|
|
|
|
substituteInPlace makefile \
|
|
|
|
--replace '-lbsd' '-framework CoreFoundation -framework IOKit'
|
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
installShellFiles
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = lib.optionals (!stdenv.hostPlatform.isDarwin) [
|
|
|
|
libbsd
|
|
|
|
] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
|
|
|
|
CoreFoundation
|
|
|
|
IOKit
|
|
|
|
];
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = "-D_GNU_SOURCE";
|
2022-10-21 18:38:19 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
install -Dm755 cvt_pt $out/bin/cvt_pt
|
|
|
|
install -Dm755 pdisk $out/bin/pdisk
|
|
|
|
|
|
|
|
installManPage pdisk.8
|
|
|
|
install -Dm644 pdisk.html $out/share/doc/pdisk/pdisk.html
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "A low-level Apple partition table editor for Linux, OSS Apple version";
|
|
|
|
homepage = "https://github.com/apple-oss-distributions/pdisk";
|
|
|
|
license = with licenses; [
|
|
|
|
hpnd # original license statements seems to match this (in files that are shared with mac-fdisk)
|
|
|
|
apsl10 # new files
|
|
|
|
];
|
|
|
|
maintainers = with maintainers; [ OPNA2608 ];
|
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|