Unverified Commit d0809c6f authored by 7c6f434c's avatar 7c6f434c Committed by GitHub
Browse files

curl-impersonate: 0.6.1 -> 0.7.0 (#333589)

parents b6c75475 2939ad7b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: let
      pyyaml
      pytest-asyncio
      dpkt
      ts1-signatures
    ]}"

    # Prepare test root prefix
+44 −0
Original line number Diff line number Diff line
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  setuptools,
  dpkt,
  pyyaml,
  pythonOlder,
  pytestCheckHook,
}:
buildPythonPackage {
  pname = "ts1-signatures";
  version = "0-unstable-2024-08-10";
  pyproject = true;

  disabled = pythonOlder "3.7";

  src = fetchFromGitHub {
    owner = "yifeikong";
    repo = "th1";
    rev = "efa682bd37c668ae00d2225deb753e01f6cd1406";
    hash = "sha256-fz5EFPO5UPPbFnqe4wE1y2lIROPByse9awyBa49o8ZE=";
  };

  build-system = [ setuptools ];

  dependencies = [
    dpkt
    pyyaml
  ];

  nativeCheckInputs = [ pytestCheckHook ];

  disabledTests = [
    "test_nghttpd_log_parsing" # Attempts to load things from logs/ which it cannot find for some reason.
  ];

  meta = {
    description = "TLS and HTTP signature and fingerprint library";
    homepage = "https://github.com/yifeikong/th1";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ ggg ];
  };
}
+206 −0
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  fetchFromGitHub,
  callPackage,
  buildGoModule,
  installShellFiles,
  buildPackages,
  zlib,
  zstd,
  sqlite,
  cmake,
  python3,
  ninja,
  perl,
  autoconf,
  automake,
  libtool,
  cctools,
  cacert,
  unzip,
  go,
  p11-kit,
}:
stdenv.mkDerivation rec {
  pname = "curl-impersonate-chrome";
  version = "0.7.0";

  outputs = [
    "out"
    "dev"
  ];

  src = fetchFromGitHub {
    owner = "yifeikong";
    repo = "curl-impersonate";
    rev = "v${version}";
    hash = "sha256-nxANiNgrbbp7F6k2y1HGGWGOUBRwc3tK8WcNIqEBLz4=";
  };

  patches = [ ./disable-building-docs.patch ];

  # Disable blanket -Werror to fix build on `gcc-13` related to minor
  # warnings on `boringssl`.
  env.NIX_CFLAGS_COMPILE = "-Wno-error";

  strictDeps = true;

  depsBuildBuild = lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
    buildPackages.stdenv.cc
  ];

  nativeBuildInputs =
    lib.optionals stdenv.isDarwin [
      # Must come first so that it shadows the 'libtool' command but leaves 'libtoolize'
      cctools
    ]
    ++ [
      installShellFiles
      cmake
      python3
      python3.pythonOnBuildForHost.pkgs.gyp
      ninja
      perl
      autoconf
      automake
      libtool
      unzip
      go
    ];

  buildInputs = [
    zlib
    zstd
    sqlite
  ];

  configureFlags = [
    "--with-ca-bundle=${
      if stdenv.isDarwin then "/etc/ssl/cert.pem" else "/etc/ssl/certs/ca-certificates.crt"
    }"
    "--with-ca-path=${cacert}/etc/ssl/certs"
  ];

  buildFlags = [ "chrome-build" ];
  checkTarget = "chrome-checkbuild";
  installTargets = [ "chrome-install" ];

  doCheck = true;

  dontUseCmakeConfigure = true;
  dontUseNinjaBuild = true;
  dontUseNinjaInstall = true;
  dontUseNinjaCheck = true;

  postUnpack =
    lib.concatStringsSep "\n" (
      lib.mapAttrsToList (name: dep: "ln -sT ${dep.outPath} source/${name}") (
        lib.filterAttrs (n: v: v ? outPath) passthru.deps
      )
    )
    + ''

      curltar=$(realpath -s source/curl-*.tar.gz)

      pushd "$(mktemp -d)"

      tar -xf "$curltar"

      pushd curl-curl-*/
      patchShebangs scripts
      popd

      rm "$curltar"
      tar -czf "$curltar" .

      popd
    '';

  preConfigure = ''
    export GOCACHE=$TMPDIR/go-cache
    export GOPATH=$TMPDIR/go
    export GOPROXY=file://${passthru.boringssl-go-modules}
    export GOSUMDB=off

    # Need to get value of $out for this flag
    configureFlagsArray+=("--with-libnssckbi=$out/lib")
  '';

  postInstall =
    ''
      # Remove vestigial *-config script
      rm $out/bin/curl-impersonate-chrome-config

      # Patch all shebangs of installed scripts
      patchShebangs $out/bin

      # Install headers
      make -C curl-*/include install
    ''
    + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
      # Build and install completions for each curl binary

      # Patch in correct binary name and alias it to all scripts
      perl curl-*/scripts/completion.pl --curl $out/bin/curl-impersonate-chrome --shell zsh >$TMPDIR/curl-impersonate-chrome.zsh
      substituteInPlace $TMPDIR/curl-impersonate-chrome.zsh \
        --replace-fail \
          '#compdef curl' \
          "#compdef curl-impersonate-chrome$(find $out/bin -name 'curl_*' -printf ' %f=curl-impersonate-chrome')"

      perl curl-*/scripts/completion.pl --curl $out/bin/curl-impersonate-chrome --shell fish >$TMPDIR/curl-impersonate-chrome.fish
      substituteInPlace $TMPDIR/curl-impersonate-chrome.fish \
        --replace-fail \
          '--command curl' \
          "--command curl-impersonate-chrome$(find $out/bin -name 'curl_*' -printf ' --command %f')"

      # Install zsh and fish completions
      installShellCompletion $TMPDIR/curl-impersonate-chrome.{zsh,fish}
    '';

  preFixup =
    let
      libext = stdenv.hostPlatform.extensions.sharedLibrary;
    in
    ''
      # If libnssckbi.so is needed, link libnssckbi.so without needing nss in closure
      if grep -F nssckbi $out/lib/libcurl-impersonate-*${libext} &>/dev/null; then
        ln -s ${p11-kit}/lib/pkcs11/p11-kit-trust${libext} $out/lib/libnssckbi${libext}
        ${lib.optionalString stdenv.hostPlatform.isElf ''
          patchelf --add-needed libnssckbi${libext} $out/lib/libcurl-impersonate-*${libext}
        ''}
      fi
    '';

  disallowedReferences = [ go ];

  passthru = {
    deps = callPackage ./deps.nix { };

    updateScript = ./update.sh;

    boringssl-go-modules =
      (buildGoModule {
        inherit (passthru.deps."boringssl.zip") name;

        src = passthru.deps."boringssl.zip";
        vendorHash = "sha256-oKlwh+Oup3lVgqgq42vY3iLg62VboF9N565yK2W0XxI=";

        nativeBuildInputs = [ unzip ];

        proxyVendor = true;
      }).goModules;
  };

  meta = {
    description = "Special build of curl that can impersonate Chrome & Firefox";
    homepage = "https://github.com/yifeikong/curl-impersonate";
    license = with lib.licenses; [
      curl
      mit
    ];
    maintainers = with lib.maintainers; [ ggg ];
    platforms = lib.platforms.unix;
    mainProgram = "curl-impersonate-chrome";
  };
}
+24 −0
Original line number Diff line number Diff line
# Generated by update.sh
{ fetchurl }:

{
  "curl-8_7_1.tar.gz" = fetchurl {
    url = "https://github.com/curl/curl/archive/curl-8_7_1.tar.gz";
    hash = "sha256-DkbIVvUXYCw0e7X+W3MXT47nmLyH8alyNclXYfdfzCg=";
  };

  "brotli-1.1.0.tar.gz" = fetchurl {
    url = "https://github.com/google/brotli/archive/refs/tags/v1.1.0.tar.gz";
    hash = "sha256-5yCmyilCi4A/StFlNxdx9TmPq6OX7fZ3iDehhZnqE/8=";
  };

  "boringssl.zip" = fetchurl {
    url = "https://github.com/google/boringssl/archive/d24a38200fef19150eef00cad35b138936c08767.zip";
    hash = "sha256-tzAAwL70VAyUEOZZ86ql+RgXsw4DZhkvW5l0d1eVVHU=";
  };

  "nghttp2-1.61.0.tar.bz2" = fetchurl {
    url = "https://github.com/nghttp2/nghttp2/releases/download/v1.61.0/nghttp2-1.61.0.tar.bz2";
    hash = "sha256-Toz37DLUxaQwlmJC1yA10lXNlHCodm1h7tegGQ3VRP0=";
  };
}
+20 −0
Original line number Diff line number Diff line
From 5366ca35b3d20ef962ccf54399cc44f523d803be Mon Sep 17 00:00:00 2001
From: GGG <gggkiller2@gmail.com>
Date: Mon, 5 Aug 2024 04:19:29 -0300
Subject: [PATCH] Disable building docs
---
 Makefile.in | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile.in b/Makefile.in
index 41d7324..b1f5ec6 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -249,6 +249,7 @@ $(CURL_VERSION)/.chrome: $(chrome_libs)	$(CURL_VERSION).tar.gz $(CURL_VERSION)/.
 	# (for cross compilation), then pass it on to curl.
 	{ \
 	  config_flags="--prefix=@prefix@"; \
+	  config_flags="$$config_flags --disable-manual"; \
 	  config_flags="$$config_flags --with-nghttp2=$(nghttp2_install_dir)"; \
 	  config_flags="$$config_flags --with-brotli=$(brotli_install_dir)"; \
 	  config_flags="$$config_flags --with-openssl=$(boringssl_install_dir)"; \
Loading