Lines 155-160
qout() {
Link Here
|
155 |
} |
155 |
} |
156 |
|
156 |
|
157 |
qeinfo() { qout einfo "${@}" ; } |
157 |
qeinfo() { qout einfo "${@}" ; } |
|
|
158 |
qewarn() { qout ewarn "$@" ; } |
158 |
qeerror() { qout eerror "${@}" ; } |
159 |
qeerror() { qout eerror "${@}" ; } |
159 |
|
160 |
|
160 |
# File Functions |
161 |
# File Functions |
Lines 215-221
getfilevar_noexec() {
Link Here
|
215 |
else |
216 |
else |
216 |
${mycat} "${2}" | \ |
217 |
${mycat} "${2}" | \ |
217 |
sed -n \ |
218 |
sed -n \ |
218 |
-e "/^[[:space:]]*${1}[[:space:]]*=[[:space:]]*\(.*\)\$/{ |
219 |
-e "/^[[:space:]]*${1}[[:space:]]*:\\?=[[:space:]]*\(.*\)\$/{ |
219 |
s,^[^=]*[[:space:]]*=[[:space:]]*,,g ; |
220 |
s,^[^=]*[[:space:]]*=[[:space:]]*,,g ; |
220 |
s,[[:space:]]*\$,,g ; |
221 |
s,[[:space:]]*\$,,g ; |
221 |
p |
222 |
p |
Lines 404-409
get_localversion() {
Link Here
|
404 |
# internal variable, so we know to only print the warning once |
405 |
# internal variable, so we know to only print the warning once |
405 |
get_version_warning_done= |
406 |
get_version_warning_done= |
406 |
|
407 |
|
|
|
408 |
check_kbuild_output() { |
409 |
if [ ! -s "${KBUILD_OUTPUT}/Makefile" ]; then |
410 |
if [ -z "${get_version_warning_done}" ]; then |
411 |
get_version_warning_done=1 |
412 |
qeerror "Could not find a Makefile in the kernel build directory." |
413 |
qeerror "Please ensure that ${KBUILD_OUTPUT} points to an initialized" |
414 |
qeerror "kernel output directory." |
415 |
fi |
416 |
return 1 |
417 |
else |
418 |
local make_args="$(getfilevar MAKEARGS ${KBUILD_OUTPUT}/Makefile)" |
419 |
if [ -n "${make_args}" ]; then |
420 |
# 2.6.25 or more recent Makefile of KBUILD_OUTPUT |
421 |
[ -z "${get_version_warning_done}" ] && \ |
422 |
qeinfo "This KBUILD_OUTPUT makefile looks like 2.6.25 or more recent format" |
423 |
OUTPUT_DIR=$(echo ${make_args} | sed -r -e 's:^(.* )?O=([^ ]*)/\.( .*)?$:\2:') |
424 |
KV_DIR=$(echo ${make_args} | sed -r -e 's:^(.* )?-C ([^ ]*)/? .*$:\2:') |
425 |
else |
426 |
# Attempt vars as in KBUILD_OUTPUT Makefile of older kernels |
427 |
OUTPUT_DIR="$(getfilevar_noexec KERNELOUTPUT ${KBUILD_OUTPUT}/Makefile)" |
428 |
KV_DIR="$(getfilevar_noexec KERNELSRC ${KBUILD_OUTPUT}/Makefile)" |
429 |
fi |
430 |
if [ -z "${KV_DIR}" ] && [ -n "$(getfilevar_noexec SUBLEVEL ${KBUILD_OUTPUT}/Makefile)" ]; then |
431 |
# KBUILD_OUTPUT is the same as KERNEL_DIR |
432 |
OUTPUT_DIR="${KBUILD_OUTPUT}" |
433 |
KV_DIR="${KBUILD_OUTPUT}" |
434 |
elif [ -z "${KV_DIR}" ]; then |
435 |
if [ -z "${get_version_warning_done}" ]; then |
436 |
get_version_warning_done=1 |
437 |
qeerror "Can't figure out anything out of ${KBUILD_OUTPUT}," |
438 |
qeerror "make sure it points to a valid kernel object tree or" |
439 |
qeerror "kernel source tree if you build in tree." |
440 |
fi |
441 |
return 1 |
442 |
fi |
443 |
fi |
444 |
return 0 |
445 |
} |
446 |
|
407 |
# @FUNCTION: get_version |
447 |
# @FUNCTION: get_version |
408 |
# @DESCRIPTION: |
448 |
# @DESCRIPTION: |
409 |
# It gets the version of the kernel inside KERNEL_DIR and populates the KV_FULL variable |
449 |
# It gets the version of the kernel inside KERNEL_DIR and populates the KV_FULL variable |
Lines 430-470
get_version() {
Link Here
|
430 |
qeinfo "Determining the location of the kernel source code" |
470 |
qeinfo "Determining the location of the kernel source code" |
431 |
|
471 |
|
432 |
if [ -n "${KBUILD_OUTPUT}" ]; then |
472 |
if [ -n "${KBUILD_OUTPUT}" ]; then |
433 |
if [ ! -s "${KBUILD_OUTPUT}/Makefile" ]; then |
473 |
check_kbuild_output || return 1 |
434 |
if [ -z "${get_version_warning_done}" ]; then |
|
|
435 |
get_version_warning_done=1 |
436 |
qeerror "Could not find a Makefile in the kernel build directory." |
437 |
qeerror "Please ensure that ${KBUILD_OUTPUT} points to an initialized" |
438 |
qeerror "kernel output directory." |
439 |
fi |
440 |
return 1 |
441 |
else |
442 |
local make_args="$(getfilevar MAKEARGS ${KBUILD_OUTPUT}/Makefile)" |
443 |
if [ -n "${make_args}" ]; then |
444 |
# 2.6.25 or more recent Makefile of KBUILD_OUTPUT |
445 |
[ -z "${get_version_warning_done}" ] && \ |
446 |
qeinfo "This KBUILD_OUTPUT makefile looks like 2.6.25 or more recent format" |
447 |
OUTPUT_DIR=$(echo ${make_args} | sed -r -e 's:^(.* )?O=([^ ]*)/\.( .*)?$:\2:') |
448 |
KV_DIR=$(echo ${make_args} | sed -r -e 's:^(.* )?-C ([^ ]*)/? .*$:\2:') |
449 |
else |
450 |
# Attempt vars as in KBUILD_OUTPUT Makefile of older kernels |
451 |
OUTPUT_DIR="$(getfilevar_noexec KERNELOUTPUT ${KBUILD_OUTPUT}/Makefile)" |
452 |
KV_DIR="$(getfilevar_noexec KERNELSRC ${KBUILD_OUTPUT}/Makefile)" |
453 |
fi |
454 |
if [ -z "${KV_DIR}" ] && [ -n "$(getfilevar_noexec SUBLEVEL ${KBUILD_OUTPUT}/Makefile)" ]; then |
455 |
# KBUILD_OUTPUT is the same as KERNEL_DIR |
456 |
OUTPUT_DIR="${KBUILD_OUTPUT}" |
457 |
KV_DIR="${KBUILD_OUTPUT}" |
458 |
elif [ -z "${KV_DIR}" ]; then |
459 |
if [ -z "${get_version_warning_done}" ]; then |
460 |
get_version_warning_done=1 |
461 |
qeerror "Can't figure out anything out of ${KBUILD_OUTPUT}," |
462 |
qeerror "make sure it points to a valid kernel object tree or" |
463 |
qeerror "kernel source tree if you build in tree." |
464 |
fi |
465 |
return 1 |
466 |
fi |
467 |
fi |
468 |
fi |
474 |
fi |
469 |
|
475 |
|
470 |
if [ -z "${KV_DIR}" ]; then |
476 |
if [ -z "${KV_DIR}" ]; then |
Lines 497-502
get_version() {
Link Here
|
497 |
if [ ! -s "${KV_DIR}/Makefile" ] |
503 |
if [ ! -s "${KV_DIR}/Makefile" ] |
498 |
then |
504 |
then |
499 |
if [ -z "${get_version_warning_done}" ]; then |
505 |
if [ -z "${get_version_warning_done}" ]; then |
|
|
506 |
echo "${KV_DIR}/Makefile does not exist/is empty" |
500 |
get_version_warning_done=1 |
507 |
get_version_warning_done=1 |
501 |
qeerror "Could not find a Makefile in the kernel source directory." |
508 |
qeerror "Could not find a Makefile in the kernel source directory." |
502 |
qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources" |
509 |
qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources" |
Lines 512-517
get_version() {
Link Here
|
512 |
KV_PATCH="$(getfilevar_noexec SUBLEVEL ${KV_DIR}/Makefile)" |
519 |
KV_PATCH="$(getfilevar_noexec SUBLEVEL ${KV_DIR}/Makefile)" |
513 |
KV_EXTRA="$(getfilevar_noexec EXTRAVERSION ${KV_DIR}/Makefile)" |
520 |
KV_EXTRA="$(getfilevar_noexec EXTRAVERSION ${KV_DIR}/Makefile)" |
514 |
|
521 |
|
|
|
522 |
if [ -z "${KV_MAJOR}" -o -z "${KV_MINOR}" -o -z "${KV_PATCH}" ]; then |
523 |
qewarn "It was not a kernel source directory, checking as kernel object directory" |
524 |
KBUILD_OUTPUT=${KV_DIR} |
525 |
if check_kbuild_output; then |
526 |
if [ -z "${get_version_warning_done}" ]; then |
527 |
qeinfo "Found kernel source directory:" |
528 |
qeinfo " ${KV_DIR}" |
529 |
fi |
530 |
|
531 |
KV_MAJOR="$(getfilevar_noexec VERSION ${KV_DIR}/Makefile)" |
532 |
KV_MINOR="$(getfilevar_noexec PATCHLEVEL ${KV_DIR}/Makefile)" |
533 |
KV_PATCH="$(getfilevar_noexec SUBLEVEL ${KV_DIR}/Makefile)" |
534 |
KV_EXTRA="$(getfilevar_noexec EXTRAVERSION ${KV_DIR}/Makefile)" |
535 |
fi |
536 |
fi |
515 |
if [ -z "${KV_MAJOR}" -o -z "${KV_MINOR}" -o -z "${KV_PATCH}" ] |
537 |
if [ -z "${KV_MAJOR}" -o -z "${KV_MINOR}" -o -z "${KV_PATCH}" ] |
516 |
then |
538 |
then |
517 |
if [ -z "${get_version_warning_done}" ]; then |
539 |
if [ -z "${get_version_warning_done}" ]; then |
Lines 572-577
get_running_version() {
Link Here
|
572 |
|
594 |
|
573 |
if [[ -f ${ROOT}/lib/modules/${KV_FULL}/source/Makefile ]]; then |
595 |
if [[ -f ${ROOT}/lib/modules/${KV_FULL}/source/Makefile ]]; then |
574 |
KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/source) |
596 |
KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/source) |
|
|
597 |
if [[ -f ${ROOT}/lib/modules/${KV_FULL}/build/Makefile ]]; then |
598 |
KBUILD_OUTPUT=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/build) |
599 |
fi |
575 |
unset KV_FULL |
600 |
unset KV_FULL |
576 |
get_version |
601 |
get_version |
577 |
return $? |
602 |
return $? |