aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Deutschmann <whissi@gentoo.org>2019-03-29 03:47:43 +0100
committerThomas Deutschmann <whissi@gentoo.org>2019-03-29 03:51:22 +0100
commita42e9e779795d1a4eff1a48ba14e70f03a64b98e (patch)
treebcdfc25a5f7c46334f48f21415aae0392cd6dfab /gen_funcs.sh
parentconfig_kernel(): Force --static and --no-ramdisk-modules (diff)
downloadgenkernel-a42e9e779795d1a4eff1a48ba14e70f03a64b98e.tar.gz
genkernel-a42e9e779795d1a4eff1a48ba14e70f03a64b98e.tar.bz2
genkernel-a42e9e779795d1a4eff1a48ba14e70f03a64b98e.zip
Add new function expand_file() to allow file path expansion
Relies on Python os.path.expanduser and realpath from coreutils. Bug: https://bugs.gentoo.org/412321 Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Diffstat (limited to 'gen_funcs.sh')
-rwxr-xr-xgen_funcs.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/gen_funcs.sh b/gen_funcs.sh
index 95c8f30..ba45b02 100755
--- a/gen_funcs.sh
+++ b/gen_funcs.sh
@@ -538,6 +538,25 @@ check_distfiles() {
done
}
+expand_file() {
+ [[ "$#" -lt '1' ]] &&
+ echo ''
+
+ local file="${1}"
+ local expanded_file=
+
+ expanded_file=$(python -c "import os; print(os.path.expanduser('${file}'))" 2>/dev/null)
+ if [ -z "${expanded_file}" ]
+ then
+ # if Python failed for some reason, just reset
+ expanded_file=${file}
+ fi
+
+ expanded_file=$(realpath -q "${expanded_file}" 2>/dev/null)
+
+ echo "${expanded_file}"
+}
+
find_kernel_binary() {
local kernel_binary=$*
local curdir=$(pwd)