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
```
This commit is contained in:
Yamashita Yuu 2013-12-20 17:17:17 +09:00
parent 3d5156ed1d
commit 75559df89d

View file

@ -162,17 +162,24 @@ install_package_using() {
apply_patches() { apply_patches() {
local package_name="$1" local package_name="$1"
local patches_path="${PYTHON_BUILD_ROOT}/share/python-build/patches/${DEFINITION_PATH##*/}"
# Support PYTHON_PATCH_STRIP, etc. # Support PYTHON_PATCH_STRIP, etc.
local package_var_name="$(capitalize "${package_name%%-*}")" 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_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 if [ -f "$patch" ]; then
{ echo "Applying ${patch##*/} to ${package_name}..." >&2
echo "Applying ${patch##*/} to ${package_name}..." { ${!PACKAGE_PATCH:-patch} "-p${!PACKAGE_PATCH_STRIP:-0}" $PATCH_OPTS ${!PACKAGE_PATCH_OPTS} "${!PACKAGE_PATCH_OPTS_ARRAY}" < "$patch"
patch "-p${!PACKAGE_PATCH_STRIP:-0}" < "$patch"
} >&4 2>&1 } >&4 2>&1
fi fi
done done
@ -1253,6 +1260,12 @@ elif [ ! -e "$DEFINITION_PATH" ]; then
fi fi
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]}" PREFIX_PATH="${ARGUMENTS[1]}"
if [ -z "$PREFIX_PATH" ]; then if [ -z "$PREFIX_PATH" ]; then
usage usage