commit:     cec73041df583bfd46e1fa9739286a74a2e85b18
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Mar  4 08:34:43 2021 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Mar  4 08:59:04 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=cec73041

bin/ebuild-pyhelper: wrapper for portage python helpers

Merge the shell script wrappers for chmod-lite and ebuild-ipc
into a single ebuild-pyhelper script.

Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 bin/chmod-lite      | 11 +----------
 bin/ebuild-ipc      |  9 +--------
 bin/ebuild-pyhelper | 21 +++++++++++++++++++++
 3 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/bin/chmod-lite b/bin/chmod-lite
deleted file mode 100755
index ffa8d4d23..000000000
--- a/bin/chmod-lite
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-# Copyright 2015 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-export __PORTAGE_HELPER_CWD=${PWD}
-
-# Use safe cwd, avoiding unsafe import for bug #469338.
-cd "${PORTAGE_PYM_PATH}" || exit 1
-PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
-       exec "${PORTAGE_PYTHON:-/usr/bin/python}" 
"$PORTAGE_BIN_PATH/chmod-lite.py" "$@"

diff --git a/bin/chmod-lite b/bin/chmod-lite
new file mode 120000
index 000000000..d64cd615b
--- /dev/null
+++ b/bin/chmod-lite
@@ -0,0 +1 @@
+ebuild-pyhelper
\ No newline at end of file

diff --git a/bin/ebuild-ipc b/bin/ebuild-ipc
deleted file mode 100755
index e77b94b2c..000000000
--- a/bin/ebuild-ipc
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-# Copyright 2010-2013 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-# Use safe cwd, avoiding unsafe import for bug #469338.
-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-ipc b/bin/ebuild-ipc
new file mode 120000
index 000000000..d64cd615b
--- /dev/null
+++ b/bin/ebuild-ipc
@@ -0,0 +1 @@
+ebuild-pyhelper
\ No newline at end of file

diff --git a/bin/ebuild-pyhelper b/bin/ebuild-pyhelper
new file mode 100755
index 000000000..d32bc6f6f
--- /dev/null
+++ b/bin/ebuild-pyhelper
@@ -0,0 +1,21 @@
+#!/bin/bash
+# Copyright 2010-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+export __PORTAGE_HELPER_CWD=${PWD}
+
+if [[ ${0##*/} == "ebuild-pyhelper" ]]; then
+       echo "ebuild-pyhelper: must be called via symlink" &>2
+       exit 1
+fi
+
+# Use safe cwd, avoiding unsafe import for bug #469338.
+cd "${PORTAGE_PYM_PATH}" || exit 1
+for path in "${PORTAGE_BIN_PATH}/${0##*/}"{.py,}; do
+       if [[ -x "${path}" ]]; then
+               PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
+                       exec "${PORTAGE_PYTHON:-/usr/bin/python}" "${path}" "$@"
+       fi
+done
+echo "File not found: ${path}" >&2
+exit 1

Reply via email to