linux-info.eclass: account for lack of trailing slash
authorMarty E. Plummer <hanetzer@startmail.com>
Fri, 13 Jul 2018 23:44:48 +0000 (18:44 -0500)
committerMatt Turner <mattst88@gentoo.org>
Tue, 17 Jul 2018 14:15:17 +0000 (07:15 -0700)
In EAPI 7, D, ED, ROOT, EROOT no longer have a trailing slash[1]. This
makes finding /usr/src/linux not work properly as it currently stands.

Use the form "${ROOT%/}/" where apropos in order to unify behavior across
EAPIs.

1: https://dev.gentoo.org/~ulm/pms/head/pms.html#x1-113001r7
Closes: https://github.com/gentoo/gentoo/pull/9222

eclass/linux-info.eclass

index 96f94e4072ae59d83eba0500f275543d1ee66508..314647660387a1f09871e164dd23c6189111d3ee 100644 (file)
@@ -115,7 +115,7 @@ IUSE="kernel_linux"
 
 # Overwritable environment Var's
 # ---------------------------------------
-KERNEL_DIR="${KERNEL_DIR:-${ROOT}usr/src/linux}"
+KERNEL_DIR="${KERNEL_DIR:-${ROOT%/}/usr/src/linux}"
 
 
 # Bug fixes
@@ -554,7 +554,7 @@ get_version() {
        # caught before this if they are.
        if [[ -z ${OUTPUT_DIR} ]] ; then
                # Try to locate a kernel that is most relevant for us.
-               for OUTPUT_DIR in "${SYSROOT}" "${ROOT}" "" ; do
+               for OUTPUT_DIR in "${SYSROOT}" "${ROOT%/}/" "" ; do
                        OUTPUT_DIR+="/lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}/build"
                        if [[ -e ${OUTPUT_DIR} ]] ; then
                                break
@@ -615,19 +615,19 @@ get_running_version() {
 
        KV_FULL=$(uname -r)
 
-       if [[ -f ${ROOT}/lib/modules/${KV_FULL}/source/Makefile && -f ${ROOT}/lib/modules/${KV_FULL}/build/Makefile ]]; then
-               KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/source)
-               KBUILD_OUTPUT=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/build)
+       if [[ -f ${ROOT%/}/lib/modules/${KV_FULL}/source/Makefile && -f ${ROOT%/}/lib/modules/${KV_FULL}/build/Makefile ]]; then
+               KERNEL_DIR=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/source)
+               KBUILD_OUTPUT=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/build)
                unset KV_FULL
                get_version
                return $?
-       elif [[ -f ${ROOT}/lib/modules/${KV_FULL}/source/Makefile ]]; then
-               KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/source)
+       elif [[ -f ${ROOT%/}/lib/modules/${KV_FULL}/source/Makefile ]]; then
+               KERNEL_DIR=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/source)
                unset KV_FULL
                get_version
                return $?
-       elif [[ -f ${ROOT}/lib/modules/${KV_FULL}/build/Makefile ]]; then
-               KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/build)
+       elif [[ -f ${ROOT%/}/lib/modules/${KV_FULL}/build/Makefile ]]; then
+               KERNEL_DIR=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/build)
                unset KV_FULL
                get_version
                return $?