Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 72974 - nvidia-kernel fails to compile, because of multiple problems in linux-info.eclass
Summary: nvidia-kernel fails to compile, because of multiple problems in linux-info.ec...
Status: RESOLVED TEST-REQUEST
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: John Mylchreest (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-30 15:29 UTC by Georgi Georgiev
Modified: 2004-12-05 10:13 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
linux-info.eclass.patch (patch,622 bytes, patch)
2004-12-01 11:45 UTC, Georgi Georgiev
Details | Diff
emerge info file (info.out,1.91 KB, text/plain)
2004-12-05 10:13 UTC, Neil Katin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Georgi Georgiev 2004-11-30 15:29:01 UTC
The current linux-info.eclass has numerous problems that prevent packages that depend on it from compiling.

1. getfilevar() produces unreasonable output when looking for KBUILD_OUTPUT
  $ getfilevar KBUILD_OUTPUT /usr/src/linux/Makefile 
- actual results:
 /var/tmp/linux-build/$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
- expected results
 /var/tmp/linux-build/2.6.7-y1

2. getfilevar() knows nothing about variable substition and thus fails on Makefile parsing
 (see 1. for expected and actual results)

- suggestion

  I once suggested (in a bug that I cannot find) to use the make command for parsing Makefiles. I.e., instead of running grep + sed on the Makefile (and handle all possible syntax fluctuations and error cases), use this one instead:

echo -e 'include /usr/src/linux/Makefile\ne:\n\t@echo $(KBUILD_OUTPUT);' | make -f - e 2>/dev/null

Or, in the general, linux-info.eclass case:

--- /tmp/linux-info.eclass      2004-12-01 08:22:05.247590402 +0900
+++ /usr/portage/eclass/linux-info.eclass       2004-12-01 08:21:58.078816716 +0900
@@ -32,7 +32,7 @@
                eerror "getfilevar requires 2 variables, with the second a valid file."
                eerror "   getfilevar <VARIABLE> <CONFIGFILE>"
        else
-               grep -e "^$1[= ]" $2 | sed 's: = :=:' | cut -d= -f2-
+               echo -e "include $2\ne:\n\t@echo \$($1)" | make -f - e 2>/dev/null
        fi
 }

A nice plus is that this method can still be used for parsing the .config files of the kernel as well. I.e, with a modified linux-info.eclass as per above:

$ getfilevar CONFIG_CRC32 /var/tmp/linux-build/2.6.7-y1/.config
y
$ getfilevar KBUILD_OUTPUT /usr/src/linux-2.6.7/Makefile 
/var/tmp/linux-build/2.6.7-y1

3. getfilevar() has a 'sed -e ": = :=:" which does not handle the case "VAR= something", or even "VAR =     something" or "VAR := whatever"
Comment 1 John Mylchreest (RETIRED) gentoo-dev 2004-12-01 09:45:23 UTC
Firstly, I would appreciate if the bugs you logged were a little more respectful. Saying something sucks can easily be suggested without saying it.
The code which went in to support KBUILD_OUTPUT was mostly experimental code to at least honour this. Perhaps you could be a little more tactful.

1: That should never get validated since the following code is what sets KV_OUT_FULL

	kbuild_output="$(getfilevar KBUILD_OUTPUT ${KV_DIR}/Makefile)"
	OUTPUT_DIR="${OUTPUT_DIR:-${kbuild_output}}"

	[ -h "${OUTPUT_DIR}" ] && KV_OUT_DIR="$(readlink -f ${OUTPUT_DIR})"
	[ -d "${OUTPUT_DIR}" ] && KV_OUT_DIR="${OUTPUT_DIR}"
	if [ -n "${KV_OUT_DIR}" ];
	then
		einfo "Found kernel object directory:"
		einfo "    ${KV_OUT_DIR}"
		
		KV_LOCAL="$(cat ${KV_OUT_DIR}/localversion* 2>/dev/null)"
	fi
	# and if we STILL haven't got it, then we better just set it to KV_DIR
	KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}"

since that is neither a directory nor a symlink, I dont see how that validates. 

2: What was the outcome of that bug?
I dont actually see any reason to not use your method.

3: that sed makes the assumption that its either the kernel config code which wrote a .config, and the kernel Makefile is using proper syntax.
It shouldnt fail, although assuming we move to no2 which I don't have a problem with (except for the initial speed hit which isn't important) this wont make any difference.
Comment 2 John Mylchreest (RETIRED) gentoo-dev 2004-12-01 09:54:39 UTC
There is of course the problem with the make file usage, with the fact that we are not in ${KV_DIR} when the make is executed. so the function should technically store PWD, change to `dirname $2` run the make, then change back

So the attached suggested patch would break on all merges.
Comment 3 John Mylchreest (RETIRED) gentoo-dev 2004-12-01 10:35:37 UTC
Could you please attach a working patch for me for your suggested solution.
If practical, I will consider moving to it.
Comment 4 Georgi Georgiev 2004-12-01 11:27:30 UTC
Sorry if the report was insulting. It was my poor attempt to summarize it in the end in an original way. I'll rephrase that, since it was not my intent. I personally enjoyed the number of features that the eclass provided -- they're much easier to read than previous eclasses.

About the $PWD problem, here are a few more suggestions in addition to yours:

1. make -C "$(dirname $2)" --no-print-directory
2. cd "$(dirname $2)"; make ... ; cd -
3. pushd "$(dirname $2)" >/dev/null 2>&1 && make && popd >/dev/null 2>&1

This is actually a problem with 2.4.x kernels only. The suggested code works fine on a 2.6 kernel.

Re: Comment #2, point 3.

I pointed out a problem with a legal kernel syntax. The code that you had in there would always fail, since KBUILD_OUTPUT is matched at least once for the default Makefile (of a 2.6 kernel), and once more, for the location I've set up on top.

Fact is, that I had a working configuration (generated by config-kernel, that I see is deprecated now) that stopped working after the ebuild switched to using the linux-mod.eclass.

P.S. I just saw that linux-info is patched already. That was fast.
Comment 5 Georgi Georgiev 2004-12-01 11:45:58 UTC
Created attachment 45069 [details, diff]
linux-info.eclass.patch

Here is the requested patch for my favorite method. Unless you want to also be
able to support non-gnu make -- then I'd go for "cd $(dirname $2); make; cd -".


2>/dev/null is needed, because there are warnings about overriding the rules
for target "e" (or whatever the target used) otherwise (on a 2.6 kernel).

E.g,

/tmp/GmQKJIhF:3: warning: overriding commands for target `e'
Makefile:112: warning: ignoring old commands for target `e'
Comment 6 John Mylchreest (RETIRED) gentoo-dev 2004-12-01 15:24:33 UTC
Thanks for changing the bug summary.
After some mild testing, I've come up with this alteration (in attempt to keep portability and compatibility)

		workingdir=${PWD}
		basefname=$(basename ${2})
		basedname=$(dirname ${2})
		arch=${ARCH}
		unset ARCH
		
		cd ${basedname}
		echo -e "include ${basefname}\ne:\n\t@echo \$(${1})" | make -f - e
		cd ${workingdir}
		 
		ARCH=${arch}

I am comitting the changes now. Please test for me and let me know how you get on.
Comment 7 Georgi Georgiev 2004-12-02 22:32:44 UTC
Just a minor problem still. See comment #5 why you need a "2>/dev/null" for the "make" command. I am currently getting:

# ebuild /usr/portage/media-video/nvidia-kernel/nvidia-kernel-1.0.6629.ebuild clean install
x86
>>> md5 src_uri ;-) NVIDIA-Linux-x86-1.0-6629-pkg1.run
x86
 * Determining the location of the kernel source code
/var/tmp/portage/nvidia-kernel-1.0.6629/temp/GmvEJR8h:3: warning: overriding commands for target `e'
Makefile:112: warning: ignoring old commands for target `e'
/var/tmp/portage/nvidia-kernel-1.0.6629/temp/Gm5ndPAl:3: warning: overriding commands for target `e'
Makefile:112: warning: ignoring old commands for target `e'
/var/tmp/portage/nvidia-kernel-1.0.6629/temp/GmLoiNlk:3: warning: overriding commands for target `e'
Makefile:112: warning: ignoring old commands for target `e'
/var/tmp/portage/nvidia-kernel-1.0.6629/temp/GmNGRlRn:3: warning: overriding commands for target `e'
Makefile:112: warning: ignoring old commands for target `e'
/var/tmp/portage/nvidia-kernel-1.0.6629/temp/GmFRbnCm:3: warning: overriding commands for target `e'
Makefile:112: warning: ignoring old commands for target `e'

It does work OK, but the warnings are annoying.
Comment 8 Neil Katin 2004-12-04 00:48:45 UTC
I was having this same problem; I can confirm that the new
version 1.6 of linux-info.eclass fixes the problem for me.
Thanks for making the change.

I'm not sure why, but I am *not* seeing the error messages
show in comment #6; the patch works fine for me.
Comment 9 Georgi Georgiev 2004-12-04 03:02:00 UTC
You don't get the errors for 2.4 kernels, but you do for 2.6.
Comment 10 Neil Katin 2004-12-05 10:13:43 UTC
Created attachment 45333 [details]
emerge info file

I am running gentoo-dev-sources-2.6.9-r6, so its not just a 2.6 vs 2.4 issue. 
I attached the output of emerge info, just in case that helps capture any
system
differences between your situation and mine.