1 |
commit: a42e9e779795d1a4eff1a48ba14e70f03a64b98e |
2 |
Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Mar 29 02:47:43 2019 +0000 |
4 |
Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Mar 29 02:51:22 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=a42e9e77 |
7 |
|
8 |
Add new function expand_file() to allow file path expansion |
9 |
|
10 |
Relies on Python os.path.expanduser and realpath from coreutils. |
11 |
|
12 |
Bug: https://bugs.gentoo.org/412321 |
13 |
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org> |
14 |
|
15 |
gen_funcs.sh | 19 +++++++++++++++++++ |
16 |
1 file changed, 19 insertions(+) |
17 |
|
18 |
diff --git a/gen_funcs.sh b/gen_funcs.sh |
19 |
index 95c8f30..ba45b02 100755 |
20 |
--- a/gen_funcs.sh |
21 |
+++ b/gen_funcs.sh |
22 |
@@ -538,6 +538,25 @@ check_distfiles() { |
23 |
done |
24 |
} |
25 |
|
26 |
+expand_file() { |
27 |
+ [[ "$#" -lt '1' ]] && |
28 |
+ echo '' |
29 |
+ |
30 |
+ local file="${1}" |
31 |
+ local expanded_file= |
32 |
+ |
33 |
+ expanded_file=$(python -c "import os; print(os.path.expanduser('${file}'))" 2>/dev/null) |
34 |
+ if [ -z "${expanded_file}" ] |
35 |
+ then |
36 |
+ # if Python failed for some reason, just reset |
37 |
+ expanded_file=${file} |
38 |
+ fi |
39 |
+ |
40 |
+ expanded_file=$(realpath -q "${expanded_file}" 2>/dev/null) |
41 |
+ |
42 |
+ echo "${expanded_file}" |
43 |
+} |
44 |
+ |
45 |
find_kernel_binary() { |
46 |
local kernel_binary=$* |
47 |
local curdir=$(pwd) |