mirror of
https://github.com/JulienMalka/snowfield.git
synced 2025-04-01 09:40:55 +02:00
bumped flaresolverr
This commit is contained in:
parent
4e68089909
commit
f74bd7c3fc
2 changed files with 51 additions and 56 deletions
|
@ -1,69 +1,45 @@
|
||||||
{ pkgs, stdenv }:
|
{ pkgs, lib, stdenv, python3 }:
|
||||||
with pkgs;
|
with pkgs;
|
||||||
|
let
|
||||||
|
python_env = pkgs.python3.withPackages
|
||||||
|
(p: with p; [ bottle waitress selenium func-timeout requests websockets xvfbwrapper ]);
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
in
|
||||||
|
stdenv.mkDerivation
|
||||||
|
rec {
|
||||||
|
|
||||||
pname = "flaresolverr";
|
pname = "flaresolverr";
|
||||||
version = "2.2.10";
|
version = "3.0.2";
|
||||||
|
|
||||||
src = fetchurl {
|
|
||||||
url = "https://github.com/FlareSolverr/FlareSolverr/releases/download/v2.2.10/flaresolverr-v2.2.10-linux-x64.zip";
|
src = fetchFromGitHub {
|
||||||
sha256 = "sha256-VZj7CkL1ef+Gfd90PCGUxMCuayzMkqVlGhJrM4Lmacs=";
|
owner = pname;
|
||||||
|
repo = pname;
|
||||||
|
rev = "v${version}";
|
||||||
|
sha256 = "sha256-zpeJf1CaQ4bsncZz44sH+tFKddYrZf7YdNYL50d9GA4=";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
buildInputs = [ pkgs.makeWrapper ];
|
||||||
|
nativeBuildInputs = [ chromedriver ];
|
||||||
|
patches = [ ./flaresolverr.patch ];
|
||||||
|
|
||||||
nativeBuildInputs = [
|
postPatch = ''
|
||||||
unzip
|
substituteInPlace src/utils.py \
|
||||||
];
|
--replace "CHANGEME" "${pkgs.chromedriver}/bin/chromedriver"
|
||||||
|
|
||||||
buildInputs = [ gcc stdenv.cc.cc.lib firefox ];
|
|
||||||
|
|
||||||
preFixup =
|
|
||||||
let
|
|
||||||
libPath = lib.makeLibraryPath [ stdenv.cc.cc ];
|
|
||||||
in
|
|
||||||
''
|
|
||||||
orig_size=$(stat --printf=%s $out/bin/flaresolverr)
|
|
||||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/bin/flaresolverr
|
|
||||||
patchelf --set-rpath ${libPath} $out/bin/flaresolverr
|
|
||||||
chmod +x $out/bin/flaresolverr
|
|
||||||
new_size=$(stat --printf=%s $out/bin/flaresolverr)
|
|
||||||
###### zeit-pkg fixing starts here.
|
|
||||||
# we're replacing plaintext js code that looks like
|
|
||||||
# PAYLOAD_POSITION = '1234 ' | 0
|
|
||||||
# [...]
|
|
||||||
# PRELUDE_POSITION = '1234 ' | 0
|
|
||||||
# ^-----20-chars-----^^------22-chars------^
|
|
||||||
# ^-- grep points here
|
|
||||||
#
|
|
||||||
# var_* are as described above
|
|
||||||
# shift_by seems to be safe so long as all patchelf adjustments occur
|
|
||||||
# before any locations pointed to by hardcoded offsets
|
|
||||||
var_skip=20
|
|
||||||
var_select=22
|
|
||||||
shift_by=$(expr $new_size - $orig_size)
|
|
||||||
function fix_offset {
|
|
||||||
# $1 = name of variable to adjust
|
|
||||||
location=$(grep -obUam1 "$1" $out/bin/flaresolverr | cut -d: -f1)
|
|
||||||
location=$(expr $location + $var_skip)
|
|
||||||
value=$(dd if=$out/bin/flaresolverr iflag=count_bytes,skip_bytes skip=$location \
|
|
||||||
bs=1 count=$var_select status=none)
|
|
||||||
value=$(expr $shift_by + $value)
|
|
||||||
echo -n $value | dd of=$out/bin/flaresolverr bs=1 seek=$location conv=notrunc
|
|
||||||
}
|
|
||||||
fix_offset PAYLOAD_POSITION
|
|
||||||
fix_offset PRELUDE_POSITION
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/share
|
||||||
cp flaresolverr $out/bin/
|
cp -r . $out/share
|
||||||
mkdir -p $out/bin/firefox
|
|
||||||
ln -s ${pkgs.firefox}/bin/firefox $out/bin/firefox/firefox
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
dontStrip = true;
|
postFixup = ''
|
||||||
|
makeWrapper ${python_env}/bin/python $out/bin/flaresolverr \
|
||||||
|
--prefix PATH : ${lib.makeBinPath [ pkgs.chromium pkgs.xvfb-run xorg.xorgserver pkgs.chromedriver ]} \
|
||||||
|
--add-flags $out/share/src/flaresolverr.py \
|
||||||
|
--chdir $out/share/
|
||||||
|
'';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
19
packages/flaresolverr/flaresolverr.patch
Normal file
19
packages/flaresolverr/flaresolverr.patch
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
diff --git a/src/utils.py b/src/utils.py
|
||||||
|
index ceff7ec..06623bb 100644
|
||||||
|
--- a/src/utils.py
|
||||||
|
+++ b/src/utils.py
|
||||||
|
@@ -69,13 +69,10 @@ def get_webdriver() -> WebDriver:
|
||||||
|
|
||||||
|
# downloads and patches the chromedriver
|
||||||
|
# if we don't set driver_executable_path it downloads, patches, and deletes the driver each time
|
||||||
|
- driver = uc.Chrome(options=options, driver_executable_path=driver_exe_path, version_main=version_main,
|
||||||
|
+ driver = uc.Chrome(options=options, driver_executable_path="CHANGEME",
|
||||||
|
windows_headless=windows_headless)
|
||||||
|
|
||||||
|
# save the patched driver to avoid re-downloads
|
||||||
|
- if driver_exe_path is None:
|
||||||
|
- PATCHED_DRIVER_PATH = os.path.join(driver.patcher.data_path, driver.patcher.exe_name)
|
||||||
|
- shutil.copy(driver.patcher.executable_path, PATCHED_DRIVER_PATH)
|
||||||
|
|
||||||
|
# selenium vanilla
|
||||||
|
# options = webdriver.ChromeOptions()
|
Loading…
Add table
Reference in a new issue