Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_7zz: 22.00 -> 22.01; build on macOS #146010

Merged
merged 3 commits into from
Jul 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 33 additions & 20 deletions pkgs/tools/archivers/7zz/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
, lib
, fetchurl

# Only used for x86/x86_64
# Only used for Linux's x86/x86_64
, uasm
, useUasm ? stdenv.hostPlatform.isx86
, useUasm ? (stdenv.isLinux && stdenv.hostPlatform.isx86)

# RAR code is under non-free unRAR license
# see the meta.license section below for more details
Expand All @@ -16,23 +16,23 @@
}:

let
inherit (stdenv.hostPlatform) system;
platformSuffix = {
aarch64-linux = "_arm64";
i686-linux = "_x86";
x86_64-linux = "_x64";
}.${system} or
(builtins.trace "`platformSuffix` not available for `${system}.` Making a generic `7zz` build." "");
makefile = {
aarch64-darwin = "../../cmpl_mac_arm64.mak";
x86_64-darwin = "../../cmpl_mac_x64.mak";
aarch64-linux = "../../cmpl_gcc_arm64.mak";
i686-linux = "../../cmpl_gcc_x86.mak";
x86_64-linux = "../../cmpl_gcc_x64.mak";
}.${stdenv.hostPlatform.system} or "../../cmpl_gcc.mak"; # generic build
in
stdenv.mkDerivation rec {
pname = "7zz";
version = "22.00";
version = "22.01";

src = fetchurl {
url = "https://7-zip.org/a/7z${lib.replaceStrings [ "." ] [ "" ] version}-src.tar.xz";
hash = {
free = "sha256-QzGZgPxHobGwstFfVRtb4V+hqMM7dMIy2/EZcJ2aZe8=";
unfree = "sha256-QJafYB6Gr/Saqgug31zm/Tl89+JoOoS1kbAIHkYe9nU=";
free = "sha256-mp3cFXOEiVptkUdD1+X8XxwoJhBGs+Ns5qk3HBByfLg=";
unfree = "sha256-OTCYcwxwBCOSr4CJF+dllF3CQ33ueq48/MSWbrkg+8U=";
}.${if enableUnfree then "unfree" else "free"};
downloadToTemp = (!enableUnfree);
# remove the unRAR related code from the src drv
Expand All @@ -51,27 +51,40 @@ stdenv.mkDerivation rec {
'';
};

sourceRoot = "CPP/7zip/Bundles/Alone2";
sourceRoot = ".";

patches = [ ./fix-build-on-darwin.patch ];
patchFlags = [ "-p0" ];

NIX_CFLAGS_COMPILE = lib.optionals stdenv.isDarwin [
"-Wno-deprecated-copy-dtor"
];

inherit makefile;

makeFlags =
[
"CC=${stdenv.cc.targetPrefix}cc"
"CXX=${stdenv.cc.targetPrefix}c++"
] ++
lib.optionals useUasm [ "MY_ASM=uasm" ] ++
]
++ lib.optionals useUasm [ "MY_ASM=uasm" ]
# We need at minimum 10.13 here because of utimensat, however since
# we need a bump anyway, let's set the same minimum version as the one in
# aarch64-darwin so we don't need additional changes for it
++ lib.optionals stdenv.isDarwin [ "MACOSX_DEPLOYMENT_TARGET=10.16" ]
# it's the compression code with the restriction, see DOC/License.txt
lib.optionals (!enableUnfree) [ "DISABLE_RAR_COMPRESS=true" ];

makefile = "../../cmpl_gcc${platformSuffix}.mak";
++ lib.optionals (!enableUnfree) [ "DISABLE_RAR_COMPRESS=true" ];

nativeBuildInputs = lib.optionals useUasm [ uasm ];

enableParallelBuilding = true;

preBuild = "cd CPP/7zip/Bundles/Alone2";

installPhase = ''
runHook preInstall

install -Dm555 -t $out/bin b/g${platformSuffix}/7zz
install -Dm555 -t $out/bin b/*/7zz
install -Dm444 -t $out/share/doc/${pname} ../../../../DOC/*.txt

runHook postInstall
Expand All @@ -96,7 +109,7 @@ stdenv.mkDerivation rec {
# the unRAR compression code is disabled by default
lib.optionals enableUnfree [ unfree ];
maintainers = with maintainers; [ anna328p peterhoeg jk ];
platforms = platforms.linux;
platforms = platforms.unix;
mainProgram = "7zz";
};
}
24 changes: 24 additions & 0 deletions pkgs/tools/archivers/7zz/fix-build-on-darwin.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff -Naur CPP/7zip/Common/FileStreams.cpp CPP/7zip/Common/FileStreams.cpp
--- CPP/7zip/Common/FileStreams.cpp
+++ CPP/7zip/Common/FileStreams.cpp
@@ -12,7 +12,7 @@
#include <pwd.h>

// for major()/minor():
-#if defined(__FreeBSD__) || defined(BSD)
+#if defined(__FreeBSD__) || defined(BSD) || defined(__APPLE__)
#include <sys/types.h>
#else
#include <sys/sysmacros.h>
diff -Naur CPP/7zip/UI/Common/UpdateCallback.cpp CPP/7zip/UI/Common/UpdateCallback.cpp
--- CPP/7zip/UI/Common/UpdateCallback.cpp
+++ CPP/7zip/UI/Common/UpdateCallback.cpp
@@ -9,7 +9,7 @@
// #include <pwd.h>

// for major()/minor():
-#if defined(__FreeBSD__) || defined(BSD)
+#if defined(__FreeBSD__) || defined(BSD) || defined(__APPLE__)
#include <sys/types.h>
#else
#include <sys/sysmacros.h>
7 changes: 4 additions & 3 deletions pkgs/tools/archivers/7zz/update.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p coreutils gnused curl jq
#! nix-shell -i bash -p coreutils gnused curl jq nix-prefetch
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"

DRV_DIR="$PWD"

OLD_VERSION="$(sed -nE 's/\s*version = "(.*)".*/\1/p' ./default.nix)"

NEW_VERSION="$(curl "https://sourceforge.net/projects/sevenzip/best_release.json" | jq '.platform_releases.linux.filename' -r | cut -d/ -f3)"
# The best_release.json is not always up-to-date
# In those cases you can force the version by calling `./update.sh <newer_version>`
NEW_VERSION="${1:-$(curl 'https://sourceforge.net/projects/sevenzip/best_release.json' | jq '.platform_releases.linux.filename' -r | cut -d/ -f3)}"

echo "comparing versions $OLD_VERSION => $NEW_VERSION"
if [[ "$OLD_VERSION" == "$NEW_VERSION" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ with pkgs;

_6tunnel = callPackage ../tools/networking/6tunnel { };

_7zz = callPackage ../tools/archivers/7zz { };
_7zz = darwin.apple_sdk_11_0.callPackage ../tools/archivers/7zz { };

_9pfs = callPackage ../tools/filesystems/9pfs { };

Expand Down