commit: eb192ed4f307517851214baf94a6bfd792338711
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 17 20:42:15 2014 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Dec 4 14:01:35 2014 +0000
URL:
http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=eb192ed4
Add tentative support for EAPI6 eapply function
Add the eapply patch applying function.
---
bin/eapi.sh | 4 ++++
bin/phase-helpers.sh | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+)
diff --git a/bin/eapi.sh b/bin/eapi.sh
index 978a410..8ffffbb 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -72,6 +72,10 @@ ___eapi_has_einstalldocs() {
[[ ! ${1-${EAPI}} =~
^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
}
+___eapi_has_eapply() {
+ [[ ! ${1-${EAPI}} =~
^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
+}
+
___eapi_has_master_repositories() {
[[ ${1-${EAPI}} =~ ^(5-progress)$ ]]
}
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index e401676..e9fbbb4 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -924,6 +924,68 @@ if ___eapi_has_einstalldocs; then
}
fi
+if ___eapi_has_eapply; then
+ eapply() {
+ _eapply_patch() {
+ local f=${1}
+ local prefix=${2}
+
+ started_applying=1
+ ebegin "${prefix:-Applying }${f##*/}"
+ # -p1 as a sane default
+ # -f to avoid interactivity
+ # -s to silence progress output
+ patch -p1 -f -s "${patch_options[@]}" < "${f}"
+ if ! eend ${?}; then
+ __helpers_die "patch -p1 ${patch_options[*]}
failed with ${f}"
+ failed=1
+ fi
+ }
+
+ local f patch_options=() failed started_applying
options_terminated
+ for f; do
+ if [[ ${f} == -* && -z ${options_terminated} ]]; then
+ if [[ -n ${started_applying} ]]; then
+ die "eapply: options need to be
specified before files"
+ fi
+ if [[ ${f} == -- ]]; then
+ options_terminated=1
+ else
+ patch_options+=( ${f} )
+ fi
+ elif [[ -d ${f} ]]; then
+ _eapply_get_files() {
+ local LC_ALL=POSIX
+ local prev_shopt=$(shopt -p nullglob)
+ shopt -s nullglob
+ files=( "${f}"/*.{patch,diff} )
+ ${prev_shopt}
+ }
+
+ local files
+ _eapply_get_files
+ [[ -z ${files[@]} ]] && die "No *.{patch,diff}
files in directory ${f}"
+
+ einfo "Applying patches from ${f} ..."
+ local f2
+ for f2 in "${files[@]}"; do
+ _eapply_patch "${f2}" ' '
+
+ # in case of nonfatal
+ [[ -n ${failed} ]] && return 1
+ done
+ else
+ _eapply_patch "${f}"
+
+ # in case of nonfatal
+ [[ -n ${failed} ]] && return 1
+ fi
+ done
+
+ return 0
+ }
+fi
+
if ___eapi_has_master_repositories; then
master_repositories() {
local output repository=$1 retval