diff --git a/plugins/python-build/README.md b/plugins/python-build/README.md index c9dcf425..1044db64 100644 --- a/plugins/python-build/README.md +++ b/plugins/python-build/README.md @@ -104,6 +104,10 @@ process. * `PYTHON_CONFIGURE_OPTS` and `PYTHON_MAKE_OPTS` allow you to specify configure and make options for buildling CPython. These variables will be passed to Python only, not any dependent packages (e.g. libyaml). +* `PYTHON_PATCH_PATH` allows you to specify a directory that contains + the patches for building CPython. All patches should be created + as same strip number (default `-p0`). `PYTHON_PATCH_OPTS` allows + you to override the options for `patch`. ### Checksum verification diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index 5d4430d9..47a5fc96 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 diff --git a/plugins/python-build/install.sh b/plugins/python-build/install.sh index 719df966..42c4042b 100755 --- a/plugins/python-build/install.sh +++ b/plugins/python-build/install.sh @@ -17,4 +17,4 @@ SHARE_PATH="${PREFIX}/share/python-build" mkdir -p "$BIN_PATH" "$SHARE_PATH" install -p bin/* "$BIN_PATH" -install -p share/python-build/* "$SHARE_PATH" +cp -RPp share/python-build/* "$SHARE_PATH"