Merge pull request #193551 from OPNA2608/init/mac-fdisk

main
Sandro 2 years ago committed by GitHub
commit 3e6e7aa535
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      lib/licenses.nix
  2. 112
      pkgs/tools/system/mac-fdisk/default.nix
  3. 88
      pkgs/tools/system/pdisk/default.nix
  4. 6
      pkgs/top-level/all-packages.nix

@ -78,6 +78,12 @@ in mkLicense lset) ({
url = "https://aomedia.org/license/patent-license/";
};
apsl10 = {
spdxId = "APSL-1.0";
fullName = "Apple Public Source License 1.0";
url = "https://web.archive.org/web/20040701000000*/http://www.opensource.apple.com/apsl/1.0.txt";
};
apsl20 = {
spdxId = "APSL-2.0";
fullName = "Apple Public Source License 2.0";

@ -0,0 +1,112 @@
{ stdenv
, lib
, fetchzip
, fetchpatch
, installShellFiles
}:
stdenv.mkDerivation rec {
pname = "mac-fdisk";
version = "0.1.16";
src = fetchzip {
url = "https://deb.debian.org/debian/pool/main/m/mac-fdisk/mac-fdisk_0.1.orig.tar.gz";
sha256 = "sha256-pYNyhPvRKdIje0Rpay0OzmrkGcl+/JOhMv7r+2LZk/Q=";
};
patches = [
# Debian's changeset, extracted into a patch
(fetchpatch {
url = "https://git.adelielinux.org/adelie/packages/-/raw/1b708c8a90e3548c4954c6367a9376f76f3746bd/user/mac-fdisk/mac-fdisk-0.1-debian.patch";
sha256 = "sha256-a9pGF+UsFeZiXgracmT4anqgpmcGcS/W3jGtFzHZtt4=";
})
# Include a lot more headers and remove a bunch of braindead __linux__ checks
(fetchpatch {
url = "https://git.adelielinux.org/adelie/packages/-/raw/1fa4c88ee21866eeb0feae8f6b0bf609a04711cc/user/mac-fdisk/mac-fdisk-0.1-headers.patch";
sha256 = "sha256-FIk9K+lP+3e1pgmNfymTdpdSoTpBDv29kmwYgqYwWQw=";
})
# Add support for more architectures
(fetchpatch {
url = "https://git.adelielinux.org/adelie/packages/-/raw/1b708c8a90e3548c4954c6367a9376f76f3746bd/user/mac-fdisk/mac-fdisk-0.1-more-arches.patch";
sha256 = "sha256-HNRmzETUmKfZQFrjg6Y/HPwUnLk0vO5DokfU4umdOm0=";
})
# From p16 (source?), adjusts some types & fixes PPC64 support
(fetchpatch {
url = "https://git.adelielinux.org/adelie/packages/-/raw/1fa4c88ee21866eeb0feae8f6b0bf609a04711cc/user/mac-fdisk/mac-fdisk-0.1_p16-ppc64.patch";
sha256 = "sha256-GK0nfga59nOXotkbKI+2ejA9TtyZUwDIxuXWFGGbeFg=";
})
# From p16 (source?), makes some inlines static
(fetchpatch {
url = "https://git.adelielinux.org/adelie/packages/-/raw/1fa4c88ee21866eeb0feae8f6b0bf609a04711cc/user/mac-fdisk/mac-fdisk-0.1_p16-proper-inline.patch";
sha256 = "sha256-wr2teKpm0FyqNudKYlTD49pTFDis33Fo+0LULNYIJko=";
})
# Adds x86_64 support
(fetchpatch {
url = "https://git.adelielinux.org/adelie/packages/-/raw/1b708c8a90e3548c4954c6367a9376f76f3746bd/user/mac-fdisk/mac-fdisk-amd64.patch";
sha256 = "sha256-iO4/sY5sGKQyymMmAOb/TlCc9id2qgEDw7E8pFZpsHI=";
})
# Fix missing header in fdisk.c on musl
(fetchpatch {
url = "https://git.adelielinux.org/adelie/packages/-/raw/1fa4c88ee21866eeb0feae8f6b0bf609a04711cc/user/mac-fdisk/mac-fdisk-fdisk-header-musl.patch";
sha256 = "sha256-mKBVjvLKtxKPADeoPqp17YdJ1QWj2enAYhKKSqTnQ44=";
})
# Support disks >550GB
(fetchpatch {
url = "https://git.adelielinux.org/adelie/packages/-/raw/1fa4c88ee21866eeb0feae8f6b0bf609a04711cc/user/mac-fdisk/mac-fdisk-large-disk-support.patch";
sha256 = "sha256-IXZZdozqZKyZEz87ZzB8Jof22GgvHf4GaXBqSKn8su8=";
})
# Enable Large File Support (>2GiB)
(fetchpatch {
url = "https://git.adelielinux.org/adelie/packages/-/raw/1fa4c88ee21866eeb0feae8f6b0bf609a04711cc/user/mac-fdisk/mac-fdisk-largerthan2gb.patch";
sha256 = "sha256-ATK7QYXV7BOk8iIFeXY8g+ZHLuuhww9pcrqOMDn/oLM=";
})
# Fix compilation on non-glibc
(fetchpatch {
url = "https://git.adelielinux.org/adelie/packages/-/raw/1fa4c88ee21866eeb0feae8f6b0bf609a04711cc/user/mac-fdisk/mac-fdisk-non-glibc-support.patch";
sha256 = "sha256-CBZUKf7dPvvpuG5L+SI1FQ4W7/fDgeKXHUMFkJNu/MY=";
})
# Flush stdout after printing prompt for better UX
(fetchpatch {
url = "https://git.adelielinux.org/adelie/packages/-/raw/656ae6bf9f8a64aee95c4797b20bfe713627f1f4/user/mac-fdisk/flush-stdout.patch";
sha256 = "sha256-k7+UPiUf/oCQdDhxDcC+FRwkxS89WSsYzFw6fUB/10I=";
})
];
nativeBuildInputs = [
installShellFiles
];
enableParallelBuilding = true;
NIX_CFLAGS_COMPILE = "-D_GNU_SOURCE";
hardeningDisable = [ "format" ];
installPhase = ''
runHook preInstall
install -Dm755 pdisk $out/sbin/mac-fdisk
install -Dm755 fdisk $out/sbin/pmac-fdisk
for manpage in {,p}mac-fdisk.8; do
mv "$manpage".in $manpage
installManPage $manpage
done
runHook postInstall
'';
meta = with lib; {
description = "68K and PowerPC Mac disk partitioning utility, Adélie Linux version";
# http://ftp.mklinux.apple.com:/pub/Other_Tools/ but that one's looong dead, link goes to the patch compilation we're using
homepage = "https://git.adelielinux.org/adelie/packages/-/tree/master/user/mac-fdisk";
license = with licenses; [
hpnd # original license statements seems to match this (in files that are shared with pdisk)
gpl1Plus # fdisk.c
];
maintainers = with maintainers; [ OPNA2608 ];
# the toolchain that's being expected for Mac support (SCSI.h from Universal Headers 2.0, SIOUX.h from Metrowerks CoreWarrior) is ancient, unsure about BSDs
platforms = platforms.linux;
badPlatforms = platforms.aarch64; # missing some platform definitions
};
}

@ -0,0 +1,88 @@
{ stdenv
, lib
, fetchzip
, fetchpatch
, installShellFiles
, libbsd
, CoreFoundation
, IOKit
}:
stdenv.mkDerivation rec {
pname = "pdisk";
version = "0.9";
src = fetchzip {
url = "https://opensource.apple.com/tarballs/pdisk/pdisk-${lib.versions.minor version}.tar.gz";
sha256 = "sha256-+gBgnk/1juEHE0nXaz7laUaH7sxrX5SzsLGr0PHsdHs=";
};
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 {
url = "https://aur.archlinux.org/cgit/aur.git/plain/linux_strerror.patch?h=pdisk&id=&id=d0c930ea8bcac008bbd0ade1811133a625caea54";
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
];
NIX_CFLAGS_COMPILE = "-D_GNU_SOURCE";
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;
};
}

@ -7530,10 +7530,16 @@ with pkgs;
lucky-cli = callPackage ../development/web/lucky-cli { };
mac-fdisk = callPackage ../tools/system/mac-fdisk { };
partclone = callPackage ../tools/backup/partclone { };
partimage = callPackage ../tools/backup/partimage { };
pdisk = callPackage ../tools/system/pdisk {
inherit (darwin.apple_sdk.frameworks) CoreFoundation IOKit;
};
pgf_graphics = callPackage ../tools/graphics/pgf { };
pgformatter = callPackage ../development/tools/pgformatter { };

Loading…
Cancel
Save