Gentoo Archives: gentoo-commits

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/genkernel:master commit in: /
Date: Tue, 06 Jul 2021 00:25:20
Message-Id: 1625528451.8a7e6909326b5b70076bdedb38513d93cb0d3117.whissi@gentoo
1 commit: 8a7e6909326b5b70076bdedb38513d93cb0d3117
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Mon Jul 5 22:23:02 2021 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Mon Jul 5 23:40:51 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=8a7e6909
7
8 gen_funcs.sh: expand_file(): Outsource embedded Python call
9
10 This will allow us to set proper shebang for dev-lang/python-exec[-native-symlinks]
11 support.
12
13 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
14
15 gen_funcs.sh | 2 +-
16 path_expander.py | 18 ++++++++++++++++++
17 2 files changed, 19 insertions(+), 1 deletion(-)
18
19 diff --git a/gen_funcs.sh b/gen_funcs.sh
20 index ab7a7ce..7257229 100755
21 --- a/gen_funcs.sh
22 +++ b/gen_funcs.sh
23 @@ -1952,7 +1952,7 @@ expand_file() {
24 local file="${1}"
25 local expanded_file=
26
27 - expanded_file=$(python -c "import os; print(os.path.expanduser('${file}'))" 2>/dev/null)
28 + expanded_file=$("${GK_SHARE}/path_expander.py" "${file}" 2>/dev/null)
29 if [ -z "${expanded_file}" ]
30 then
31 # if Python failed for some reason, just reset
32
33 diff --git a/path_expander.py b/path_expander.py
34 new file mode 100755
35 index 0000000..82accad
36 --- /dev/null
37 +++ b/path_expander.py
38 @@ -0,0 +1,18 @@
39 +#!/usr/bin/env python3
40 +
41 +import os
42 +import sys
43 +
44 +def main(argv):
45 + if len(argv) != 1:
46 + print(
47 + "%s expects exactly one argument but %s were given!"
48 + % (os.path.basename(__file__), len(argv)),
49 + file=sys.stderr
50 + )
51 + sys.exit(1)
52 +
53 + print(os.path.expanduser(argv[0]))
54 +
55 +if __name__ == "__main__":
56 + main(sys.argv[1:])