commit: 8a7e6909326b5b70076bdedb38513d93cb0d3117
Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 5 22:23:02 2021 +0000
Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Mon Jul 5 23:40:51 2021 +0000
URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=8a7e6909
gen_funcs.sh: expand_file(): Outsource embedded Python call
This will allow us to set proper shebang for
dev-lang/python-exec[-native-symlinks]
support.
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
gen_funcs.sh | 2 +-
path_expander.py | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/gen_funcs.sh b/gen_funcs.sh
index ab7a7ce..7257229 100755
--- a/gen_funcs.sh
+++ b/gen_funcs.sh
@@ -1952,7 +1952,7 @@ expand_file() {
local file="${1}"
local expanded_file=
- expanded_file=$(python -c "import os;
print(os.path.expanduser('${file}'))" 2>/dev/null)
+ expanded_file=$("${GK_SHARE}/path_expander.py" "${file}" 2>/dev/null)
if [ -z "${expanded_file}" ]
then
# if Python failed for some reason, just reset
diff --git a/path_expander.py b/path_expander.py
new file mode 100755
index 0000000..82accad
--- /dev/null
+++ b/path_expander.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+
+def main(argv):
+ if len(argv) != 1:
+ print(
+ "%s expects exactly one argument but %s were given!"
+ % (os.path.basename(__file__), len(argv)),
+ file=sys.stderr
+ )
+ sys.exit(1)
+
+ print(os.path.expanduser(argv[0]))
+
+if __name__ == "__main__":
+ main(sys.argv[1:])