Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH 05/13] Add tentative support for EAPI6 eapply function
Date: Mon, 18 Aug 2014 17:56:29
Message-Id: 1408384612-14713-6-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCHES] Initial EAPI6 patch set for review by "Michał Górny"
1 Add the eapply patch applying function.
2 ---
3 bin/eapi.sh | 4 ++++
4 bin/phase-helpers.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
5 2 files changed, 56 insertions(+)
6
7 diff --git a/bin/eapi.sh b/bin/eapi.sh
8 index 978a410..8ffffbb 100644
9 --- a/bin/eapi.sh
10 +++ b/bin/eapi.sh
11 @@ -72,6 +72,10 @@ ___eapi_has_einstalldocs() {
12 [[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
13 }
14
15 +___eapi_has_eapply() {
16 + [[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
17 +}
18 +
19 ___eapi_has_master_repositories() {
20 [[ ${1-${EAPI}} =~ ^(5-progress)$ ]]
21 }
22 diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
23 index 6ccf4f4..6bd8a12 100644
24 --- a/bin/phase-helpers.sh
25 +++ b/bin/phase-helpers.sh
26 @@ -875,6 +875,58 @@ if ___eapi_has_einstalldocs; then
27 }
28 fi
29
30 +if ___eapi_has_eapply; then
31 + eapply() {
32 + _eapply_patch() {
33 + started_applying=1
34 + ebegin "Applying ${1#${top_dir}/}"
35 + # -p1 as a sane default
36 + # -f to avoid interactivity
37 + # -s to silence progress output
38 + patch -p1 -f -s "${patch_options[@]}" < "${1}"
39 + if ! eend ${?}; then
40 + __helpers_die "patch -p1 ${patch_options[*]} failed with ${1}"
41 + failed=1
42 + fi
43 + }
44 +
45 + local f patch_options=() failed started_applying options_terminated
46 + for f; do
47 + local top_dir=${f%/*}
48 +
49 + if [[ ${f} == -* && -z ${options_terminated} ]]; then
50 + if [[ -n ${started_applying} ]]; then
51 + die "eapply: options need to be specified before files"
52 + fi
53 + if [[ ${f} == -- ]]; then
54 + options_terminated=1
55 + else
56 + patch_options+=( ${f} )
57 + fi
58 + elif [[ -d ${f} ]]; then
59 + local prev_shopt=$(shopt -p nullglob)
60 + shopt -s nullglob
61 + local files=( "${f}"/*.{patch,diff} )
62 + ${prev_shopt}
63 +
64 + [[ -z ${files[@]} ]] && die "No *.{patch,diff} files in directory ${f}"
65 +
66 + local f2
67 + for f2 in "${files[@]}"; do
68 + _eapply_patch "${f2}"
69 + done
70 + else
71 + _eapply_patch "${f}"
72 + fi
73 +
74 + # in case of nonfatal
75 + [[ -n ${failed} ]] && return 1
76 + done
77 +
78 + return 0
79 + }
80 +fi
81 +
82 if ___eapi_has_master_repositories; then
83 master_repositories() {
84 local output repository=$1 retval
85 --
86 2.0.4