2021-01-11 08:54:33 +01:00
|
|
|
{ lib, stdenv, fetchurl, dpkg }:
|
2019-03-07 00:50:43 +01:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "fx_cast_bridge";
|
2020-07-24 03:47:41 +02:00
|
|
|
version = "0.0.7";
|
2019-03-07 00:50:43 +01:00
|
|
|
|
|
|
|
src = fetchurl {
|
2019-09-07 20:12:20 +02:00
|
|
|
url = "https://github.com/hensm/fx_cast/releases/download/v${version}/${pname}-${version}-x64.deb";
|
2020-07-24 03:47:41 +02:00
|
|
|
sha256 = "0kd58vzsq1qzl7qsh1qv25ylxvr5y37li03gjb48x4vhd85slzz5";
|
2019-03-07 00:50:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ dpkg ];
|
|
|
|
|
|
|
|
unpackPhase = ''
|
|
|
|
runHook preUnpack
|
2019-08-20 14:02:46 +02:00
|
|
|
dpkg-deb -xv $src ./
|
2019-03-07 00:50:43 +01:00
|
|
|
runHook postUnpack
|
|
|
|
'';
|
|
|
|
|
|
|
|
dontBuild = true;
|
|
|
|
dontPatchELF = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
2019-09-07 20:12:20 +02:00
|
|
|
install -DT {opt/fx_cast,$out/bin}/${pname}
|
|
|
|
install -DT {usr,$out}/lib/mozilla/native-messaging-hosts/${pname}.json
|
2019-03-07 00:50:43 +01:00
|
|
|
|
2019-09-07 20:12:20 +02:00
|
|
|
substituteInPlace $out/lib/mozilla/native-messaging-hosts/${pname}.json \
|
|
|
|
--replace {/opt/fx_cast,$out/bin}/${pname}
|
2019-03-07 00:50:43 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
# See now-cli/default.nix
|
|
|
|
dontStrip = true;
|
|
|
|
preFixup = let
|
2019-08-20 15:54:26 +02:00
|
|
|
libPath = stdenv.lib.makeLibraryPath [stdenv.cc.cc stdenv.cc.libc];
|
2019-09-07 20:12:20 +02:00
|
|
|
bin = "$out/bin/${pname}";
|
2019-03-07 00:50:43 +01:00
|
|
|
in ''
|
|
|
|
|
|
|
|
orig_size=$(stat --printf=%s ${bin})
|
|
|
|
|
|
|
|
patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" ${bin}
|
|
|
|
patchelf --set-rpath ${libPath} ${bin}
|
|
|
|
chmod +x ${bin}
|
|
|
|
|
|
|
|
new_size=$(stat --printf=%s ${bin})
|
|
|
|
|
|
|
|
###### 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" ${bin} | cut -d: -f1)
|
|
|
|
location=$(expr $location + $var_skip)
|
|
|
|
|
|
|
|
value=$(dd if=${bin} iflag=count_bytes,skip_bytes skip=$location \
|
|
|
|
bs=1 count=$var_select status=none)
|
|
|
|
value=$(expr $shift_by + $value)
|
|
|
|
|
|
|
|
echo -n $value | dd of=${bin} bs=1 seek=$location conv=notrunc
|
|
|
|
}
|
|
|
|
|
|
|
|
fix_offset PAYLOAD_POSITION
|
|
|
|
fix_offset PRELUDE_POSITION
|
|
|
|
|
|
|
|
'';
|
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2019-03-07 00:50:43 +01:00
|
|
|
description = "Implementation of the Chrome Sender API (Chromecast) within Firefox";
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "https://hensm.github.io/fx_cast/";
|
2019-03-07 00:50:43 +01:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ dtzWill ];
|
|
|
|
};
|
|
|
|
}
|