Skip to content

Commit

Permalink
pkgs/topsap: init at 3.5.2.36.2 (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
inclyc authored Jan 4, 2024
1 parent b48cd45 commit 11d5c30
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .github/workflows/cachix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ jobs:
- name: Build NixOS configuration
run: nix build .#nixosConfigurations.${{ matrix.host }}.config.system.build.toplevel

build-packages:
strategy:
matrix:
package: [ topsap ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v12
with:
name: inclyc
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
# Cherry-picked from https://github.com/TGuimbert/dotfiles/blob/3b9d27ec6e22ab7c70819799876e4eb089678424/.github/workflows/cachix.yaml#L8
- name: Build Packages
run: nix build .#${{ matrix.package }}

build-home-configurations:
strategy:
matrix:
Expand Down
4 changes: 3 additions & 1 deletion pkgs/default.nix
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{ pkgs ? (import ../nixpkgs.nix) { } }: { }
{ pkgs ? (import ../nixpkgs.nix) { } }: {
topsap = pkgs.callPackage ./topsap { };
}
57 changes: 57 additions & 0 deletions pkgs/topsap/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{ stdenv
, fetchurl
, perl
, dpkg
, libuuid
, buildFHSUserEnvBubblewrap
, autoPatchelfHook
, ...
}:
stdenv.mkDerivation rec {
pname = "topsap";
version = "3.5.2.36.2";
src = fetchurl {
urls = [
"https://github.com/inclyc/containerized-topsap/releases/download/topsec-v${version}/TopSAP-${version}-x86_64.deb"
"https://app.topsec.com.cn/vpn/sslvpnclient/TopSAP-${version}-x86_64.deb"
];
sha256 = "sha256-I859oVKa7n3VGIZvzu0h0bYXGFg27jxd5GHsnX7Y+yE=";
};

nativeBuildInputs = [
autoPatchelfHook
dpkg
];

buildInputs = [
stdenv.cc.cc
libuuid
];


unpackCmd = "dpkg -x $curSrc source";

dontConfigure = true;
dontBuild = true;

installPhase = ''
sh opt/TopSAP/TopSAP*.bin --target $name --noexec
mkdir -p $out/{bin,lib}
cp $name/common/topvpn $out/bin
cp $name/common/sv_websrv $out/bin
# ELF hack, sv_websrv tries to dlopen "./libvpn_client.so"
# Let's patch "./libvpn_client.so" -> "libvpn_client.so\0\0"
# man:dlopen(3) said: if it is a relative or absolute path, DT_RUNPATH will not be searched.
${perl}/bin/perl -0777 -pe 's/\.\/libvpn_client\.so/substr q{libvpn_client.so}."\0"x length$&,0,length$&/e or die "pattern not found"' -i $out/bin/sv_websrv
cp $name/common/libvpn_client.so $out/lib
'';

postFixup = ''
patchelf --add-needed libvpn_client.so \
--add-rpath $out/lib \
$out/bin/sv_websrv
'';
}

0 comments on commit 11d5c30

Please sign in to comment.