Apply built-in patches only if patch is not given via STDIN

This commit is contained in:
Yamashita Yuu 2013-12-30 17:18:03 +09:00
parent 1f76effbfb
commit 4953fa4034
2 changed files with 36 additions and 64 deletions

View file

@ -104,10 +104,6 @@ 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

View file

@ -160,57 +160,12 @@ install_package_using() {
} >&2
}
apply_patches() {
local package_name="$1"
# Support PYTHON_PATCH, PYTHON_PATCH_OPTS, etc.
local package_var_name="$(capitalize "${package_name%%-*}")"
local PACKAGE_PATCH="${package_var_name}_PATCH"
local PACKAGE_PATCH_OPTS="${package_var_name}_PATCH_OPTS"
if [ -z "${PATCH_OPTS+defined}" ] && [ -z "${!PACKAGE_PATCH_OPTS+defined}" ]; then
local PATCH_OPTS="-p0"
fi
local patch
for patch in $(list_patches "${package_name}"); do
echo "Applying ${patch##*/} to ${package_name}..." >&2
{ ${!PACKAGE_PATCH:-patch} $PATCH_OPTS ${!PACKAGE_PATCH_OPTS} < "$patch"
} >&4 2>&1
done
}
list_patches() {
local package_name="$1"
# Support PYTHON_PATCH_PATH, etc.
local package_var_name="$(capitalize "${package_name%%-*}")"
local PACKAGE_PATCH_PATH="${package_var_name}_PATCH_PATH"
if [ "${!PACKAGE_PATCH_PATH+defined}" ]; then
# patch path may be given in relative from working directory
if [[ "${!PACKAGE_PATCH_PATH}" != /* ]]; then
local patch_path="${CWD}/${!PACKAGE_PATCH_PATH}"
else
local patch_path="${!PACKAGE_PATCH_PATH}"
fi
else
local patch_path="${PYTHON_BUILD_PATCH_PATH}/${package_name}"
fi
{ for patch in "${patch_path}"/*; do
[ -f "${patch}" ] && echo "${patch}"
done
} | sort
}
make_package() {
local package_name="$1"
shift
pushd "$package_name" >&4
before_install_package "$package_name"
apply_patches "$package_name"
build_package "$package_name" $*
after_install_package "$package_name"
fix_directory_permissions
@ -744,10 +699,28 @@ build_package_copy() {
before_install_package() {
local stub=1
before_install_package_patch "$@"
}
before_install_package_patch() {
# Apply built-in patches if patch was not given from stdin
if [ -z "$HAS_PATCH" ]; then
( cat "${PYTHON_BUILD_ROOT}/share/python-build/patches/${DEFINITION_PATH##*/}/$1"/* || true ) 2>/dev/null 1>"$1.patch"
exec <&-
exec <"$1.patch"
fi
ORIG_HAS_PATCH="$HAS_PATCH"
HAS_PATCH=true
}
after_install_package() {
local stub=1
after_install_package_patch "$@"
}
after_install_package_patch() {
rm -f "$1.patch"
HAS_PATCH="$ORIG_HAS_PATCH"
}
fix_directory_permissions() {
@ -973,13 +946,13 @@ has_broken_mac_readline() {
}
use_homebrew_readline() {
local libdir="$(brew --prefix readline 2>/dev/null || true)"
if [ -d "$libdir" ]; then
CPPFLAGS="-I$libdir/include $CPPFLAGS"
LDFLAGS="-L$libdir/lib $LDFLAGS"
else
return 1
fi
local libdir="$(brew --prefix readline 2>/dev/null || true)"
if [ -d "$libdir" ]; then
CPPFLAGS="-I$libdir/include $CPPFLAGS"
LDFLAGS="-L$libdir/lib $LDFLAGS"
else
return 1
fi
}
has_broken_mac_openssl() {
@ -1089,9 +1062,19 @@ isolated_gem_install() {
}
apply_python_patch() {
local package_name="$1"
# Support PYTHON_PATCH_OPTS, etc.
local package_var_name="$(capitalize "${package_name%%-*}")"
local PACKAGE_PATCH_OPTS="${package_var_name}_PATCH_OPTS"
if [ -z "${PATCH_OPTS+defined}" ] && [ -z "${!PACKAGE_PATCH_OPTS+defined}" ]; then
local PATCH_OPTS="-p0"
fi
case "$1" in
Python-* | jython-* | pypy-* )
patch -p0 -i "${2:--}"
${PATCH:-patch} $PATCH_OPTS ${!PACKAGE_PATCH_OPTS} -i "${2:--}"
;;
esac
}
@ -1302,13 +1285,6 @@ elif [ ! -e "$DEFINITION_PATH" ]; then
fi
fi
if [ -z "$PYTHON_BUILD_PATCH_PATH" ]; then
# Find patches from "./patches" relatively from the definition path
PYTHON_BUILD_PATCH_PATH="$(abs_dirname "${DEFINITION_PATH}" 2>/dev/null)/patches/${DEFINITION_PATH##*/}"
else
PYTHON_BUILD_PATCH_PATH="$(abs_dirname "${PYTHON_BUILD_PATCH_PATH}/.." 2>/dev/null)"
fi
PREFIX_PATH="${ARGUMENTS[1]}"
if [ -z "$PREFIX_PATH" ]; then
usage