Skip to content

Instantly share code, notes, and snippets.

@disassembler
Created May 22, 2017 20:32
Show Gist options
  • Save disassembler/35f8e50a35045d67d1b684b5dec31e63 to your computer and use it in GitHub Desktop.
Save disassembler/35f8e50a35045d67d1b684b5dec31e63 to your computer and use it in GitHub Desktop.
with import <nixpkgs> { system = "x86_64-linux"; };
stdenv.mkDerivation {
name = "forticlientsslvpn-4.4.2333";
src = fetchurl {
url = https://github.com/mcereda/forticlientsslvpn/raw/master/tarball/forticlientsslvpn_linux_4.4.2333.tar.gz;
sha256 = "0vqnv2fdkank8iajhry5my45ips6j26ip6i6gdbw9ymih3dw8aji";
};
buildInputs = [ makeWrapper ];
propagatedBuildInputs = [ iproute ];
buildCommand = ''
# Extract files from the installer
cp $src forticlientsslvpn_linux_4.4.2333.tar.gz
tar -zxvf forticlientsslvpn_linux_4.4.2333.tar.gz
# Patch ELF binaries
patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux-x86-64.so.2 forticlientsslvpn/64bit/forticlientsslvpn
patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux-x86-64.so.2 forticlientsslvpn/64bit/forticlientsslvpn_cli
patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux-x86-64.so.2 forticlientsslvpn/64bit/helper/subproc
patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux-x86-64.so.2 forticlientsslvpn/64bit/helper/showlicense
patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux-x86-64.so.2 forticlientsslvpn/64bit/helper/setup
patchelf --set-rpath $(pwd):${stdenv.cc.libc}/lib:${stdenv.cc.cc.lib}/lib:${gdk_pixbuf}/lib:${pango.out}/lib:${gtk2}/lib:${xlibs.libX11}/lib:${xlibs.libXext}/lib:${glib}/lib:${xorg.libSM}/lib:${xlibs.libXinerama}/lib forticlientsslvpn/64bit/forticlientsslvpn
patchelf --set-rpath $(pwd):${stdenv.cc.libc}/lib:${stdenv.cc.cc.lib}/lib forticlientsslvpn/64bit/forticlientsslvpn_cli
patchelf --set-rpath $(pwd):${stdenv.cc.libc}/lib:${stdenv.cc.cc.lib}/lib forticlientsslvpn/64bit/helper/subproc
patchelf --set-rpath $(pwd):${stdenv.cc.libc}/lib:${stdenv.cc.cc.lib}/lib forticlientsslvpn/64bit/helper/setup
patchelf --set-rpath $(pwd):${stdenv.cc.libc}/lib:${stdenv.cc.cc.lib}/lib:${gdk_pixbuf}/lib:${pango.out}/lib:${gtk2}/lib:${xlibs.libX11}/lib:${xlibs.libXext}/lib:${glib}/lib:${xorg.libSM}/lib:${xlibs.libXinerama}/lib forticlientsslvpn/64bit/helper/showlicense
# Move extracted files into the Nix store
mkdir -p $out/bin
mv forticlientsslvpn/64bit/forticlientsslvpn $out/bin
mv forticlientsslvpn/64bit/forticlientsslvpn_cli $out/bin
mv forticlientsslvpn/64bit/helper $out/bin/
wrapProgram $out/bin/forticlientsslvpn \
--set LD_PRELOAD "${libredirect}/lib/libredirect.so" \
--set NIX_REDIRECTS /sbin/ip=${iproute}/bin/ip:/usr/sbin/pppd=${ppp}/sbin/pppd
wrapProgram $out/bin/forticlientsslvpn_cli \
--set LD_PRELOAD "${libredirect}/lib/libredirect.so" \
--set NIX_REDIRECTS /sbin/ip=${iproute}/bin/ip
wrapProgram $out/bin/helper/showlicense \
--set LD_PRELOAD "${libredirect}/lib/libredirect.so" \
--set NIX_REDIRECTS ./helper/License.txt=$out/bin/helper/License.txt:/usr/bin/sudo=/run/wrappers/bin/sudo:./helper/setup=$out/bin/helper/setup
wrapProgram $out/bin/helper/setup \
--set LD_PRELOAD "${libredirect}/lib/libredirect.so" \
--set NIX_REDIRECTS ./helper/License.txt=$out/bin/helper/License.txt:/usr/bin/sudo=/run/wrappers/bin/sudo:./helper/setup=$out/bin/helper/setup
chmod +x $out/bin/forticlientsslvpn $out/bin/forticlientsslvpn_cli $out/bin/helper/subproc $out/bin/helper/showlicense $out/bin/helper/setup
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment