From 1e77a600a4879b627e228e46d6d5da62b3a00128 Mon Sep 17 00:00:00 2001 From: Sergey Abramchuk Date: Wed, 4 Mar 2020 11:52:03 +0300 Subject: [PATCH] Add scripts to apply patches --- Scripts/apply_patches.sh | 19 +++++++++++++++++++ Scripts/functions.sh | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100755 Scripts/apply_patches.sh create mode 100644 Scripts/functions.sh diff --git a/Scripts/apply_patches.sh b/Scripts/apply_patches.sh new file mode 100755 index 0000000..4b47d0b --- /dev/null +++ b/Scripts/apply_patches.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -e + +. functions.sh + +ASIO_SRC_DIR="../Sources/ASIO" +ASIO_PATCH_DIR="../Sources/OpenVPN3/deps/asio/patches" + +MBEDTLS_SRC_DIR="../Sources/mbedTLS" +MBEDTLS_PATCH_DIR="../Sources/OpenVPN3/deps/mbedtls/patches" + +if [ "$1" = "--reverse" ]; then + reverse_patches ${ASIO_SRC_DIR} ${ASIO_PATCH_DIR} + reverse_patches ${MBEDTLS_SRC_DIR} ${MBEDTLS_PATCH_DIR} +else + apply_patches ${ASIO_SRC_DIR} ${ASIO_PATCH_DIR} + apply_patches ${MBEDTLS_SRC_DIR} ${MBEDTLS_PATCH_DIR} +fi diff --git a/Scripts/functions.sh b/Scripts/functions.sh new file mode 100644 index 0000000..e45a91b --- /dev/null +++ b/Scripts/functions.sh @@ -0,0 +1,37 @@ +function apply_patches() +{ + DEP_SRC_DIR=$1 + DEP_PATCH_DIR=$2 + + CURRENT_DIR=$(pwd) + + pushd ${CURRENT_DIR} + + cd /tmp + + for file in ${CURRENT_DIR}/${DEP_PATCH_DIR}/*.patch; do + echo Applying patch: $file + git apply --directory ${CURRENT_DIR}/${DEP_SRC_DIR} --unsafe-path $file + done + + popd +} + +function reverse_patches() +{ + DEP_SRC_DIR=$1 + DEP_PATCH_DIR=$2 + + CURRENT_DIR=$(pwd) + + pushd ${CURRENT_DIR} + + cd /tmp + + for file in ${CURRENT_DIR}/${DEP_PATCH_DIR}/*.patch; do + echo Reverse patch: $file + git apply --reverse --directory ${CURRENT_DIR}/${DEP_SRC_DIR} --unsafe-path $file + done + + popd +}