commit:     da66246c68be060ea7484110fac298ac7fa4363d
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Sun May 22 04:03:48 2016 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Sun May 22 04:03:48 2016 +0000
URL:        https://gitweb.gentoo.org/dev/heroxbd.git/commit/?id=da66246c

prefix.eclass: add eprefixify_patch.

 eclass/prefix.eclass | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/eclass/prefix.eclass b/eclass/prefix.eclass
index 1f3c4b0..101cce2 100644
--- a/eclass/prefix.eclass
+++ b/eclass/prefix.eclass
@@ -12,6 +12,8 @@
 # located somewhere in the filesystem.  Prefix ebuilds require
 # additional functions and variables which are defined by this eclass.
 
+inherit eutils
+
 # @ECLASS-VARIABLE: EPREFIX
 # @DESCRIPTION:
 # The offset prefix of a Gentoo Prefix installation.  When Gentoo Prefix
@@ -48,5 +50,28 @@ eprefixify() {
        return 0
 }
 
+# @FUNCTION: eprefixify_patch
+# @USAGE: <list of patch files to be eprefixified>
+# @DESCRIPTION:
+# copies the patch files to ${T} and eprefixify before applying.
+# dies if no arguments are given, a file does not exist, or changing a
+# file failed.
+eprefixity_patch() {
+       [[ $# -lt 1 ]] && die "at least one argument required"
+
+       local x f
+       for x in "$@" ; do
+               if [[ -e ${x} ]] ; then
+                       f=${x##*/}
+                       cp "${x}" "${T}" || die "failed to copy patch"
+                       eprefixify "${T}"/${f}
+                       epatch "${T}"/${f}
+               else
+                       die "${x} does not exist"
+               fi
+       done
+
+       return 0
+}
 
 # vim: tw=72:

Reply via email to