diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-12-20 04:56:17 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-12-20 05:47:45 +0100 |
commit | f8f1739fc19d7201ae62ab643c89ec6d15390741 (patch) | |
tree | a608076596cd34f17a63d2b0b06d21f9e14ca668 /standalone-tools | |
parent | standalone-tools: add make push (diff) | |
download | android_kernel_wireguard-f8f1739fc19d7201ae62ab643c89ec6d15390741.tar.xz android_kernel_wireguard-f8f1739fc19d7201ae62ab643c89ec6d15390741.zip |
Drastically simplify
Diffstat (limited to 'standalone-tools')
-rw-r--r-- | standalone-tools/.gitignore | 2 | ||||
-rw-r--r-- | standalone-tools/Makefile | 39 | ||||
-rw-r--r-- | standalone-tools/addonsd.sh | 37 | ||||
-rw-r--r-- | standalone-tools/installer.sh | 74 |
4 files changed, 0 insertions, 152 deletions
diff --git a/standalone-tools/.gitignore b/standalone-tools/.gitignore deleted file mode 100644 index 030cc7a..0000000 --- a/standalone-tools/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -wireguard-tools.zip -build diff --git a/standalone-tools/Makefile b/standalone-tools/Makefile deleted file mode 100644 index 340233a..0000000 --- a/standalone-tools/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# -# Copyright (C) 2015-2017 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. - -ARCHS := $(shell ndk-build NDK_PROJECT_PATH=$(PWD)/build APP_BUILD_SCRIPT=$(PWD)/../Android.mk APP_PLATFORM=21 DUMP_NDK_KNOWN_DEVICE_ABIS 2>/dev/null) - -help: - @echo "Type \`make zip' to create a flashable zip, or type \`make push' to push tools to a running device using adb." - -clean: - rm -rf build wireguard-tools.zip - -wg-build: ../wg-quick.c - ndk-build NDK_PROJECT_PATH=$(PWD)/build APP_BUILD_SCRIPT=$(PWD)/../Android.mk APP_PLATFORM=21 - -$(foreach ARCH,$(ARCHS),build/libs/$(ARCH)/wg build/libs/$(ARCH)/wg-quick): wg-build - -wireguard-tools.zip: $(foreach ARCH,$(ARCHS),build/libs/$(ARCH)/wg-quick build/libs/$(ARCH)/wg) installer.sh addonsd.sh - rm -rf $@ build/zip build/*.zip - mkdir -p build/zip build/zip/addon.d build/zip/META-INF/com/google/android - ln -frs build/libs build/zip/arch - ln -frs addonsd.sh build/zip/addon.d/40-wireguard.sh - ln -frs installer.sh build/zip/META-INF/com/google/android/update-binary - touch build/zip/META-INF/com/google/android/updater-script - cd build/zip && zip -0Xr ../unaligned-$@ . - openssl req -x509 -nodes -newkey rsa:2048 -keyout build/key.pem -out build/cert.pem -days 3650 -subj /CN=$$(hostname)/ - openssl pkcs8 -topk8 -inform PEM -outform DER -in build/key.pem -out build/key.pk8 -nocrypt - $(ANDROID_HOME)/build-tools/27.0.1/zipalign -v -p 4 build/unaligned-$@ build/aligned-$@ - $(ANDROID_HOME)/build-tools/27.0.1/apksigner sign --key build/key.pk8 --cert build/cert.pem --min-sdk-version 21 --out $@ build/aligned-$@ - -zip: wireguard-tools.zip - -push: $(foreach ARCH,$(ARCHS),build/libs/$(ARCH)/wg-quick build/libs/$(ARCH)/wg) - ARCH="$$(adb shell 'su -c "mount -o rw,remount /system" && getprop ro.product.cpu.abi')" && \ - adb push "build/libs/$$ARCH/wg-quick" "build/libs/$$ARCH/wg" /sdcard && \ - adb shell 'su -c "mv /sdcard/wg /sdcard/wg-quick /system/xbin/ && chmod 755 /system/xbin/wg /system/xbin/wg-quick"' - -.PHONY: clean zip push -.SECONDARY: diff --git a/standalone-tools/addonsd.sh b/standalone-tools/addonsd.sh deleted file mode 100644 index 90865d0..0000000 --- a/standalone-tools/addonsd.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/sbin/sh - -. /tmp/backuptool.functions - -list_files() { -cat <<_EOF -xbin/wg -xbin/wg-quick -_EOF -} - -case "$1" in - backup) - list_files | while read FILE DUMMY; do - backup_file $S/"$FILE" - done - ;; - restore) - list_files | while read FILE REPLACEMENT; do - R="" - [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT" - [ -f "$C/$S/$FILE" ] && restore_file $S/"$FILE" "$R" - done - ;; - pre-backup) - # Stub - ;; - post-backup) - # Stub - ;; - pre-restore) - # Stub - ;; - post-restore) - # Stub - ;; -esac diff --git a/standalone-tools/installer.sh b/standalone-tools/installer.sh deleted file mode 100644 index 11838a1..0000000 --- a/standalone-tools/installer.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/sbin/sh -# SPDX-License-Identifier: GPL-2.0 -# -# Copyright (C) 2015-2017 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. - -SCRIPT="$1" -OUTFD="$2" -ZIP="$3" -ARCH="$(getprop ro.product.cpu.abi)" - -print() { - echo "ui_print [+] $*" >&$OUTFD -} - -die() { - echo "ui_print [-] $*" >&$OUTFD - exit 1 -} - -cleanup() { - mount -o ro,remount /system - rm -rf /tmp/wireguard -} - -mount_system() { - local slot dev - - if grep -q /system /proc/mounts; then - print "Remounting system partition r/w" - mount -o rw,remount /system || die "Could not remount system partition r/w" - else - print "Mounting system partition" - - slot="$(getprop ro.boot.slot_suffix)" - [ -z "$slot" ] && slot="$(getprop ro.boot.slot)" - - dev="$(find /dev/block -iname "system$slot" -print | head -n 1)" - [ -n "$dev" ] || die "Could not find system partition" - - mount -o rw "$dev" /system || die "Could not mount system partition" - fi -} - -echo "ui_print ==================================" >&$OUTFD -echo "ui_print = WireGuard Tools =" >&$OUTFD -echo "ui_print = by zx2c4 =" >&$OUTFD -echo "ui_print = www.wireguard.com =" >&$OUTFD -echo "ui_print ==================================" >&$OUTFD - -[ -n $ARCH ] || die "Could not determine architecture" -[ -f "$ZIP" ] || die "Could not find zip file" - -trap cleanup INT TERM EXIT - -mount_system - -print "Extracting files" -rm -rf /tmp/wireguard -mkdir -p /tmp/wireguard -unzip -d /tmp/wireguard "$ZIP" - -print "Installing WireGuard tools" -[ -d /tmp/wireguard/arch/$ARCH ] || die "Not available for device's ABI" -cp -f /tmp/wireguard/arch/$ARCH/* /system/xbin/ || die "Could not copy binaries" -chmod 755 /system/xbin/wg /system/xbin/wg-quick || die "Could not mark binaries as executable" - -if [ -d /system/addon.d ]; then - print "Installing ROM flash survial script" - cp -f /tmp/wireguard/addon.d/40-wireguard.sh /system/addon.d/ || die "Could not copy survival script" - chmod 755 /system/addon.d/40-wireguard.sh || die "Could not mark survival script as executable" -fi - -mkdir -pm 700 /data/misc/wireguard -print "Success! Be sure your kernel has the WireGuard module enabled." |