public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH] make PORTAGE_BIN_PATH settings relocatable
@ 2015-06-01  6:34 Mike Frysinger
  2015-06-01 17:25 ` Mike Frysinger
  2015-06-10 15:45 ` [gentoo-portage-dev] [PATCH] require PORTAGE_{BIN,PYM}_PATH not be cleared Mike Frysinger
  0 siblings, 2 replies; 11+ messages in thread
From: Mike Frysinger @ 2015-06-01  6:34 UTC (permalink / raw
  To: gentoo-portage-dev

Rather than hardcode /usr/lib/portage/bin everywhere, use the currently
active script name to locate the right path.

This helps out the Prefix project as they currently rewrite these on the
fly, but even the latest portage no longer installs into that path.
---
 bin/ebuild-helpers/die                | 5 ++++-
 bin/ebuild-helpers/dobin              | 5 ++++-
 bin/ebuild-helpers/doconfd            | 6 +++++-
 bin/ebuild-helpers/dodir              | 5 ++++-
 bin/ebuild-helpers/dodoc              | 5 ++++-
 bin/ebuild-helpers/doenvd             | 6 +++++-
 bin/ebuild-helpers/doexe              | 5 ++++-
 bin/ebuild-helpers/dohard             | 5 ++++-
 bin/ebuild-helpers/doheader           | 5 ++++-
 bin/ebuild-helpers/dohtml             | 6 ++++--
 bin/ebuild-helpers/doinfo             | 5 ++++-
 bin/ebuild-helpers/doinitd            | 6 +++++-
 bin/ebuild-helpers/doins              | 5 ++++-
 bin/ebuild-helpers/dolib              | 5 ++++-
 bin/ebuild-helpers/doman              | 5 ++++-
 bin/ebuild-helpers/domo               | 5 ++++-
 bin/ebuild-helpers/dosbin             | 5 ++++-
 bin/ebuild-helpers/dosed              | 5 ++++-
 bin/ebuild-helpers/dosym              | 5 ++++-
 bin/ebuild-helpers/ecompress          | 5 ++++-
 bin/ebuild-helpers/ecompressdir       | 5 ++++-
 bin/ebuild-helpers/elog               | 5 ++++-
 bin/ebuild-helpers/emake              | 5 ++++-
 bin/ebuild-helpers/fowners            | 5 ++++-
 bin/ebuild-helpers/fperms             | 5 ++++-
 bin/ebuild-helpers/keepdir            | 5 ++++-
 bin/ebuild-helpers/newins             | 5 ++++-
 bin/ebuild-helpers/portageq           | 5 ++++-
 bin/ebuild-helpers/prepall            | 5 ++++-
 bin/ebuild-helpers/prepalldocs        | 5 ++++-
 bin/ebuild-helpers/prepallinfo        | 5 ++++-
 bin/ebuild-helpers/prepallman         | 5 ++++-
 bin/ebuild-helpers/prepallstrip       | 5 ++++-
 bin/ebuild-helpers/prepinfo           | 5 ++++-
 bin/ebuild-helpers/prepman            | 5 ++++-
 bin/ebuild-helpers/prepstrip          | 6 +++++-
 bin/ebuild-helpers/unprivileged/chown | 7 +++++--
 bin/ebuild-helpers/xattr/install      | 5 ++++-
 bin/ebuild-ipc                        | 4 +++-
 bin/ebuild.sh                         | 4 +++-
 bin/helper-functions.sh               | 5 ++++-
 bin/isolated-functions.sh             | 5 ++++-
 bin/misc-functions.sh                 | 5 ++++-
 43 files changed, 175 insertions(+), 45 deletions(-)

diff --git a/bin/ebuild-helpers/die b/bin/ebuild-helpers/die
index 9869141..09d1c74 100755
--- a/bin/ebuild-helpers/die
+++ b/bin/ebuild-helpers/die
@@ -2,6 +2,9 @@
 # Copyright 2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/dobin b/bin/ebuild-helpers/dobin
index 0ba1eb0..cf5a9bc 100755
--- a/bin/ebuild-helpers/dobin
+++ b/bin/ebuild-helpers/dobin
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/doconfd b/bin/ebuild-helpers/doconfd
index 1baa3ed..3d5a0f6 100755
--- a/bin/ebuild-helpers/doconfd
+++ b/bin/ebuild-helpers/doconfd
@@ -2,8 +2,12 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
+if [[ -z ${PORTAGE_BIN_PATH} ]] ; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
 if [[ $# -lt 1 ]] ; then
-	source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+	source "${PORTAGE_BIN_PATH}"/isolated-functions.sh
 	__helpers_die "${0##*/}: at least one argument needed"
 	exit 1
 fi
diff --git a/bin/ebuild-helpers/dodir b/bin/ebuild-helpers/dodir
index e03ba9a..34ba300 100755
--- a/bin/ebuild-helpers/dodir
+++ b/bin/ebuild-helpers/dodir
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/dodoc b/bin/ebuild-helpers/dodoc
index 6ccf0a4..2d18e26 100755
--- a/bin/ebuild-helpers/dodoc
+++ b/bin/ebuild-helpers/dodoc
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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
 	__PORTAGE_HELPER='dodoc' exec doins "$@"
diff --git a/bin/ebuild-helpers/doenvd b/bin/ebuild-helpers/doenvd
index 67bb934..77e926f 100755
--- a/bin/ebuild-helpers/doenvd
+++ b/bin/ebuild-helpers/doenvd
@@ -2,8 +2,12 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
+if [[ -z ${PORTAGE_BIN_PATH} ]] ; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
 if [[ $# -lt 1 ]] ; then
-	source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+	source "${PORTAGE_BIN_PATH}"/isolated-functions.sh
 	__helpers_die "${0##*/}: at least one argument needed"
 	exit 1
 fi
diff --git a/bin/ebuild-helpers/doexe b/bin/ebuild-helpers/doexe
index c34fcae..4c00c2a 100755
--- a/bin/ebuild-helpers/doexe
+++ b/bin/ebuild-helpers/doexe
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/dohard b/bin/ebuild-helpers/dohard
index e0a44fa..669afd8 100755
--- a/bin/ebuild-helpers/dohard
+++ b/bin/ebuild-helpers/dohard
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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_dohard; then
 	die "'${0##*/}' has been banned for EAPI '$EAPI'"
diff --git a/bin/ebuild-helpers/doheader b/bin/ebuild-helpers/doheader
index e4cae6a..3d093f2 100755
--- a/bin/ebuild-helpers/doheader
+++ b/bin/ebuild-helpers/doheader
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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_doheader; then
 	die "${0##*/} is not supported in EAPI ${EAPI}"
diff --git a/bin/ebuild-helpers/dohtml b/bin/ebuild-helpers/dohtml
index 0478e49..9c08b11 100755
--- a/bin/ebuild-helpers/dohtml
+++ b/bin/ebuild-helpers/dohtml
@@ -2,13 +2,15 @@
 # Copyright 2009-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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_dohtml_deprecated; then
 	eqawarn "'${0##*/}' is deprecated in EAPI '$EAPI'"
 fi
 
-PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}
 PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym}
 # Use safe cwd, avoiding unsafe import for bug #469338.
 export __PORTAGE_HELPER_CWD=${PWD}
diff --git a/bin/ebuild-helpers/doinfo b/bin/ebuild-helpers/doinfo
index 2edbdc5..f8a9b6e 100755
--- a/bin/ebuild-helpers/doinfo
+++ b/bin/ebuild-helpers/doinfo
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/doinitd b/bin/ebuild-helpers/doinitd
index aa7b66c..5887652 100755
--- a/bin/ebuild-helpers/doinitd
+++ b/bin/ebuild-helpers/doinitd
@@ -2,8 +2,12 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
+if [[ -z ${PORTAGE_BIN_PATH} ]] ; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
 if [[ $# -lt 1 ]] ; then
-	source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+	source "${PORTAGE_BIN_PATH}"/isolated-functions.sh
 	__helpers_die "${0##*/}: at least one argument needed"
 	exit 1
 fi
diff --git a/bin/ebuild-helpers/doins b/bin/ebuild-helpers/doins
index c60e057..ba1f7c7 100755
--- a/bin/ebuild-helpers/doins
+++ b/bin/ebuild-helpers/doins
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/dolib b/bin/ebuild-helpers/dolib
index fd92d7f..2d08c6f 100755
--- a/bin/ebuild-helpers/dolib
+++ b/bin/ebuild-helpers/dolib
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/doman b/bin/ebuild-helpers/doman
index d680859..6c78a31 100755
--- a/bin/ebuild-helpers/doman
+++ b/bin/ebuild-helpers/doman
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/domo b/bin/ebuild-helpers/domo
index 9a8dda3..7709da3 100755
--- a/bin/ebuild-helpers/domo
+++ b/bin/ebuild-helpers/domo
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/dosbin b/bin/ebuild-helpers/dosbin
index 361ca83..4b4b589 100755
--- a/bin/ebuild-helpers/dosbin
+++ b/bin/ebuild-helpers/dosbin
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/dosed b/bin/ebuild-helpers/dosed
index 7db0629..1793a26 100755
--- a/bin/ebuild-helpers/dosed
+++ b/bin/ebuild-helpers/dosed
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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_dosed; then
 	die "'${0##*/}' has been banned for EAPI '$EAPI'"
diff --git a/bin/ebuild-helpers/dosym b/bin/ebuild-helpers/dosym
index 649b100..967e158 100755
--- a/bin/ebuild-helpers/dosym
+++ b/bin/ebuild-helpers/dosym
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/ecompress b/bin/ebuild-helpers/ecompress
index 71287b4..57e2ead 100755
--- a/bin/ebuild-helpers/ecompress
+++ b/bin/ebuild-helpers/ecompress
@@ -2,7 +2,10 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/ecompressdir b/bin/ebuild-helpers/ecompressdir
index eca5888..f9ae9c3 100755
--- a/bin/ebuild-helpers/ecompressdir
+++ b/bin/ebuild-helpers/ecompressdir
@@ -2,7 +2,10 @@
 # Copyright 1999-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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
 
 if [[ -z $1 ]] ; then
 	__helpers_die "${0##*/}: at least one argument needed"
diff --git a/bin/ebuild-helpers/elog b/bin/ebuild-helpers/elog
index a2303af..2ffd3a9 100755
--- a/bin/ebuild-helpers/elog
+++ b/bin/ebuild-helpers/elog
@@ -2,6 +2,9 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/emake b/bin/ebuild-helpers/emake
index 2a3c2f0..5748312 100755
--- a/bin/ebuild-helpers/emake
+++ b/bin/ebuild-helpers/emake
@@ -9,7 +9,10 @@
 #
 # With newer EAPIs, we also automatically fail the build if make itself fails.
 
-source "${PORTAGE_BIN_PATH:-/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
 
 cmd=(
 	${MAKE:-make} ${MAKEOPTS} "$@" ${EXTRA_EMAKE}
diff --git a/bin/ebuild-helpers/fowners b/bin/ebuild-helpers/fowners
index cee4108..28ee049 100755
--- a/bin/ebuild-helpers/fowners
+++ b/bin/ebuild-helpers/fowners
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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= ED=${D}
diff --git a/bin/ebuild-helpers/fperms b/bin/ebuild-helpers/fperms
index d854ebb..644a811 100755
--- a/bin/ebuild-helpers/fperms
+++ b/bin/ebuild-helpers/fperms
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/keepdir b/bin/ebuild-helpers/keepdir
index bec2feb..b6af2e9 100755
--- a/bin/ebuild-helpers/keepdir
+++ b/bin/ebuild-helpers/keepdir
@@ -2,7 +2,10 @@
 # Copyright 1999-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/newins b/bin/ebuild-helpers/newins
index 0335985..062a40f 100755
--- a/bin/ebuild-helpers/newins
+++ b/bin/ebuild-helpers/newins
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/portageq b/bin/ebuild-helpers/portageq
index ba889eb..a824df6 100755
--- a/bin/ebuild-helpers/portageq
+++ b/bin/ebuild-helpers/portageq
@@ -5,7 +5,10 @@
 scriptpath=${BASH_SOURCE[0]}
 scriptname=${scriptpath##*/}
 
-PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}
+if [[ -z ${PORTAGE_BIN_PATH} ]] ; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
 PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym}
 # Use safe cwd, avoiding unsafe import for bug #469338.
 cd "${PORTAGE_PYM_PATH}"
diff --git a/bin/ebuild-helpers/prepall b/bin/ebuild-helpers/prepall
index fb5c2db..99ec50a 100755
--- a/bin/ebuild-helpers/prepall
+++ b/bin/ebuild-helpers/prepall
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/prepalldocs b/bin/ebuild-helpers/prepalldocs
index 3094661..ed09c6e 100755
--- a/bin/ebuild-helpers/prepalldocs
+++ b/bin/ebuild-helpers/prepalldocs
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/prepallinfo b/bin/ebuild-helpers/prepallinfo
index 1a20275..7ce9ce5 100755
--- a/bin/ebuild-helpers/prepallinfo
+++ b/bin/ebuild-helpers/prepallinfo
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/prepallman b/bin/ebuild-helpers/prepallman
index 5331eaf..5547115 100755
--- a/bin/ebuild-helpers/prepallman
+++ b/bin/ebuild-helpers/prepallman
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/prepallstrip b/bin/ebuild-helpers/prepallstrip
index 1aa6686..34e6174 100755
--- a/bin/ebuild-helpers/prepallstrip
+++ b/bin/ebuild-helpers/prepallstrip
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/prepinfo b/bin/ebuild-helpers/prepinfo
index 5afc18a..9312f64 100755
--- a/bin/ebuild-helpers/prepinfo
+++ b/bin/ebuild-helpers/prepinfo
@@ -2,7 +2,10 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/prepman b/bin/ebuild-helpers/prepman
index fb5dcb4..95d7d25 100755
--- a/bin/ebuild-helpers/prepman
+++ b/bin/ebuild-helpers/prepman
@@ -5,7 +5,10 @@
 # Do not compress man pages which are smaller than this (in bytes). #169260
 SIZE_LIMIT='128'
 
-source "${PORTAGE_BIN_PATH:-/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/bin/ebuild-helpers/prepstrip b/bin/ebuild-helpers/prepstrip
index 2ef8a1a..f80838b 100755
--- a/bin/ebuild-helpers/prepstrip
+++ b/bin/ebuild-helpers/prepstrip
@@ -2,8 +2,12 @@
 # Copyright 1999-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
+if [[ -z ${PORTAGE_BIN_PATH} ]] ; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(readlink -f "$0")")")
+fi
+
 PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym}
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/helper-functions.sh
+source "${PORTAGE_BIN_PATH}"/helper-functions.sh
 
 # avoid multiple calls to `has`.  this creates things like:
 #   FEATURES_foo=false
diff --git a/bin/ebuild-helpers/unprivileged/chown b/bin/ebuild-helpers/unprivileged/chown
index 2f1f161..dde0d78 100755
--- a/bin/ebuild-helpers/unprivileged/chown
+++ b/bin/ebuild-helpers/unprivileged/chown
@@ -2,6 +2,11 @@
 # Copyright 2012-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
+if [[ -z ${PORTAGE_BIN_PATH} ]] ; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(dirname "$(readlink -f "$0")")")")
+fi
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh
+
 scriptpath=${BASH_SOURCE[0]}
 scriptname=${scriptpath##*/}
 
@@ -23,8 +28,6 @@ for path in ${PATH}; do
 			output="${output}\n ... (further messages truncated)"
 		fi
 
-		source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
-
 		if ! ___eapi_has_prefix_variables; then
 			EPREFIX=
 		fi
diff --git a/bin/ebuild-helpers/xattr/install b/bin/ebuild-helpers/xattr/install
index 2d2a693..c48f7c5 100755
--- a/bin/ebuild-helpers/xattr/install
+++ b/bin/ebuild-helpers/xattr/install
@@ -2,7 +2,10 @@
 # Copyright 2013-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}
+if [[ -z ${PORTAGE_BIN_PATH} ]] ; then
+	PORTAGE_BIN_PATH=$(dirname "$(dirname "$(dirname "$(readlink -f "$0")")")")
+fi
+
 PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym}
 INSTALL_XATTR=${EPREFIX}/usr/bin/install-xattr
 # Use safe cwd, avoiding unsafe import for bug #469338.
diff --git a/bin/ebuild-ipc b/bin/ebuild-ipc
index 820005f..7d12e05 100755
--- a/bin/ebuild-ipc
+++ b/bin/ebuild-ipc
@@ -2,7 +2,9 @@
 # Copyright 2010-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}
+if [[ -z ${PORTAGE_BIN_PATH} ]] ; then
+	PORTAGE_BIN_PATH=$(dirname "$(readlink -f "$0")")
+fi
 PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym}
 # Use safe cwd, avoiding unsafe import for bug #469338.
 cd "${PORTAGE_PYM_PATH}"
diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 4e26f87..4b0f0f9 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -2,7 +2,9 @@
 # Copyright 1999-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-PORTAGE_BIN_PATH="${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"
+if [[ -z ${PORTAGE_BIN_PATH} ]] ; then
+	PORTAGE_BIN_PATH=$(dirname "$(readlink -f "$0")")
+fi
 PORTAGE_PYM_PATH="${PORTAGE_PYM_PATH:-/usr/lib/portage/pym}"
 
 # Prevent aliases from causing portage to act inappropriately.
diff --git a/bin/helper-functions.sh b/bin/helper-functions.sh
index b9bc74a..5cd8de1 100644
--- a/bin/helper-functions.sh
+++ b/bin/helper-functions.sh
@@ -5,7 +5,10 @@
 # For routines we want to use in ebuild-helpers/ but don't want to
 # expose to the general ebuild environment.
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -z ${PORTAGE_BIN_PATH} ]] ; then
+	PORTAGE_BIN_PATH=$(dirname "$(readlink -f "$0")")
+fi
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh
 
 #
 # API functions for doing parallel processing
diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 8e789ec..5fe2e3d 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -2,7 +2,10 @@
 # Copyright 1999-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}/eapi.sh"
+if [[ -z ${PORTAGE_BIN_PATH} ]] ; then
+	PORTAGE_BIN_PATH=$(dirname "$(readlink -f "$0")")
+fi
+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/bin/misc-functions.sh b/bin/misc-functions.sh
index 24941af..8013d7d 100755
--- a/bin/misc-functions.sh
+++ b/bin/misc-functions.sh
@@ -14,7 +14,10 @@
 MISC_FUNCTIONS_ARGS="$@"
 shift $#
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}/ebuild.sh"
+if [[ -z ${PORTAGE_BIN_PATH} ]] ; then
+	PORTAGE_BIN_PATH=$(dirname "$(readlink -f "$0")")
+fi
+source "${PORTAGE_BIN_PATH}/ebuild.sh"
 
 install_symlink_html_docs() {
 	if ! ___eapi_has_prefix_variables; then
-- 
2.4.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [gentoo-portage-dev] [PATCH] make PORTAGE_BIN_PATH settings relocatable
  2015-06-01  6:34 [gentoo-portage-dev] [PATCH] make PORTAGE_BIN_PATH settings relocatable Mike Frysinger
@ 2015-06-01 17:25 ` Mike Frysinger
  2015-06-01 18:01   ` Tim Harder
  2015-06-01 18:49   ` Zac Medico
  2015-06-10 15:45 ` [gentoo-portage-dev] [PATCH] require PORTAGE_{BIN,PYM}_PATH not be cleared Mike Frysinger
  1 sibling, 2 replies; 11+ messages in thread
From: Mike Frysinger @ 2015-06-01 17:25 UTC (permalink / raw
  To: gentoo-portage-dev

[-- Attachment #1: Type: text/plain, Size: 2266 bytes --]

On 01 Jun 2015 02:34, Mike Frysinger wrote:
> -source "${PORTAGE_BIN_PATH:-/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

for people who don't want to scan this whole thing, basically every file gets a 
change like this.

two things to note:

(1) i did not retain the ${VAR:-def} form because bash evaluates the default 
value even if it doesn't use it.  so when you do something like:
	VAR=val
	echo "${VAR:-$(rm -rf /some/path)}"
it will first run the `rm` and then expand val for the echo.  the form i used 
thus avoids the runtime overhead of doing dirname/readlink unnecessarily.

(2) i avoided the bash string functions like ${VAR%/*} because it splits up 
into multiple statements and is not as readable imo:
	PORTAGE_BIN_PATH=$(readlink -f "$0")
	PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH%/*}
	PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH%/*}
or even worse:
	PORTAGE_BIN_PATH=$(readlink -f "$0"); PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH%/*}; PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH%/*}
or also bad imo as it's still not that readable:
	p=$(readlink -f "$0"); p=${p%/*}; p=${p%/*}
	PORTAGE_BIN_PATH=${p}
the dirname version might be a bit slower, but i think that's acceptable 
considering this is the fallback case that should rarely be run (as the env 
var should normally be set).

alternative crazy ideas:

(a) just throw an error and exit when PORTAGE_BIN_PATH is not set ... 
considering the current portage code points to a path where it is no longer 
installed, maybe that's ok ?  the recent changes to make portage install copies
for each python version is what broke it i think.

(b) add a tool alongside it that can be `eval`-ed, although you'd still need to 
do something like:
	if [[ -z ${PORTAGE_BIN_PATH} ]] ; then
		eval $("$(dirname "$(readlink -f "$0")")/some-tool")
	fi
and i don't think that's an improvement relative to my patch (deal with quoting 
bs and such).

(c) convert most things to python and use relative module imports to get at the 
bootstrap module.  then that one would hold all the logic.

(d) some other alternative ?
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [gentoo-portage-dev] [PATCH] make PORTAGE_BIN_PATH settings relocatable
  2015-06-01 17:25 ` Mike Frysinger
@ 2015-06-01 18:01   ` Tim Harder
  2015-06-02  4:31     ` Mike Frysinger
  2015-06-01 18:49   ` Zac Medico
  1 sibling, 1 reply; 11+ messages in thread
From: Tim Harder @ 2015-06-01 18:01 UTC (permalink / raw
  To: gentoo-portage-dev

[-- Attachment #1: Type: text/plain, Size: 1276 bytes --]

On 2015-06-01 13:25, Mike Frysinger wrote:
> > -source "${PORTAGE_BIN_PATH:-/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

> alternative crazy ideas:

> (a) just throw an error and exit when PORTAGE_BIN_PATH is not set ...
> considering the current portage code points to a path where it is no longer
> installed, maybe that's ok ?  the recent changes to make portage install copies
> for each python version is what broke it i think.

> (b) add a tool alongside it that can be `eval`-ed, although you'd still need to
> do something like:
> 	if [[ -z ${PORTAGE_BIN_PATH} ]] ; then
> 		eval $("$(dirname "$(readlink -f "$0")")/some-tool")
> 	fi
> and i don't think that's an improvement relative to my patch (deal with quoting
> bs and such).

> (c) convert most things to python and use relative module imports to get at the
> bootstrap module.  then that one would hold all the logic.

> (d) some other alternative ?

If you're sticking with bash, there is also pkgcore's approach of using
a custom shebang script that handles initialization and related generic
things for most of the helpers.

Tim

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [gentoo-portage-dev] [PATCH] make PORTAGE_BIN_PATH settings relocatable
  2015-06-01 17:25 ` Mike Frysinger
  2015-06-01 18:01   ` Tim Harder
@ 2015-06-01 18:49   ` Zac Medico
  2015-06-02 15:34     ` Mike Frysinger
  1 sibling, 1 reply; 11+ messages in thread
From: Zac Medico @ 2015-06-01 18:49 UTC (permalink / raw
  To: gentoo-portage-dev

On 06/01/2015 10:25 AM, Mike Frysinger wrote:
> (a) just throw an error and exit when PORTAGE_BIN_PATH is not set ... 
> considering the current portage code points to a path where it is no longer 
> installed, maybe that's ok ?  the recent changes to make portage install copies
> for each python version is what broke it i think.

I like this idea. I can't think of a reason why we should allow
PORTAGE_BIN_PATH to be unset.
-- 
Thanks,
Zac


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [gentoo-portage-dev] [PATCH] make PORTAGE_BIN_PATH settings relocatable
  2015-06-01 18:01   ` Tim Harder
@ 2015-06-02  4:31     ` Mike Frysinger
  2015-06-02  5:27       ` Tim Harder
  0 siblings, 1 reply; 11+ messages in thread
From: Mike Frysinger @ 2015-06-02  4:31 UTC (permalink / raw
  To: gentoo-portage-dev

[-- Attachment #1: Type: text/plain, Size: 598 bytes --]

On 01 Jun 2015 14:01, Tim Harder wrote:
> On 2015-06-01 13:25, Mike Frysinger wrote:
> > (d) some other alternative ?
> 
> If you're sticking with bash, there is also pkgcore's approach of using
> a custom shebang script that handles initialization and related generic
> things for most of the helpers.

shebangs have to be absolute which defeats the relocatable approach :(

although i could create a single wrapper script which would do the bootstrap and 
then source the final script, and all the other tools would be symlinks to that.  
like we do with newins/newbin/etc...
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [gentoo-portage-dev] [PATCH] make PORTAGE_BIN_PATH settings relocatable
  2015-06-02  4:31     ` Mike Frysinger
@ 2015-06-02  5:27       ` Tim Harder
  0 siblings, 0 replies; 11+ messages in thread
From: Tim Harder @ 2015-06-02  5:27 UTC (permalink / raw
  To: gentoo-portage-dev

On 2015-06-02 00:31, Mike Frysinger wrote:
> > > (d) some other alternative ?
> > If you're sticking with bash, there is also pkgcore's approach of using
> > a custom shebang script that handles initialization and related generic
> > things for most of the helpers.

> shebangs have to be absolute which defeats the relocatable approach :(

> although i could create a single wrapper script which would do the bootstrap and 
> then source the final script, and all the other tools would be symlinks to that.  
> like we do with newins/newbin/etc...

Ah sure, so then you'd need to copy more of the underlying solution as
well. In summary, currently a file (_const.py) gets generated at install
time with all the relevant paths that can change. If that file doesn't
exist (in git repos and unpacked tarballs) relative paths are used
instead (and env overrides are supported as well if needed). The dir
containing the shebang script is added to PATH for each ebuild process
and /usr/bin/env is used to execute it in the shebangs.

In short, it sort of combines a relocatable at install time approach
with the inverse of portage's usage of its .portage_not_installed file.

Tim


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [gentoo-portage-dev] [PATCH] make PORTAGE_BIN_PATH settings relocatable
  2015-06-01 18:49   ` Zac Medico
@ 2015-06-02 15:34     ` Mike Frysinger
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2015-06-02 15:34 UTC (permalink / raw
  To: gentoo-portage-dev

[-- Attachment #1: Type: text/plain, Size: 725 bytes --]

On 01 Jun 2015 11:49, Zac Medico wrote:
> On 06/01/2015 10:25 AM, Mike Frysinger wrote:
> > (a) just throw an error and exit when PORTAGE_BIN_PATH is not set ... 
> > considering the current portage code points to a path where it is no longer 
> > installed, maybe that's ok ?  the recent changes to make portage install copies
> > for each python version is what broke it i think.
> 
> I like this idea. I can't think of a reason why we should allow
> PORTAGE_BIN_PATH to be unset.

i'll try this in the CrOS project where we're using Gentoo/Prefix and see how it 
goes.  and then try it on my system for a while to further check it.  otherwise
i'll go with Tim's inspired idea about symlinked wrappers.
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [gentoo-portage-dev] [PATCH] require PORTAGE_{BIN,PYM}_PATH not be cleared
  2015-06-01  6:34 [gentoo-portage-dev] [PATCH] make PORTAGE_BIN_PATH settings relocatable Mike Frysinger
  2015-06-01 17:25 ` Mike Frysinger
@ 2015-06-10 15:45 ` Mike Frysinger
  2015-06-10 18:31   ` Zac Medico
  2015-06-11  9:57   ` Mike Frysinger
  1 sibling, 2 replies; 11+ messages in thread
From: Mike Frysinger @ 2015-06-10 15:45 UTC (permalink / raw
  To: gentoo-portage-dev

Rather than hardcode a full path everywhere as a fallback, assume the
value is always set to the right location.  The current path isn't the
right place anymore already.

If it turns out we want to support this scenario, we can do it via a
bunch of bootstrapping (and symlinked) files.
---
 bin/ebuild-helpers/die                | 2 +-
 bin/ebuild-helpers/dobin              | 2 +-
 bin/ebuild-helpers/doconfd            | 2 +-
 bin/ebuild-helpers/dodir              | 2 +-
 bin/ebuild-helpers/dodoc              | 2 +-
 bin/ebuild-helpers/doenvd             | 2 +-
 bin/ebuild-helpers/doexe              | 2 +-
 bin/ebuild-helpers/dohard             | 2 +-
 bin/ebuild-helpers/doheader           | 2 +-
 bin/ebuild-helpers/dohtml             | 6 ++----
 bin/ebuild-helpers/doinfo             | 2 +-
 bin/ebuild-helpers/doinitd            | 2 +-
 bin/ebuild-helpers/doins              | 2 +-
 bin/ebuild-helpers/dolib              | 2 +-
 bin/ebuild-helpers/doman              | 2 +-
 bin/ebuild-helpers/domo               | 2 +-
 bin/ebuild-helpers/dosbin             | 2 +-
 bin/ebuild-helpers/dosed              | 2 +-
 bin/ebuild-helpers/dosym              | 2 +-
 bin/ebuild-helpers/ecompress          | 2 +-
 bin/ebuild-helpers/ecompressdir       | 2 +-
 bin/ebuild-helpers/elog               | 2 +-
 bin/ebuild-helpers/emake              | 2 +-
 bin/ebuild-helpers/fowners            | 2 +-
 bin/ebuild-helpers/fperms             | 2 +-
 bin/ebuild-helpers/keepdir            | 2 +-
 bin/ebuild-helpers/newins             | 2 +-
 bin/ebuild-helpers/portageq           | 4 +---
 bin/ebuild-helpers/prepall            | 2 +-
 bin/ebuild-helpers/prepalldocs        | 2 +-
 bin/ebuild-helpers/prepallinfo        | 2 +-
 bin/ebuild-helpers/prepallman         | 2 +-
 bin/ebuild-helpers/prepallstrip       | 2 +-
 bin/ebuild-helpers/prepinfo           | 2 +-
 bin/ebuild-helpers/prepman            | 2 +-
 bin/ebuild-helpers/prepstrip          | 3 +--
 bin/ebuild-helpers/unprivileged/chown | 4 ++--
 bin/ebuild-helpers/xattr/install      | 2 --
 bin/ebuild-ipc                        | 4 +---
 bin/ebuild.sh                         | 3 ---
 bin/helper-functions.sh               | 2 +-
 bin/isolated-functions.sh             | 2 +-
 bin/misc-functions.sh                 | 2 +-
 43 files changed, 43 insertions(+), 55 deletions(-)

diff --git a/bin/ebuild-helpers/die b/bin/ebuild-helpers/die
index 9869141..5c6b1d2 100755
--- a/bin/ebuild-helpers/die
+++ b/bin/ebuild-helpers/die
@@ -2,6 +2,6 @@
 # Copyright 2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 die "$@"
 exit 1
diff --git a/bin/ebuild-helpers/dobin b/bin/ebuild-helpers/dobin
index 0ba1eb0..9f4d73d 100755
--- a/bin/ebuild-helpers/dobin
+++ b/bin/ebuild-helpers/dobin
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if [[ $# -lt 1 ]] ; then
 	__helpers_die "${0##*/}: at least one argument needed"
diff --git a/bin/ebuild-helpers/doconfd b/bin/ebuild-helpers/doconfd
index 1baa3ed..926c318 100755
--- a/bin/ebuild-helpers/doconfd
+++ b/bin/ebuild-helpers/doconfd
@@ -3,7 +3,7 @@
 # Distributed under the terms of the GNU General Public License v2
 
 if [[ $# -lt 1 ]] ; then
-	source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+	source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 	__helpers_die "${0##*/}: at least one argument needed"
 	exit 1
 fi
diff --git a/bin/ebuild-helpers/dodir b/bin/ebuild-helpers/dodir
index e03ba9a..eed2c8b 100755
--- a/bin/ebuild-helpers/dodir
+++ b/bin/ebuild-helpers/dodir
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ! ___eapi_has_prefix_variables; then
 	ED=${D}
diff --git a/bin/ebuild-helpers/dodoc b/bin/ebuild-helpers/dodoc
index 6ccf0a4..75029eb 100755
--- a/bin/ebuild-helpers/dodoc
+++ b/bin/ebuild-helpers/dodoc
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ___eapi_dodoc_supports_-r; then
 	__PORTAGE_HELPER='dodoc' exec doins "$@"
diff --git a/bin/ebuild-helpers/doenvd b/bin/ebuild-helpers/doenvd
index 67bb934..eb31f37 100755
--- a/bin/ebuild-helpers/doenvd
+++ b/bin/ebuild-helpers/doenvd
@@ -3,7 +3,7 @@
 # Distributed under the terms of the GNU General Public License v2
 
 if [[ $# -lt 1 ]] ; then
-	source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+	source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 	__helpers_die "${0##*/}: at least one argument needed"
 	exit 1
 fi
diff --git a/bin/ebuild-helpers/doexe b/bin/ebuild-helpers/doexe
index c34fcae..8c4b9e9 100755
--- a/bin/ebuild-helpers/doexe
+++ b/bin/ebuild-helpers/doexe
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if [[ $# -lt 1 ]] ; then
 	__helpers_die "${0##*/}: at least one argument needed"
diff --git a/bin/ebuild-helpers/dohard b/bin/ebuild-helpers/dohard
index e0a44fa..8a93fad 100755
--- a/bin/ebuild-helpers/dohard
+++ b/bin/ebuild-helpers/dohard
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ! ___eapi_has_dohard; then
 	die "'${0##*/}' has been banned for EAPI '$EAPI'"
diff --git a/bin/ebuild-helpers/doheader b/bin/ebuild-helpers/doheader
index e4cae6a..b827086 100755
--- a/bin/ebuild-helpers/doheader
+++ b/bin/ebuild-helpers/doheader
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ! ___eapi_has_doheader; then
 	die "${0##*/} is not supported in EAPI ${EAPI}"
diff --git a/bin/ebuild-helpers/dohtml b/bin/ebuild-helpers/dohtml
index 0478e49..860d4ab 100755
--- a/bin/ebuild-helpers/dohtml
+++ b/bin/ebuild-helpers/dohtml
@@ -2,17 +2,15 @@
 # Copyright 2009-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ___eapi_has_dohtml_deprecated; then
 	eqawarn "'${0##*/}' is deprecated in EAPI '$EAPI'"
 fi
 
-PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}
-PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym}
 # Use safe cwd, avoiding unsafe import for bug #469338.
 export __PORTAGE_HELPER_CWD=${PWD}
-cd "${PORTAGE_PYM_PATH}"
+cd "${PORTAGE_PYM_PATH}" || die
 PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
 	"${PORTAGE_PYTHON:-/usr/bin/python}" "$PORTAGE_BIN_PATH/dohtml.py" "$@"
 
diff --git a/bin/ebuild-helpers/doinfo b/bin/ebuild-helpers/doinfo
index 2edbdc5..24b5ddd 100755
--- a/bin/ebuild-helpers/doinfo
+++ b/bin/ebuild-helpers/doinfo
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if [[ -z $1 ]] ; then
 	__helpers_die "${0##*/}: at least one argument needed"
diff --git a/bin/ebuild-helpers/doinitd b/bin/ebuild-helpers/doinitd
index aa7b66c..a216d98 100755
--- a/bin/ebuild-helpers/doinitd
+++ b/bin/ebuild-helpers/doinitd
@@ -3,7 +3,7 @@
 # Distributed under the terms of the GNU General Public License v2
 
 if [[ $# -lt 1 ]] ; then
-	source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+	source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 	__helpers_die "${0##*/}: at least one argument needed"
 	exit 1
 fi
diff --git a/bin/ebuild-helpers/doins b/bin/ebuild-helpers/doins
index c60e057..93052c2 100755
--- a/bin/ebuild-helpers/doins
+++ b/bin/ebuild-helpers/doins
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 helper=${__PORTAGE_HELPER:-${0##*/}}
 
diff --git a/bin/ebuild-helpers/dolib b/bin/ebuild-helpers/dolib
index fd92d7f..a11bad4 100755
--- a/bin/ebuild-helpers/dolib
+++ b/bin/ebuild-helpers/dolib
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ! ___eapi_has_prefix_variables; then
 	ED=${D}
diff --git a/bin/ebuild-helpers/doman b/bin/ebuild-helpers/doman
index d680859..da66ac3 100755
--- a/bin/ebuild-helpers/doman
+++ b/bin/ebuild-helpers/doman
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if [[ $# -lt 1 ]] ; then
 	__helpers_die "${0##*/}: at least one argument needed"
diff --git a/bin/ebuild-helpers/domo b/bin/ebuild-helpers/domo
index 9a8dda3..9742173 100755
--- a/bin/ebuild-helpers/domo
+++ b/bin/ebuild-helpers/domo
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 mynum=${#}
 if [ ${mynum} -lt 1 ] ; then
diff --git a/bin/ebuild-helpers/dosbin b/bin/ebuild-helpers/dosbin
index 361ca83..2fee9d4 100755
--- a/bin/ebuild-helpers/dosbin
+++ b/bin/ebuild-helpers/dosbin
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if [[ $# -lt 1 ]] ; then
 	__helpers_die "${0##*/}: at least one argument needed"
diff --git a/bin/ebuild-helpers/dosed b/bin/ebuild-helpers/dosed
index 7db0629..1e10d12 100755
--- a/bin/ebuild-helpers/dosed
+++ b/bin/ebuild-helpers/dosed
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ! ___eapi_has_dosed; then
 	die "'${0##*/}' has been banned for EAPI '$EAPI'"
diff --git a/bin/ebuild-helpers/dosym b/bin/ebuild-helpers/dosym
index 649b100..0bc8cc7 100755
--- a/bin/ebuild-helpers/dosym
+++ b/bin/ebuild-helpers/dosym
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if [[ $# -ne 2 ]] ; then
 	__helpers_die "${0##*/}: two arguments needed"
diff --git a/bin/ebuild-helpers/ecompress b/bin/ebuild-helpers/ecompress
index 71287b4..50ee811 100755
--- a/bin/ebuild-helpers/ecompress
+++ b/bin/ebuild-helpers/ecompress
@@ -2,7 +2,7 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if [[ -z $1 ]] ; then
 	__helpers_die "${0##*/}: at least one argument needed"
diff --git a/bin/ebuild-helpers/ecompressdir b/bin/ebuild-helpers/ecompressdir
index eca5888..4f57262 100755
--- a/bin/ebuild-helpers/ecompressdir
+++ b/bin/ebuild-helpers/ecompressdir
@@ -2,7 +2,7 @@
 # Copyright 1999-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/helper-functions.sh
+source "${PORTAGE_BIN_PATH}"/helper-functions.sh || exit 1
 
 if [[ -z $1 ]] ; then
 	__helpers_die "${0##*/}: at least one argument needed"
diff --git a/bin/ebuild-helpers/elog b/bin/ebuild-helpers/elog
index a2303af..911f8d5 100755
--- a/bin/ebuild-helpers/elog
+++ b/bin/ebuild-helpers/elog
@@ -2,6 +2,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 ${0##*/} "$@"
diff --git a/bin/ebuild-helpers/emake b/bin/ebuild-helpers/emake
index 2a3c2f0..60718a2 100755
--- a/bin/ebuild-helpers/emake
+++ b/bin/ebuild-helpers/emake
@@ -9,7 +9,7 @@
 #
 # With newer EAPIs, we also automatically fail the build if make itself fails.
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 cmd=(
 	${MAKE:-make} ${MAKEOPTS} "$@" ${EXTRA_EMAKE}
diff --git a/bin/ebuild-helpers/fowners b/bin/ebuild-helpers/fowners
index cee4108..85f7fd6 100755
--- a/bin/ebuild-helpers/fowners
+++ b/bin/ebuild-helpers/fowners
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ! ___eapi_has_prefix_variables; then
 	EPREFIX= ED=${D}
diff --git a/bin/ebuild-helpers/fperms b/bin/ebuild-helpers/fperms
index d854ebb..297679c 100755
--- a/bin/ebuild-helpers/fperms
+++ b/bin/ebuild-helpers/fperms
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ! ___eapi_has_prefix_variables; then
 	ED=${D}
diff --git a/bin/ebuild-helpers/keepdir b/bin/ebuild-helpers/keepdir
index bec2feb..e0c852d 100755
--- a/bin/ebuild-helpers/keepdir
+++ b/bin/ebuild-helpers/keepdir
@@ -2,7 +2,7 @@
 # Copyright 1999-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ! ___eapi_has_prefix_variables; then
 	ED=${D}
diff --git a/bin/ebuild-helpers/newins b/bin/ebuild-helpers/newins
index 0335985..8032a8f 100755
--- a/bin/ebuild-helpers/newins
+++ b/bin/ebuild-helpers/newins
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 helper=${0##*/}
 
diff --git a/bin/ebuild-helpers/portageq b/bin/ebuild-helpers/portageq
index ba889eb..b314bce 100755
--- a/bin/ebuild-helpers/portageq
+++ b/bin/ebuild-helpers/portageq
@@ -5,10 +5,8 @@
 scriptpath=${BASH_SOURCE[0]}
 scriptname=${scriptpath##*/}
 
-PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}
-PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym}
 # Use safe cwd, avoiding unsafe import for bug #469338.
-cd "${PORTAGE_PYM_PATH}"
+cd "${PORTAGE_PYM_PATH}" || exit 1
 
 IFS=':'
 set -f # in case ${PATH} contains any shell glob characters
diff --git a/bin/ebuild-helpers/prepall b/bin/ebuild-helpers/prepall
index fb5c2db..44643bb 100755
--- a/bin/ebuild-helpers/prepall
+++ b/bin/ebuild-helpers/prepall
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ! ___eapi_has_prefix_variables; then
 	ED=${D}
diff --git a/bin/ebuild-helpers/prepalldocs b/bin/ebuild-helpers/prepalldocs
index 3094661..cf63c64 100755
--- a/bin/ebuild-helpers/prepalldocs
+++ b/bin/ebuild-helpers/prepalldocs
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ___eapi_has_docompress; then
 	die "'${0##*/}' has been banned for EAPI '$EAPI'"
diff --git a/bin/ebuild-helpers/prepallinfo b/bin/ebuild-helpers/prepallinfo
index 1a20275..cdf149e 100755
--- a/bin/ebuild-helpers/prepallinfo
+++ b/bin/ebuild-helpers/prepallinfo
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ! ___eapi_has_prefix_variables; then
 	ED=${D}
diff --git a/bin/ebuild-helpers/prepallman b/bin/ebuild-helpers/prepallman
index 5331eaf..03b10a8 100755
--- a/bin/ebuild-helpers/prepallman
+++ b/bin/ebuild-helpers/prepallman
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 # replaced by controllable compression in EAPI 4
 ___eapi_has_docompress && exit 0
diff --git a/bin/ebuild-helpers/prepallstrip b/bin/ebuild-helpers/prepallstrip
index 1aa6686..59fa7cc 100755
--- a/bin/ebuild-helpers/prepallstrip
+++ b/bin/ebuild-helpers/prepallstrip
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ! ___eapi_has_prefix_variables; then
 	ED=${D}
diff --git a/bin/ebuild-helpers/prepinfo b/bin/ebuild-helpers/prepinfo
index 5afc18a..a64d144 100755
--- a/bin/ebuild-helpers/prepinfo
+++ b/bin/ebuild-helpers/prepinfo
@@ -2,7 +2,7 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ! ___eapi_has_prefix_variables; then
 	ED=${D}
diff --git a/bin/ebuild-helpers/prepman b/bin/ebuild-helpers/prepman
index fb5dcb4..e64acc0 100755
--- a/bin/ebuild-helpers/prepman
+++ b/bin/ebuild-helpers/prepman
@@ -5,7 +5,7 @@
 # Do not compress man pages which are smaller than this (in bytes). #169260
 SIZE_LIMIT='128'
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ! ___eapi_has_prefix_variables; then
 	ED=${D}
diff --git a/bin/ebuild-helpers/prepstrip b/bin/ebuild-helpers/prepstrip
index 2ef8a1a..43caa29 100755
--- a/bin/ebuild-helpers/prepstrip
+++ b/bin/ebuild-helpers/prepstrip
@@ -2,8 +2,7 @@
 # Copyright 1999-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym}
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/helper-functions.sh
+source "${PORTAGE_BIN_PATH}"/helper-functions.sh || exit 1
 
 # avoid multiple calls to `has`.  this creates things like:
 #   FEATURES_foo=false
diff --git a/bin/ebuild-helpers/unprivileged/chown b/bin/ebuild-helpers/unprivileged/chown
index 2f1f161..b57dc8a 100755
--- a/bin/ebuild-helpers/unprivileged/chown
+++ b/bin/ebuild-helpers/unprivileged/chown
@@ -2,6 +2,8 @@
 # Copyright 2012-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
+
 scriptpath=${BASH_SOURCE[0]}
 scriptname=${scriptpath##*/}
 
@@ -23,8 +25,6 @@ for path in ${PATH}; do
 			output="${output}\n ... (further messages truncated)"
 		fi
 
-		source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
-
 		if ! ___eapi_has_prefix_variables; then
 			EPREFIX=
 		fi
diff --git a/bin/ebuild-helpers/xattr/install b/bin/ebuild-helpers/xattr/install
index 2d2a693..4d596e1 100755
--- a/bin/ebuild-helpers/xattr/install
+++ b/bin/ebuild-helpers/xattr/install
@@ -2,8 +2,6 @@
 # Copyright 2013-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}
-PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym}
 INSTALL_XATTR=${EPREFIX}/usr/bin/install-xattr
 # Use safe cwd, avoiding unsafe import for bug #469338.
 export __PORTAGE_HELPER_CWD=${PWD}
diff --git a/bin/ebuild-ipc b/bin/ebuild-ipc
index 820005f..e77b94b 100755
--- a/bin/ebuild-ipc
+++ b/bin/ebuild-ipc
@@ -2,9 +2,7 @@
 # Copyright 2010-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}
-PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym}
 # Use safe cwd, avoiding unsafe import for bug #469338.
-cd "${PORTAGE_PYM_PATH}"
+cd "${PORTAGE_PYM_PATH}" || exit 1
 PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
 	exec "${PORTAGE_PYTHON:-/usr/bin/python}" "$PORTAGE_BIN_PATH/ebuild-ipc.py" "$@"
diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 4e26f87..75a9d24 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -2,9 +2,6 @@
 # Copyright 1999-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-PORTAGE_BIN_PATH="${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"
-PORTAGE_PYM_PATH="${PORTAGE_PYM_PATH:-/usr/lib/portage/pym}"
-
 # Prevent aliases from causing portage to act inappropriately.
 # Make sure it's before everything so we don't mess aliases that follow.
 unalias -a
diff --git a/bin/helper-functions.sh b/bin/helper-functions.sh
index b9bc74a..c096aed 100644
--- a/bin/helper-functions.sh
+++ b/bin/helper-functions.sh
@@ -5,7 +5,7 @@
 # For routines we want to use in ebuild-helpers/ but don't want to
 # expose to the general ebuild environment.
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 #
 # API functions for doing parallel processing
diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 8e789ec..003c01d 100644
--- a/bin/isolated-functions.sh
+++ b/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/lib/portage/bin}/eapi.sh"
+source "${PORTAGE_BIN_PATH}/eapi.sh" || exit 1
 
 # We need this next line for "die" and "assert". It expands
 # It _must_ preceed all the calls to die and assert.
diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
index 24941af..9b79351 100755
--- a/bin/misc-functions.sh
+++ b/bin/misc-functions.sh
@@ -14,7 +14,7 @@
 MISC_FUNCTIONS_ARGS="$@"
 shift $#
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}/ebuild.sh"
+source "${PORTAGE_BIN_PATH}/ebuild.sh" || exit 1
 
 install_symlink_html_docs() {
 	if ! ___eapi_has_prefix_variables; then
-- 
2.4.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [gentoo-portage-dev] [PATCH] require PORTAGE_{BIN,PYM}_PATH not be cleared
  2015-06-10 15:45 ` [gentoo-portage-dev] [PATCH] require PORTAGE_{BIN,PYM}_PATH not be cleared Mike Frysinger
@ 2015-06-10 18:31   ` Zac Medico
  2015-06-11  6:44     ` Brian Dolbec
  2015-06-11  9:57   ` Mike Frysinger
  1 sibling, 1 reply; 11+ messages in thread
From: Zac Medico @ 2015-06-10 18:31 UTC (permalink / raw
  To: gentoo-portage-dev

On 06/10/2015 08:45 AM, Mike Frysinger wrote:
> Rather than hardcode a full path everywhere as a fallback, assume the
> value is always set to the right location.  The current path isn't the
> right place anymore already.
> 
> If it turns out we want to support this scenario, we can do it via a
> bunch of bootstrapping (and symlinked) files.
> ---

LGTM
-- 
Thanks,
Zac


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [gentoo-portage-dev] [PATCH] require PORTAGE_{BIN,PYM}_PATH not be cleared
  2015-06-10 18:31   ` Zac Medico
@ 2015-06-11  6:44     ` Brian Dolbec
  0 siblings, 0 replies; 11+ messages in thread
From: Brian Dolbec @ 2015-06-11  6:44 UTC (permalink / raw
  To: gentoo-portage-dev

On Wed, 10 Jun 2015 11:31:14 -0700
Zac Medico <zmedico@gentoo.org> wrote:

> On 06/10/2015 08:45 AM, Mike Frysinger wrote:
> > Rather than hardcode a full path everywhere as a fallback, assume
> > the value is always set to the right location.  The current path
> > isn't the right place anymore already.
> > 
> > If it turns out we want to support this scenario, we can do it via a
> > bunch of bootstrapping (and symlinked) files.
> > ---
> 
> LGTM

Yeah, it's good.

Sorry it's taken so long for me to review...

-- 
Brian Dolbec <dolsen>



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [gentoo-portage-dev] [PATCH] require PORTAGE_{BIN,PYM}_PATH not be cleared
  2015-06-10 15:45 ` [gentoo-portage-dev] [PATCH] require PORTAGE_{BIN,PYM}_PATH not be cleared Mike Frysinger
  2015-06-10 18:31   ` Zac Medico
@ 2015-06-11  9:57   ` Mike Frysinger
  1 sibling, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2015-06-11  9:57 UTC (permalink / raw
  To: gentoo-portage-dev

[-- Attachment #1: Type: text/plain, Size: 17 bytes --]

pushed now
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-06-11  9:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-01  6:34 [gentoo-portage-dev] [PATCH] make PORTAGE_BIN_PATH settings relocatable Mike Frysinger
2015-06-01 17:25 ` Mike Frysinger
2015-06-01 18:01   ` Tim Harder
2015-06-02  4:31     ` Mike Frysinger
2015-06-02  5:27       ` Tim Harder
2015-06-01 18:49   ` Zac Medico
2015-06-02 15:34     ` Mike Frysinger
2015-06-10 15:45 ` [gentoo-portage-dev] [PATCH] require PORTAGE_{BIN,PYM}_PATH not be cleared Mike Frysinger
2015-06-10 18:31   ` Zac Medico
2015-06-11  6:44     ` Brian Dolbec
2015-06-11  9:57   ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox