From f5307941ccc8936510afd8e1517049e190c0200a Mon Sep 17 00:00:00 2001 From: Symphorien Gibol Date: Fri, 22 Jun 2018 14:57:37 +0200 Subject: gnirehtet: init at 2.2.1 --- pkgs/tools/networking/gnirehtet/default.nix | 50 +++++++++++++++++++++++++++++ pkgs/tools/networking/gnirehtet/paths.patch | 35 ++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 pkgs/tools/networking/gnirehtet/default.nix create mode 100644 pkgs/tools/networking/gnirehtet/paths.patch (limited to 'pkgs/tools/networking') diff --git a/pkgs/tools/networking/gnirehtet/default.nix b/pkgs/tools/networking/gnirehtet/default.nix new file mode 100644 index 00000000000..8a2d32e543b --- /dev/null +++ b/pkgs/tools/networking/gnirehtet/default.nix @@ -0,0 +1,50 @@ +{stdenv, rustPlatform, fetchFromGitHub, fetchzip, androidenv, substituteAll}: +let +version = "2.2.1"; +apk = stdenv.mkDerivation { + name = "gnirehtet.apk-${version}"; + src = fetchzip { + url = "https://github.com/Genymobile/gnirehtet/releases/download/v${version}/gnirehtet-rust-linux64-v${version}.zip"; + sha256 = "1rz2wdjc1y7n8fhskmki1nj0ak80ylxspcsrcdnjkk9r7jbq0kan"; + }; + installPhase = '' + mkdir $out + mv gnirehtet.apk $out + ''; +}; +in +rustPlatform.buildRustPackage rec { + name = "gnirehtet-${version}"; + + src = fetchFromGitHub { + owner = "Genymobile"; + repo = "gnirehtet"; + rev = "v${version}"; + sha256 = "1mv8nq4422k2d766qjqqnqp47qzzbbvlwhdni0k6w4nmd3m5cnd9"; + }; + sourceRoot = "source/relay-rust"; + cargoSha256 = "11qf9n6h6akvb0rbmsgdlfmypkbnas8ss1cs7i8w19mh7524n0v5"; + + patchFlags = [ "-p2" ]; + patches = [ + (substituteAll { + src = ./paths.patch; + adb = "${androidenv.platformTools}/bin/adb"; + inherit apk; + }) + ]; + + meta = with stdenv.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). + + This relies on adb, make sure you have the required permissions/udev rules. + ''; + homepage = https://github.com/Genymobile/gnirehtet; + license = licenses.asl20; + maintainers = with maintainers; [ symphorien ]; + platforms = platforms.unix; + }; +} + diff --git a/pkgs/tools/networking/gnirehtet/paths.patch b/pkgs/tools/networking/gnirehtet/paths.patch new file mode 100644 index 00000000000..72a8445d83b --- /dev/null +++ b/pkgs/tools/networking/gnirehtet/paths.patch @@ -0,0 +1,35 @@ +diff --git a/relay-rust/src/main.rs b/relay-rust/src/main.rs +index 4f1be53..96d2e78 100644 +--- a/relay-rust/src/main.rs ++++ b/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> { +@@ -467,8 +467,8 @@ fn exec_adb>( + args: Vec, + ) -> 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(()) +@@ -490,8 +490,8 @@ fn must_install_client(serial: Option<&String>) -> Result { + if output.status.success() { + // the "regex" crate makes the binary far bigger, so just parse the versionCode -- cgit 1.4.1