Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 87242 | Differences between
and this patch

Collapse All | Expand All

(-)../linux-info-1.71.eclass (-13 / +46 lines)
Lines 424-436 get_version() { Link Here
424
	# if we dont know KV_FULL, then we need too.
424
	# if we dont know KV_FULL, then we need too.
425
	# make sure KV_DIR isnt set since we need to work it out via KERNEL_DIR
425
	# make sure KV_DIR isnt set since we need to work it out via KERNEL_DIR
426
	unset KV_DIR
426
	unset KV_DIR
427
	unset OUTPUT_DIR
427
428
428
	# KV_DIR will contain the full path to the sources directory we should use
429
	[ -z "${get_version_warning_done}" ] && \
429
	[ -z "${get_version_warning_done}" ] && \
430
	qeinfo "Determining the location of the kernel source code"
430
	qeinfo "Determining the location of the kernel source code"
431
	[ -h "${KERNEL_DIR}" ] && KV_DIR="$(readlink -f ${KERNEL_DIR})"
432
	[ -d "${KERNEL_DIR}" ] && KV_DIR="${KERNEL_DIR}"
433
431
432
	if [ -n "${KBUILD_OUTPUT}" ]; then
433
		if [ -s "${KBUILD_OUTPUT}/Makefile" ]; then
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
469
470
	if [ -z "${KV_DIR}" ]; then
471
		# KV_DIR will contain the full path to the sources directory we should use
472
		[ -h "${KERNEL_DIR}" ] && KV_DIR="$(readlink -f ${KERNEL_DIR})"
473
		[ -d "${KERNEL_DIR}" ] && KV_DIR="${KERNEL_DIR}"
474
	fi
434
	if [ -z "${KV_DIR}" ]
475
	if [ -z "${KV_DIR}" ]
435
	then
476
	then
436
		if [ -z "${get_version_warning_done}" ]; then
477
		if [ -z "${get_version_warning_done}" ]; then
Lines 463-478 get_version() { Link Here
463
		return 1
504
		return 1
464
	fi
505
	fi
465
506
466
	# OK so now we know our sources directory, but they might be using
467
	# KBUILD_OUTPUT, and we need this for .config and localversions-*
468
	# so we better find it eh?
469
	# do we pass KBUILD_OUTPUT on the CLI?
470
	OUTPUT_DIR="${OUTPUT_DIR:-${KBUILD_OUTPUT}}"
471
472
	# And if we didn't pass it, we can take a nosey in the Makefile
473
	kbuild_output="$(getfilevar_noexec KBUILD_OUTPUT ${KV_DIR}/Makefile)"
474
	OUTPUT_DIR="${OUTPUT_DIR:-${kbuild_output}}"
475
476
	# And contrary to existing functions I feel we shouldn't trust the
507
	# And contrary to existing functions I feel we shouldn't trust the
477
	# directory name to find version information as this seems insane.
508
	# directory name to find version information as this seems insane.
478
	# so we parse ${KV_DIR}/Makefile
509
	# so we parse ${KV_DIR}/Makefile
Lines 489-494 get_version() { Link Here
489
			qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources."
520
			qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources."
490
		fi
521
		fi
491
		return 1
522
		return 1
523
	elif [ -z "${OUTPUT_DIR}" -a -s "${KV_DIR}/.config" ]; then
524
		OUTPUT_DIR="${KV_DIR}"
492
	fi
525
	fi
493
526
494
	# and in newer versions we can also pull LOCALVERSION if it is set.
527
	# and in newer versions we can also pull LOCALVERSION if it is set.

Return to bug 87242