summary refs log tree commit diff
path: root/pkgs/tools/networking/gnirehtet
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/tools/networking/gnirehtet')
-rw-r--r--pkgs/tools/networking/gnirehtet/default.nix27
-rw-r--r--pkgs/tools/networking/gnirehtet/paths.patch48
2 files changed, 13 insertions, 62 deletions
diff --git a/pkgs/tools/networking/gnirehtet/default.nix b/pkgs/tools/networking/gnirehtet/default.nix
index f739e80be1f..123ab3d76ee 100644
--- a/pkgs/tools/networking/gnirehtet/default.nix
+++ b/pkgs/tools/networking/gnirehtet/default.nix
@@ -1,12 +1,12 @@
-{stdenv, rustPlatform, fetchFromGitHub, fetchzip, androidenv, substituteAll}:
+{ lib, stdenv, rustPlatform, fetchFromGitHub, fetchzip, androidenv, makeWrapper }:
 let
-version = "2.4";
+version = "2.5";
 apk = stdenv.mkDerivation {
   pname = "gnirehtet.apk";
   inherit version;
   src = fetchzip {
     url = "https://github.com/Genymobile/gnirehtet/releases/download/v${version}/gnirehtet-rust-linux64-v${version}.zip";
-    sha256 = "13gsh5982v961j86j5y71pgas94g2d1v1fgnbslbqw4h69fbf48g";
+    sha256 = "1db0gkg5z8lighhkyqfsr9jiacrck89zmfnmp74vj865hhxgjzgq";
   };
   installPhase = ''
     mkdir $out
@@ -22,21 +22,20 @@ rustPlatform.buildRustPackage {
       owner = "Genymobile";
       repo = "gnirehtet";
       rev = "v${version}";
-      sha256 = "1c99d6zpjxa8xlrg0n1825am20d2pjiicfcjwv8iay9ylfdnvygl";
+      sha256 = "0wk6n082gnj9xk46n542h1012h8gyhldca23bs7vl73g0534g878";
   };
   sourceRoot = "source/relay-rust";
-  cargoSha256 = "0rb5xcqg5ikgrxpmzrql5n298j50aqgkkp45znbfv2x2n40dywad";
+  cargoSha256 = "03r8ivsvmhi5f32gj4yacbyzanziymszya18dani53bq9zis9z31";
 
-  patchFlags = [ "-p2" ];
-  patches = [
-    (substituteAll {
-      src = ./paths.patch;
-      adb = "${androidenv.androidPkgs_9_0.platform-tools}/bin/adb";
-      inherit apk;
-    })
-  ];
+  nativeBuildInputs = [ makeWrapper ];
 
-  meta = with stdenv.lib; {
+  postInstall = ''
+    wrapProgram $out/bin/gnirehtet \
+    --set GNIREHTET_APK ${apk}/gnirehtet.apk \
+    --set ADB ${androidenv.androidPkgs_9_0.platform-tools}/bin/adb
+  '';
+
+  meta = with lib; {
     description = "Reverse tethering over adb for Android";
     longDescription = ''
       This project provides reverse tethering over adb for Android: it allows devices to use the internet connection of the computer they are plugged on. It does not require any root access (neither on the device nor on the computer).
diff --git a/pkgs/tools/networking/gnirehtet/paths.patch b/pkgs/tools/networking/gnirehtet/paths.patch
deleted file mode 100644
index e5df4b8e4fe..00000000000
--- a/pkgs/tools/networking/gnirehtet/paths.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-Index: gnirehtet/relay-rust/src/main.rs
-===================================================================
---- gnirehtet.orig/relay-rust/src/main.rs
-+++ gnirehtet/relay-rust/src/main.rs
-@@ -299,7 +299,7 @@ impl Command for RelayCommand {
- 
- fn cmd_install(serial: Option<&String>) -> Result<(), CommandExecutionError> {
-     info!(target: TAG, "Installing gnirehtet client...");
--    exec_adb(serial, vec!["install", "-r", "gnirehtet.apk"])
-+    exec_adb(serial, vec!["install", "-r", "@apk@/gnirehtet.apk"])
- }
- 
- fn cmd_uninstall(serial: Option<&String>) -> Result<(), CommandExecutionError> {
-@@ -464,8 +464,8 @@ fn exec_adb<S: Into<String>>(
-     args: Vec<S>,
- ) -> Result<(), CommandExecutionError> {
-     let adb_args = create_adb_args(serial, args);
--    debug!(target: TAG, "Execute: adb {:?}", adb_args);
--    match process::Command::new("adb").args(&adb_args[..]).status() {
-+    debug!(target: TAG, "Execute: @adb@ {:?}", adb_args);
-+    match process::Command::new("@adb@").args(&adb_args[..]).status() {
-         Ok(exit_status) => {
-             if exit_status.success() {
-                 Ok(())
-@@ -487,8 +487,8 @@ fn must_install_client(serial: Option<&S
-         serial,
-         vec!["shell", "dumpsys", "package", "com.genymobile.gnirehtet"],
-     );
--    debug!(target: TAG, "Execute: adb {:?}", args);
--    match process::Command::new("adb").args(&args[..]).output() {
-+    debug!(target: TAG, "Execute: @adb@ {:?}", args);
-+    match process::Command::new("@adb@").args(&args[..]).output() {
-         Ok(output) => {
-             if output.status.success() {
-                 // the "regex" crate makes the binary far bigger, so just parse the versionCode
-Index: gnirehtet/relay-rust/src/adb_monitor.rs
-===================================================================
---- gnirehtet.orig/relay-rust/src/adb_monitor.rs
-+++ gnirehtet/relay-rust/src/adb_monitor.rs
-@@ -206,7 +206,7 @@ impl AdbMonitor {
-
-     fn start_adb_daemon() -> bool {
-         info!(target: TAG, "Restarting adb daemon");
--        match process::Command::new("adb")
-+        match process::Command::new("@adb@")
-             .args(&["start-server"])
-             .status() {
-             Ok(exit_status) => {