From 75559df89de94c441aea999b36db711929573bab Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Fri, 20 Dec 2013 17:17:17 +0900 Subject: [PATCH] Search extra patches from given directory then apply it during build (#91) ``` $ env PYTHON_PATCH_PATH="./patches" PYTHON_PATCH_OPTS="-p1" pyenv install 2.7.6 ``` --- plugins/python-build/bin/python-build | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index 21ee206b..499e8c64 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -162,17 +162,24 @@ install_package_using() { apply_patches() { local package_name="$1" - local patches_path="${PYTHON_BUILD_ROOT}/share/python-build/patches/${DEFINITION_PATH##*/}" # Support PYTHON_PATCH_STRIP, etc. local package_var_name="$(capitalize "${package_name%%-*}")" + local PACKAGE_PATCH="${package_var_name}_PATCH" + local PACKAGE_PATCH_PATH="${package_var_name}_PATCH_PATH" local PACKAGE_PATCH_STRIP="${package_var_name}_PATCH_STRIP" + local PACKAGE_PATCH_OPTS="${package_var_name}_PATCH_OPTS" + local PACKAGE_PATCH_OPTS_ARRAY="${package_var_name}_PATCH_OPTS_ARRAY[@]" - for patch in "${patches_path}/${package_name}/"*; do + local patch_path="${!PACKAGE_PATCH_PATH:-${PYTHON_BUILD_PATCH_PATH}/${package_name}}" + # path may be given in relative from working directory + [ -e "${patch_path}" ] || patch_path="${CWD}/${patch_path}" + + local patch + for patch in "${patch_path}"/*; do if [ -f "$patch" ]; then - { - echo "Applying ${patch##*/} to ${package_name}..." - patch "-p${!PACKAGE_PATCH_STRIP:-0}" < "$patch" + echo "Applying ${patch##*/} to ${package_name}..." >&2 + { ${!PACKAGE_PATCH:-patch} "-p${!PACKAGE_PATCH_STRIP:-0}" $PATCH_OPTS ${!PACKAGE_PATCH_OPTS} "${!PACKAGE_PATCH_OPTS_ARRAY}" < "$patch" } >&4 2>&1 fi done @@ -1253,6 +1260,12 @@ elif [ ! -e "$DEFINITION_PATH" ]; then fi fi +if [ -z "$PYTHON_BUILD_PATCH_PATH" ]; then + PYTHON_BUILD_PATCH_PATH="${DEFINITION_PATH%/*}/patches/${DEFINITION_PATH##*/}" +else + PYTHON_BUILD_PATCH_PATH="${PYTHON_BUILD_PATCH_PATH%/}" +fi + PREFIX_PATH="${ARGUMENTS[1]}" if [ -z "$PREFIX_PATH" ]; then usage