linux-info.eclass: respect kernel CONFIG_LOCALVERSION
authorDmitry Derevyanko <nrndda@gmail.com>
Sun, 29 Jul 2018 23:22:38 +0000 (01:22 +0200)
committerThomas Deutschmann <whissi@gentoo.org>
Sun, 29 Jul 2018 23:23:27 +0000 (01:23 +0200)
Closes: https://bugs.gentoo.org/460996
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
eclass/linux-info.eclass

index 6cd64457edd2b558a2efadc23a0c0017d818a8c8..b158e345d16668d70a213026dbeb61fe60d53224 100644 (file)
@@ -548,6 +548,30 @@ get_version() {
                return 1
        fi
 
+       # Grab the kernel release from the output directory.
+       # TODO: we MUST detect kernel.release being out of date, and 'return 1' from
+       # this function.
+       if [ -s "${KV_DIR}"/include/config/kernel.release ]; then
+               KV_LOCAL=$(<"${KV_DIR}"/include/config/kernel.release)
+       elif [ -s "${KV_DIR}"/.kernelrelease ]; then
+               KV_LOCAL=$(<"${KV_DIR}"/.kernelrelease)
+       else
+               KV_LOCAL=
+       fi
+
+       # KV_LOCAL currently contains the full release; discard the first bits.
+       tmplocal=${KV_LOCAL#${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}}
+
+       # If the updated local version was not changed, the tree is not prepared.
+       # Clear out KV_LOCAL in that case.
+       # TODO: this does not detect a change in the localversion part between
+       # kernel.release and the value that would be generated.
+       if [ "$KV_LOCAL" = "$tmplocal" ]; then
+               KV_LOCAL=
+       else
+               KV_LOCAL=$tmplocal
+       fi
+
        # and in newer versions we can also pull LOCALVERSION if it is set.
        # but before we do this, we need to find if we use a different object directory.
        # This *WILL* break if the user is using localversions, but we assume it was
@@ -555,7 +579,7 @@ get_version() {
        if [[ -z ${OUTPUT_DIR} ]] ; then
                # Try to locate a kernel that is most relevant for us.
                for OUTPUT_DIR in "${SYSROOT}" "${ROOT%/}" "" ; do
-                       OUTPUT_DIR+="/lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}/build"
+                       OUTPUT_DIR+="/lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}/build"
                        if [[ -e ${OUTPUT_DIR} ]] ; then
                                break
                        fi
@@ -571,30 +595,6 @@ get_version() {
        # and if we STILL have not got it, then we better just set it to KV_DIR
        KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}"
 
-       # Grab the kernel release from the output directory.
-       # TODO: we MUST detect kernel.release being out of date, and 'return 1' from
-       # this function.
-       if [ -s "${KV_OUT_DIR}"/include/config/kernel.release ]; then
-               KV_LOCAL=$(<"${KV_OUT_DIR}"/include/config/kernel.release)
-       elif [ -s "${KV_OUT_DIR}"/.kernelrelease ]; then
-               KV_LOCAL=$(<"${KV_OUT_DIR}"/.kernelrelease)
-       else
-               KV_LOCAL=
-       fi
-
-       # KV_LOCAL currently contains the full release; discard the first bits.
-       tmplocal=${KV_LOCAL#${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}}
-
-       # If the updated local version was not changed, the tree is not prepared.
-       # Clear out KV_LOCAL in that case.
-       # TODO: this does not detect a change in the localversion part between
-       # kernel.release and the value that would be generated.
-       if [ "$KV_LOCAL" = "$tmplocal" ]; then
-               KV_LOCAL=
-       else
-               KV_LOCAL=$tmplocal
-       fi
-
        # And we should set KV_FULL to the full expanded version
        KV_FULL="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}"