Unverified Commit 436139e8 authored by Arne Keller's avatar Arne Keller Committed by GitHub
Browse files

unblob: init at 25.1.8 (#345554)

parents ed644585 638fe294
Loading
Loading
Loading
Loading
+28 −5
Original line number Diff line number Diff line
{ lib, stdenv, fetchFromGitHub, zlib }:
{
  lib,
  stdenv,
  fetchFromGitHub,
  fetchpatch,
  zlib,
}:

stdenv.mkDerivation rec {
  pname = "simg2img";
  version = "1.1.4";
  version = "1.1.5";

  src = fetchFromGitHub {
    owner = "anestisb";
    repo = "android-simg2img";
    rev = version;
    sha256 = "1xm9kaqs2w8c7a4psv78gv66gild88mpgjn5lj087d7jh1jxy7bf";
    hash = "sha256-sNHdSbms35YnENASFEG+VMLJGkV/JAlQUVMquDrePDc=";
  };

  # fix GCC 14 error
  # https://github.com/anestisb/android-simg2img/pull/41
  postPatch = ''
    substituteInPlace backed_block.cpp \
      --replace-fail 'calloc(sizeof(struct backed_block_list), 1));' 'calloc(1, sizeof(struct backed_block_list)));'
    substituteInPlace sparse.cpp \
      --replace-fail 'calloc(sizeof(struct sparse_file), 1));' 'calloc(1, sizeof(struct sparse_file)));'
    substituteInPlace simg2simg.cpp \
      --replace-fail 'calloc(sizeof(struct sparse_file*), files);' 'calloc(files, sizeof(struct sparse_file*));'
  '';

  buildInputs = [ zlib ];

  makeFlags = [ "PREFIX=$(out)" "DEP_CXX:=$(CXX)" ];
  makeFlags = [
    "PREFIX=$(out)"
    "DEP_CXX:=$(CXX)"
  ];

  meta = with lib; {
    description = "Tool to convert Android sparse images to raw images";
    homepage = "https://github.com/anestisb/android-simg2img";
    license = licenses.asl20;
    platforms = platforms.unix;
    maintainers = with maintainers; [ dezgeg arkivm ];
    maintainers = with maintainers; [
      dezgeg
      arkivm
    ];
  };
}
+129 −0
Original line number Diff line number Diff line
{
  lib,
  fetchpatch,
  python3,
  fetchFromGitHub,
  gitUpdater,
  makeWrapper,
  e2fsprogs,
  jefferson,
  lz4,
  lziprecover,
  lzop,
  p7zip,
  sasquatch,
  sasquatch-v4be,
  simg2img,
  ubi_reader,
  unar,
  zstd,
  versionCheckHook,
}:

let
  # These dependencies are only added to PATH
  runtimeDeps = [
    e2fsprogs
    jefferson
    lziprecover
    lzop
    p7zip
    sasquatch
    sasquatch-v4be
    ubi_reader
    simg2img
    unar
    zstd
    lz4
  ];
in
python3.pkgs.buildPythonApplication rec {
  pname = "unblob";
  version = "25.1.8";
  pyproject = true;
  disabled = python3.pkgs.pythonOlder "3.9";

  src = fetchFromGitHub {
    owner = "onekey-sec";
    repo = "unblob";
    tag = version;
    hash = "sha256-PGpJPAo9q52gQ3EGusYtDA2e0MG5kFClqCYPB2DvuMs=";
    forceFetchGit = true;
    fetchLFS = true;
  };

  strictDeps = true;

  build-system = with python3.pkgs; [ poetry-core ];

  dependencies = with python3.pkgs; [
    arpy
    attrs
    click
    cryptography
    dissect-cstruct
    lark
    lief.py
    python3.pkgs.lz4 # shadowed by pkgs.lz4
    plotext
    pluggy
    pyfatfs
    pyperscan
    python-magic
    rarfile
    rich
    structlog
    treelib
    unblob-native
  ];

  nativeBuildInputs = [
    makeWrapper
  ];

  # These are runtime-only CLI dependencies, which are used through
  # their CLI interface
  pythonRemoveDeps = [
    "jefferson"
    "ubi-reader"
  ];

  pythonImportsCheck = [ "unblob" ];

  makeWrapperArgs = [
    "--prefix PATH : ${lib.makeBinPath runtimeDeps}"
  ];

  nativeCheckInputs =
    with python3.pkgs;
    [
      pytestCheckHook
      pytest-cov
      versionCheckHook
    ]
    ++ runtimeDeps;

  versionCheckProgramArg = "--version";

  pytestFlagsArray = [
    "--no-cov"
    # `disabledTests` swallows the parameters between square brackets
    # https://github.com/tytso/e2fsprogs/issues/152
    "-k 'not test_all_handlers[filesystem.extfs]'"
  ];

  passthru = {
    updateScript = gitUpdater { };
    # helpful to easily add these to a nix-shell environment
    inherit runtimeDeps;
  };

  meta = {
    description = "Extract files from any kind of container formats";
    homepage = "https://unblob.org";
    license = lib.licenses.mit;
    platforms = lib.platforms.unix;
    mainProgram = "unblob";
    maintainers = with lib.maintainers; [ vlaci ];
  };
}
+54 −0
Original line number Diff line number Diff line
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  gitUpdater,
  setuptools,
  setuptools-scm,
  fs,
  pytestCheckHook,
  pytest-mock,
}:

buildPythonPackage rec {
  pname = "pyfatfs";
  version = "1.1.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "nathanhi";
    repo = "pyfatfs";
    tag = "v${version}";
    hash = "sha256-26b4EV3WERUqJ10VkYov3PDFhSBcfxCF79P8Eg5xpoM=";
  };

  build-system = [
    setuptools
    setuptools-scm
  ];

  dependencies = [ fs ];

  postPatch = ''
    substituteInPlace ./pyproject.toml \
      --replace-fail 'setuptools ~= 67.8' setuptools \
      --replace-fail '"setuptools_scm[toml] ~= 7.1"' ""
  '';

  nativeCheckInputs = [
    pytestCheckHook
    pytest-mock
  ];

  env.SETUPTOOLS_SCM_PRETEND_VERSION = version;

  passthru.updateScript = gitUpdater { rev-prefix = "v"; };

  meta = {
    description = "Python based FAT12/FAT16/FAT32 implementation with VFAT support";
    homepage = "https://github.com/nathanhi/pyfatfs";
    license = lib.licenses.mit;
    platforms = lib.platforms.all;
    maintainers = with lib.maintainers; [ vlaci ];
  };
}
+46 −0
Original line number Diff line number Diff line
{
  lib,
  stdenvNoCC,
  buildPythonPackage,
  fetchFromGitHub,
  nix-update-script,
  rustPlatform,
  libiconv,
}:

buildPythonPackage rec {
  pname = "unblob-native";
  version = "0.1.5";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "onekey-sec";
    repo = "unblob-native";
    tag = "v${version}";
    hash = "sha256-jpaBxKuQNfU0I3kCs67mM5dzGURSSHvqymhk43P7xXk=";
  };

  cargoDeps = rustPlatform.fetchCargoVendor {
    inherit pname version src;
    hash = "sha256-K2QTf4OlP4AH2JJiJ6r8PRkInSOQdIBQcSvY5tWr4mw=";
  };

  nativeBuildInputs = with rustPlatform; [
    maturinBuildHook
    cargoSetupHook
  ];

  buildInputs = lib.optionals stdenvNoCC.hostPlatform.isDarwin [ libiconv ];

  pythonImportsCheck = [ "unblob_native" ];

  passthru.updateScript = nix-update-script { };

  meta = {
    description = "Performance sensitive parts of Unblob";
    homepage = "https://unblob.org";
    license = lib.licenses.mit;
    platforms = lib.platforms.unix;
    maintainers = with lib.maintainers; [ vlaci ];
  };
}
+4 −0
Original line number Diff line number Diff line
@@ -11710,6 +11710,8 @@ self: super: with self; {
  pyfantom = callPackage ../development/python-modules/pyfantom { };
  pyfatfs = callPackage ../development/python-modules/pyfatfs { };
  pyfcm = callPackage ../development/python-modules/pyfcm { };
  pyfido = callPackage ../development/python-modules/pyfido { };
@@ -17494,6 +17496,8 @@ self: super: with self; {
  unasync = callPackage ../development/python-modules/unasync { };
  unblob-native = callPackage ../development/python-modules/unblob-native { };
  uncertainties = callPackage ../development/python-modules/uncertainties { };
  uncompyle6 = callPackage ../development/python-modules/uncompyle6 { };