make internal script paths relocatable

BUG=b:20895978

Change-Id: I3e80a9606dc17c7e57e0c3d84651d8e160ccba27
diff --git a/usr/lib/portage/bin/ebuild-helpers/die b/usr/lib/portage/bin/ebuild-helpers/die
index e1cd8ef..456378e 100755
--- a/usr/lib/portage/bin/ebuild-helpers/die
+++ b/usr/lib/portage/bin/ebuild-helpers/die
@@ -2,6 +2,10 @@
 # Copyright 2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 die "$@"
 exit 1
diff --git a/usr/lib/portage/bin/ebuild-helpers/dobin b/usr/lib/portage/bin/ebuild-helpers/dobin
index 51b7087..402fc3b 100755
--- a/usr/lib/portage/bin/ebuild-helpers/dobin
+++ b/usr/lib/portage/bin/ebuild-helpers/dobin
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 if [[ $# -lt 1 ]] ; then
 	__helpers_die "${0##*/}: at least one argument needed"
diff --git a/usr/lib/portage/bin/ebuild-helpers/doconfd b/usr/lib/portage/bin/ebuild-helpers/doconfd
index 26a4029..7162cbe 100755
--- a/usr/lib/portage/bin/ebuild-helpers/doconfd
+++ b/usr/lib/portage/bin/ebuild-helpers/doconfd
@@ -3,7 +3,10 @@
 # Distributed under the terms of the GNU General Public License v2
 
 if [[ $# -lt 1 ]] ; then
-	source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+	if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+		PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+	fi
+	source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 	__helpers_die "${0##*/}: at least one argument needed"
 	exit 1
 fi
diff --git a/usr/lib/portage/bin/ebuild-helpers/dodir b/usr/lib/portage/bin/ebuild-helpers/dodir
index f4f89fd..e3f1819 100755
--- a/usr/lib/portage/bin/ebuild-helpers/dodir
+++ b/usr/lib/portage/bin/ebuild-helpers/dodir
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 if ! ___eapi_has_prefix_variables; then
 	ED=${D}
diff --git a/usr/lib/portage/bin/ebuild-helpers/dodoc b/usr/lib/portage/bin/ebuild-helpers/dodoc
index fc874ca..21b663b 100755
--- a/usr/lib/portage/bin/ebuild-helpers/dodoc
+++ b/usr/lib/portage/bin/ebuild-helpers/dodoc
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 if ___eapi_dodoc_supports_-r; then
 	exec \
diff --git a/usr/lib/portage/bin/ebuild-helpers/doenvd b/usr/lib/portage/bin/ebuild-helpers/doenvd
index 8f0e6e6..689c834 100755
--- a/usr/lib/portage/bin/ebuild-helpers/doenvd
+++ b/usr/lib/portage/bin/ebuild-helpers/doenvd
@@ -3,7 +3,10 @@
 # Distributed under the terms of the GNU General Public License v2
 
 if [[ $# -lt 1 ]] ; then
-	source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+	if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+		PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+	fi
+	source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 	__helpers_die "${0##*/}: at least one argument needed"
 	exit 1
 fi
diff --git a/usr/lib/portage/bin/ebuild-helpers/doexe b/usr/lib/portage/bin/ebuild-helpers/doexe
index a323177..5484d07 100755
--- a/usr/lib/portage/bin/ebuild-helpers/doexe
+++ b/usr/lib/portage/bin/ebuild-helpers/doexe
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 if [[ $# -lt 1 ]] ; then
 	__helpers_die "${0##*/}: at least one argument needed"
diff --git a/usr/lib/portage/bin/ebuild-helpers/dohtml b/usr/lib/portage/bin/ebuild-helpers/dohtml
index be134ad..38c64b0 100755
--- a/usr/lib/portage/bin/ebuild-helpers/dohtml
+++ b/usr/lib/portage/bin/ebuild-helpers/dohtml
@@ -2,10 +2,13 @@
 # Copyright 2009-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+	PORTAGE_PYM_PATH="${PORTAGE_BIN_PATH%/*}/pym"
+fi
 
-PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}
-PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/pym}
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
+
 # Use safe cwd, avoiding unsafe import for bug #469338.
 export __PORTAGE_HELPER_CWD=${PWD}
 cd "${PORTAGE_PYM_PATH}"
diff --git a/usr/lib/portage/bin/ebuild-helpers/doinfo b/usr/lib/portage/bin/ebuild-helpers/doinfo
index a62eaed..acae086 100755
--- a/usr/lib/portage/bin/ebuild-helpers/doinfo
+++ b/usr/lib/portage/bin/ebuild-helpers/doinfo
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 if [[ -z $1 ]] ; then
 	__helpers_die "${0##*/}: at least one argument needed"
diff --git a/usr/lib/portage/bin/ebuild-helpers/doinitd b/usr/lib/portage/bin/ebuild-helpers/doinitd
index 15859e7..03ee5e1 100755
--- a/usr/lib/portage/bin/ebuild-helpers/doinitd
+++ b/usr/lib/portage/bin/ebuild-helpers/doinitd
@@ -3,7 +3,10 @@
 # Distributed under the terms of the GNU General Public License v2
 
 if [[ $# -lt 1 ]] ; then
-	source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+	if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+		PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+	fi
+	source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 	__helpers_die "${0##*/}: at least one argument needed"
 	exit 1
 fi
diff --git a/usr/lib/portage/bin/ebuild-helpers/doins b/usr/lib/portage/bin/ebuild-helpers/doins
index b76b256..875eab7 100755
--- a/usr/lib/portage/bin/ebuild-helpers/doins
+++ b/usr/lib/portage/bin/ebuild-helpers/doins
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 helper=${__PORTAGE_HELPER:-${0##*/}}
 
diff --git a/usr/lib/portage/bin/ebuild-helpers/dolib b/usr/lib/portage/bin/ebuild-helpers/dolib
index cd74cd3..9800cdd 100755
--- a/usr/lib/portage/bin/ebuild-helpers/dolib
+++ b/usr/lib/portage/bin/ebuild-helpers/dolib
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 if ! ___eapi_has_prefix_variables; then
 	ED=${D}
diff --git a/usr/lib/portage/bin/ebuild-helpers/doman b/usr/lib/portage/bin/ebuild-helpers/doman
index 635f2ee..40ad618 100755
--- a/usr/lib/portage/bin/ebuild-helpers/doman
+++ b/usr/lib/portage/bin/ebuild-helpers/doman
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 if [[ $# -lt 1 ]] ; then
 	__helpers_die "${0##*/}: at least one argument needed"
diff --git a/usr/lib/portage/bin/ebuild-helpers/domo b/usr/lib/portage/bin/ebuild-helpers/domo
index 300358c..cf0c7c9 100755
--- a/usr/lib/portage/bin/ebuild-helpers/domo
+++ b/usr/lib/portage/bin/ebuild-helpers/domo
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 mynum=${#}
 if [ ${mynum} -lt 1 ] ; then
diff --git a/usr/lib/portage/bin/ebuild-helpers/dosbin b/usr/lib/portage/bin/ebuild-helpers/dosbin
index 33415a6..1b6b01a 100755
--- a/usr/lib/portage/bin/ebuild-helpers/dosbin
+++ b/usr/lib/portage/bin/ebuild-helpers/dosbin
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 if [[ $# -lt 1 ]] ; then
 	__helpers_die "${0##*/}: at least one argument needed"
diff --git a/usr/lib/portage/bin/ebuild-helpers/dosym b/usr/lib/portage/bin/ebuild-helpers/dosym
index 638f19b..fc2b929 100755
--- a/usr/lib/portage/bin/ebuild-helpers/dosym
+++ b/usr/lib/portage/bin/ebuild-helpers/dosym
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 if [[ $# -ne 2 ]] ; then
 	__helpers_die "${0##*/}: two arguments needed"
diff --git a/usr/lib/portage/bin/ebuild-helpers/ecompress b/usr/lib/portage/bin/ebuild-helpers/ecompress
index b439ab2..3388fa2 100755
--- a/usr/lib/portage/bin/ebuild-helpers/ecompress
+++ b/usr/lib/portage/bin/ebuild-helpers/ecompress
@@ -2,7 +2,11 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 if [[ -z $1 ]] ; then
 	__helpers_die "${0##*/}: at least one argument needed"
diff --git a/usr/lib/portage/bin/ebuild-helpers/ecompressdir b/usr/lib/portage/bin/ebuild-helpers/ecompressdir
index fa68bee..2945d00 100755
--- a/usr/lib/portage/bin/ebuild-helpers/ecompressdir
+++ b/usr/lib/portage/bin/ebuild-helpers/ecompressdir
@@ -2,7 +2,12 @@
 # Copyright 1999-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/helper-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+	PORTAGE_PYM_PATH="${PORTAGE_BIN_PATH%/*}/pym"
+fi
+
+source "${PORTAGE_BIN_PATH}/helper-functions.sh"
 
 if [[ -z $1 ]] ; then
 	__helpers_die "${0##*/}: at least one argument needed"
diff --git a/usr/lib/portage/bin/ebuild-helpers/eerror b/usr/lib/portage/bin/ebuild-helpers/eerror
index a93295e..19a1a34 100755
--- a/usr/lib/portage/bin/ebuild-helpers/eerror
+++ b/usr/lib/portage/bin/ebuild-helpers/eerror
@@ -2,6 +2,10 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 ${0##*/} "$@"
diff --git a/usr/lib/portage/bin/ebuild-helpers/einfo b/usr/lib/portage/bin/ebuild-helpers/einfo
index a93295e..19a1a34 100755
--- a/usr/lib/portage/bin/ebuild-helpers/einfo
+++ b/usr/lib/portage/bin/ebuild-helpers/einfo
@@ -2,6 +2,10 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 ${0##*/} "$@"
diff --git a/usr/lib/portage/bin/ebuild-helpers/elog b/usr/lib/portage/bin/ebuild-helpers/elog
index a93295e..19a1a34 100755
--- a/usr/lib/portage/bin/ebuild-helpers/elog
+++ b/usr/lib/portage/bin/ebuild-helpers/elog
@@ -2,6 +2,10 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 ${0##*/} "$@"
diff --git a/usr/lib/portage/bin/ebuild-helpers/emake b/usr/lib/portage/bin/ebuild-helpers/emake
index b69042e..864957a 100755
--- a/usr/lib/portage/bin/ebuild-helpers/emake
+++ b/usr/lib/portage/bin/ebuild-helpers/emake
@@ -9,7 +9,11 @@
 #        is set in make.globals. We don't source make.globals
 #        here because emake is only called from an ebuild.
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 if [[ $PORTAGE_QUIET != 1 ]] ; then
 	(
diff --git a/usr/lib/portage/bin/ebuild-helpers/eqawarn b/usr/lib/portage/bin/ebuild-helpers/eqawarn
index a93295e..19a1a34 100755
--- a/usr/lib/portage/bin/ebuild-helpers/eqawarn
+++ b/usr/lib/portage/bin/ebuild-helpers/eqawarn
@@ -2,6 +2,10 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 ${0##*/} "$@"
diff --git a/usr/lib/portage/bin/ebuild-helpers/ewarn b/usr/lib/portage/bin/ebuild-helpers/ewarn
index a93295e..19a1a34 100755
--- a/usr/lib/portage/bin/ebuild-helpers/ewarn
+++ b/usr/lib/portage/bin/ebuild-helpers/ewarn
@@ -2,6 +2,10 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 ${0##*/} "$@"
diff --git a/usr/lib/portage/bin/ebuild-helpers/fowners b/usr/lib/portage/bin/ebuild-helpers/fowners
index a1e978a..0d57669 100755
--- a/usr/lib/portage/bin/ebuild-helpers/fowners
+++ b/usr/lib/portage/bin/ebuild-helpers/fowners
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 
 if ! ___eapi_has_prefix_variables; then
diff --git a/usr/lib/portage/bin/ebuild-helpers/fperms b/usr/lib/portage/bin/ebuild-helpers/fperms
index 695f912..bee265e 100755
--- a/usr/lib/portage/bin/ebuild-helpers/fperms
+++ b/usr/lib/portage/bin/ebuild-helpers/fperms
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 if ! ___eapi_has_prefix_variables; then
 	ED=${D}
diff --git a/usr/lib/portage/bin/ebuild-helpers/newbin b/usr/lib/portage/bin/ebuild-helpers/newbin
index 282e7a5..6455937 100755
--- a/usr/lib/portage/bin/ebuild-helpers/newbin
+++ b/usr/lib/portage/bin/ebuild-helpers/newbin
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 helper=${0##*/}
 
diff --git a/usr/lib/portage/bin/ebuild-helpers/newconfd b/usr/lib/portage/bin/ebuild-helpers/newconfd
index 282e7a5..6455937 100755
--- a/usr/lib/portage/bin/ebuild-helpers/newconfd
+++ b/usr/lib/portage/bin/ebuild-helpers/newconfd
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 helper=${0##*/}
 
diff --git a/usr/lib/portage/bin/ebuild-helpers/newdoc b/usr/lib/portage/bin/ebuild-helpers/newdoc
index 282e7a5..6455937 100755
--- a/usr/lib/portage/bin/ebuild-helpers/newdoc
+++ b/usr/lib/portage/bin/ebuild-helpers/newdoc
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 helper=${0##*/}
 
diff --git a/usr/lib/portage/bin/ebuild-helpers/newenvd b/usr/lib/portage/bin/ebuild-helpers/newenvd
index 282e7a5..6455937 100755
--- a/usr/lib/portage/bin/ebuild-helpers/newenvd
+++ b/usr/lib/portage/bin/ebuild-helpers/newenvd
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 helper=${0##*/}
 
diff --git a/usr/lib/portage/bin/ebuild-helpers/newexe b/usr/lib/portage/bin/ebuild-helpers/newexe
index 282e7a5..6455937 100755
--- a/usr/lib/portage/bin/ebuild-helpers/newexe
+++ b/usr/lib/portage/bin/ebuild-helpers/newexe
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 helper=${0##*/}
 
diff --git a/usr/lib/portage/bin/ebuild-helpers/newheader b/usr/lib/portage/bin/ebuild-helpers/newheader
index 282e7a5..6455937 100755
--- a/usr/lib/portage/bin/ebuild-helpers/newheader
+++ b/usr/lib/portage/bin/ebuild-helpers/newheader
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 helper=${0##*/}
 
diff --git a/usr/lib/portage/bin/ebuild-helpers/newinitd b/usr/lib/portage/bin/ebuild-helpers/newinitd
index 282e7a5..6455937 100755
--- a/usr/lib/portage/bin/ebuild-helpers/newinitd
+++ b/usr/lib/portage/bin/ebuild-helpers/newinitd
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 helper=${0##*/}
 
diff --git a/usr/lib/portage/bin/ebuild-helpers/newins b/usr/lib/portage/bin/ebuild-helpers/newins
index 282e7a5..6455937 100755
--- a/usr/lib/portage/bin/ebuild-helpers/newins
+++ b/usr/lib/portage/bin/ebuild-helpers/newins
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 helper=${0##*/}
 
diff --git a/usr/lib/portage/bin/ebuild-helpers/newlib.a b/usr/lib/portage/bin/ebuild-helpers/newlib.a
index 282e7a5..6455937 100755
--- a/usr/lib/portage/bin/ebuild-helpers/newlib.a
+++ b/usr/lib/portage/bin/ebuild-helpers/newlib.a
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 helper=${0##*/}
 
diff --git a/usr/lib/portage/bin/ebuild-helpers/newlib.so b/usr/lib/portage/bin/ebuild-helpers/newlib.so
index 282e7a5..6455937 100755
--- a/usr/lib/portage/bin/ebuild-helpers/newlib.so
+++ b/usr/lib/portage/bin/ebuild-helpers/newlib.so
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 helper=${0##*/}
 
diff --git a/usr/lib/portage/bin/ebuild-helpers/newman b/usr/lib/portage/bin/ebuild-helpers/newman
index 282e7a5..6455937 100755
--- a/usr/lib/portage/bin/ebuild-helpers/newman
+++ b/usr/lib/portage/bin/ebuild-helpers/newman
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 helper=${0##*/}
 
diff --git a/usr/lib/portage/bin/ebuild-helpers/newsbin b/usr/lib/portage/bin/ebuild-helpers/newsbin
index 282e7a5..6455937 100755
--- a/usr/lib/portage/bin/ebuild-helpers/newsbin
+++ b/usr/lib/portage/bin/ebuild-helpers/newsbin
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 helper=${0##*/}
 
diff --git a/usr/lib/portage/bin/ebuild-helpers/portageq b/usr/lib/portage/bin/ebuild-helpers/portageq
index c678dd0..d76cfaf 100755
--- a/usr/lib/portage/bin/ebuild-helpers/portageq
+++ b/usr/lib/portage/bin/ebuild-helpers/portageq
@@ -5,8 +5,10 @@
 scriptpath=${BASH_SOURCE[0]}
 scriptname=${scriptpath##*/}
 
-PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}
-PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/pym}
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+	PORTAGE_PYM_PATH="${PORTAGE_BIN_PATH%/*}/pym"
+fi
 # Use safe cwd, avoiding unsafe import for bug #469338.
 cd "${PORTAGE_PYM_PATH}"
 
diff --git a/usr/lib/portage/bin/ebuild-helpers/prepall b/usr/lib/portage/bin/ebuild-helpers/prepall
index d3f32e5..f59a8e9 100755
--- a/usr/lib/portage/bin/ebuild-helpers/prepall
+++ b/usr/lib/portage/bin/ebuild-helpers/prepall
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 [[ -d ${ED} ]] || exit 0
 
diff --git a/usr/lib/portage/bin/ebuild-helpers/prepalldocs b/usr/lib/portage/bin/ebuild-helpers/prepalldocs
index a49ff11..9fec235 100755
--- a/usr/lib/portage/bin/ebuild-helpers/prepalldocs
+++ b/usr/lib/portage/bin/ebuild-helpers/prepalldocs
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 if ___eapi_has_docompress; then
 	die "'${0##*/}' has been banned for EAPI '$EAPI'"
diff --git a/usr/lib/portage/bin/ebuild-helpers/prepallinfo b/usr/lib/portage/bin/ebuild-helpers/prepallinfo
index 8578a9f..501fcba 100755
--- a/usr/lib/portage/bin/ebuild-helpers/prepallinfo
+++ b/usr/lib/portage/bin/ebuild-helpers/prepallinfo
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 if ! ___eapi_has_prefix_variables; then
 	ED=${D}
diff --git a/usr/lib/portage/bin/ebuild-helpers/prepallman b/usr/lib/portage/bin/ebuild-helpers/prepallman
index 8cff5ee..f4efc52 100755
--- a/usr/lib/portage/bin/ebuild-helpers/prepallman
+++ b/usr/lib/portage/bin/ebuild-helpers/prepallman
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 # replaced by controllable compression in EAPI 4
 ___eapi_has_docompress && exit 0
diff --git a/usr/lib/portage/bin/ebuild-helpers/prepallstrip b/usr/lib/portage/bin/ebuild-helpers/prepallstrip
index 4d5453c..a884535 100755
--- a/usr/lib/portage/bin/ebuild-helpers/prepallstrip
+++ b/usr/lib/portage/bin/ebuild-helpers/prepallstrip
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 if ! ___eapi_has_prefix_variables; then
 	ED=${D}
diff --git a/usr/lib/portage/bin/ebuild-helpers/prepinfo b/usr/lib/portage/bin/ebuild-helpers/prepinfo
index 74a56bf..ab386b6 100755
--- a/usr/lib/portage/bin/ebuild-helpers/prepinfo
+++ b/usr/lib/portage/bin/ebuild-helpers/prepinfo
@@ -2,7 +2,11 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 if ! ___eapi_has_prefix_variables; then
 	ED=${D}
diff --git a/usr/lib/portage/bin/ebuild-helpers/prepman b/usr/lib/portage/bin/ebuild-helpers/prepman
index e5e482e..9912115 100755
--- a/usr/lib/portage/bin/ebuild-helpers/prepman
+++ b/usr/lib/portage/bin/ebuild-helpers/prepman
@@ -5,7 +5,11 @@
 # Do not compress man pages which are smaller than this (in bytes). #169260
 SIZE_LIMIT='128'
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 if ! ___eapi_has_prefix_variables; then
 	ED=${D}
diff --git a/usr/lib/portage/bin/ebuild-helpers/prepstrip b/usr/lib/portage/bin/ebuild-helpers/prepstrip
index f7311c5..f50fb21 100755
--- a/usr/lib/portage/bin/ebuild-helpers/prepstrip
+++ b/usr/lib/portage/bin/ebuild-helpers/prepstrip
@@ -2,7 +2,11 @@
 # Copyright 1999-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/helper-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
+source "${PORTAGE_BIN_PATH}/helper-functions.sh"
 
 # avoid multiple calls to `has`.  this creates things like:
 #   FEATURES_foo=false
diff --git a/usr/lib/portage/bin/ebuild-helpers/unprivileged/chgrp b/usr/lib/portage/bin/ebuild-helpers/unprivileged/chgrp
index 2af9b8c..a3a88a7 100755
--- a/usr/lib/portage/bin/ebuild-helpers/unprivileged/chgrp
+++ b/usr/lib/portage/bin/ebuild-helpers/unprivileged/chgrp
@@ -21,7 +21,10 @@
 			output="${output}\n ... (further messages truncated)"
 		fi
 
-		source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+		if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+			PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+		fi
+		source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 		if ! ___eapi_has_prefix_variables; then
 			EPREFIX=
diff --git a/usr/lib/portage/bin/ebuild-helpers/unprivileged/chown b/usr/lib/portage/bin/ebuild-helpers/unprivileged/chown
index 2af9b8c..a3a88a7 100755
--- a/usr/lib/portage/bin/ebuild-helpers/unprivileged/chown
+++ b/usr/lib/portage/bin/ebuild-helpers/unprivileged/chown
@@ -21,7 +21,10 @@
 			output="${output}\n ... (further messages truncated)"
 		fi
 
-		source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"/isolated-functions.sh
+		if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+			PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+		fi
+		source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
 
 		if ! ___eapi_has_prefix_variables; then
 			EPREFIX=
diff --git a/usr/lib/portage/bin/ebuild.sh b/usr/lib/portage/bin/ebuild.sh
index 7623049..f027154 100755
--- a/usr/lib/portage/bin/ebuild.sh
+++ b/usr/lib/portage/bin/ebuild.sh
@@ -2,8 +2,10 @@
 # Copyright 1999-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-PORTAGE_BIN_PATH="${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}"
-PORTAGE_PYM_PATH="${PORTAGE_PYM_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/pym}"
+if [[ -z ${PORTAGE_BIN_PATH} ]]; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+	PORTAGE_PYM_PATH="${PORTAGE_BIN_PATH%/*}/pym"
+fi
 
 # Prevent aliases from causing portage to act inappropriately.
 # Make sure it's before everything so we don't mess aliases that follow.
diff --git a/usr/lib/portage/bin/isolated-functions.sh b/usr/lib/portage/bin/isolated-functions.sh
index 1b10b6d..857da26 100755
--- a/usr/lib/portage/bin/isolated-functions.sh
+++ b/usr/lib/portage/bin/isolated-functions.sh
@@ -2,7 +2,7 @@
 # Copyright 1999-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}/eapi.sh"
+source "${PORTAGE_BIN_PATH}/eapi.sh"
 
 # We need this next line for "die" and "assert". It expands
 # It _must_ preceed all the calls to die and assert.
diff --git a/usr/lib/portage/bin/misc-functions.sh b/usr/lib/portage/bin/misc-functions.sh
index b285865..2f53809 100755
--- a/usr/lib/portage/bin/misc-functions.sh
+++ b/usr/lib/portage/bin/misc-functions.sh
@@ -14,7 +14,7 @@
 MISC_FUNCTIONS_ARGS="$@"
 shift $#
 
-source "${PORTAGE_BIN_PATH:-/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage/bin}/ebuild.sh"
+source "${PORTAGE_BIN_PATH}/ebuild.sh"
 
 install_symlink_html_docs() {
 	if ! ___eapi_has_prefix_variables; then
diff --git a/usr/lib/portage/pym/portage/const_autotool.py b/usr/lib/portage/pym/portage/const_autotool.py
index c113247..6189d0c 100644
--- a/usr/lib/portage/pym/portage/const_autotool.py
+++ b/usr/lib/portage/pym/portage/const_autotool.py
@@ -7,11 +7,11 @@
 		"portageuser", "portagegroup", "rootuser", "rootuid", "rootgid",
 		"PORTAGE_BASH", "PORTAGE_MV"]
 
-from os import path
+import os
 
-EPREFIX      = "/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir"
-SYSCONFDIR   = "/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/etc"
-PORTAGE_BASE = "/usr/local/google/home/vapier/src/android/mdk/build/portage/tmp/prefix-portage-2.2.14/destdir/usr/lib/portage"
+EPREFIX      = os.path.realpath(os.path.abspath(__file__) + '../' * 7)
+SYSCONFDIR   = os.path.join(EPREFIX, 'etc')
+PORTAGE_BASE = os.path.join(EPREFIX, 'usr/lib/portage')
 
 portagegroup = "eng"
 portageuser  = "vapier"