# [SOLVED]sometimes "unable to calculate linux kernel version"

## at_chaos

Hi,

It seems that linux-info.eclass is not working right. I get always the error: "could not calculate linux kernel verion" but symlinks are set correctly (see below) on some ebuilds

Symlinks are correct and .config + sources are present:

```

# ls -la /usr/src/linux

lrwxrwxrwx 1 root root 22 18. Nov 11:20 /usr/src/linux -> linux-2.6.22-gentoo-r9

# uname -a

Linux localhost 2.6.22-gentoo-r9 #2 SMP Sun Nov 18 12:49:06 CET 2007 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 6000+ AuthenticAMD GNU/Linux

# ls -la /usr/src/linux/

insgesamt 37748

drwxr-xr-x 20 root root     4096 18. Nov 12:49 .

drwxr-xr-x  5 root root     4096 18. Nov 11:36 ..

drwxr-xr-x 28 root root     4096 18. Nov 11:20 arch

drwxr-xr-x  2 root root     4096 18. Nov 11:27 block

-rw-r--r--  1 root root    40354 18. Nov 12:48 .config

-rw-r--r--  1 root root    39527 18. Nov 11:23 .config.old

-rw-r--r--  1 root root    18693  9. Jul 01:32 COPYING

-rw-r--r--  1 root root    91435  9. Jul 01:32 CREDITS

drwxr-xr-x  2 root root     4096 18. Nov 12:49 crypto

<snip>

```

What fails: lm_sensors, truecrypt, nvidia-drivers (all the same error) with "unable to calculate linux kernel version"

```
>>> Emerging (1 of 1) sys-apps/lm_sensors-2.10.4 to /

 * lm_sensors-2.10.4.tar.gz RMD160 SHA1 SHA256 size ;-) ...               [ ok ]

 * checking ebuild checksums ;-) ...                                      [ ok ]

 * checking auxfile checksums ;-) ...                                     [ ok ]

 * checking miscfile checksums ;-) ...                                    [ ok ]

 * checking lm_sensors-2.10.4.tar.gz ;-) ...                              [ ok ]

 * Determining the location of the kernel source code

 * Found kernel source directory:

 *     /usr/src/linux

 * Could not detect kernel version.

 * Please ensure that /usr/src/linux points to a complete set of Linux sources.

 * 

 * ERROR: sys-apps/lm_sensors-2.10.4 failed.

 * Call stack:

 *                  ebuild.sh, line 1717:  Called dyn_setup

 *                  ebuild.sh, line  768:  Called qa_call 'pkg_setup'

 *                  ebuild.sh, line   44:  Called pkg_setup

 *   lm_sensors-2.10.4.ebuild, line   31:  Called linux-info_pkg_setup

 *          linux-info.eclass, line  558:  Called die

 * The specific snippet of code:

 *      get_version || die "Unable to calculate Linux Kernel version"

 *  The die message:

 *   Unable to calculate Linux Kernel version

 * 

 * If you need support, post the topmost build error, and the call stack if relevant.

 * A complete build log is located at '/var/tmp/portage/sys-apps/lm_sensors-2.10.4/temp/build.log'.

 * 

```

BUT all 3 are working now if I do an:

```
export KBUILD_OUTPUT="/usr/src/linux"
```

Any ideas what is broken?

```
# emerge --info

Portage 2.1.3.19 (default-linux/amd64/2007.0/desktop, gcc-4.1.2, glibc-2.6.1-r0, 2.6.22-gentoo-r9 x86_64)

=================================================================

System uname: 2.6.22-gentoo-r9 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 6000+

Timestamp of tree: Sat, 17 Nov 2007 23:16:01 +0000

app-shells/bash:     3.2_p17

dev-java/java-config: 1.3.7, 2.0.33-r1

dev-lang/python:     2.4.4-r6

dev-python/pycrypto: 2.0.1-r6

sys-apps/baselayout: 1.12.9-r2

sys-apps/sandbox:    1.2.18.1-r2

sys-devel/autoconf:  2.13, 2.61-r1

sys-devel/automake:  1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10

sys-devel/binutils:  2.18-r1

sys-devel/gcc-config: 1.3.16

sys-devel/libtool:   1.5.24

virtual/os-headers:  2.6.22-r2

ACCEPT_KEYWORDS="amd64"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-mtune=k8 -O2 -pipe"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/share/X11/xkb"

CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/revdep-rebuild /etc/terminfo /etc/udev/rules.d"

CXXFLAGS="-mtune=k8 -O2 -pipe"

DISTDIR="/usr/portage/distfiles"

FEATURES="distlocks metadata-transfer sandbox sfperms strict unmerge-orphans userfetch"

GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"

LANG="de_DE.UTF-8"

LC_ALL="de_DE.UTF-8"

LINGUAS="de en"

MAKEOPTS="-j3"

PKGDIR="/usr/portage/packages"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --filter=H_**/files/digest-*"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="   "

SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"

USE="X a52 acl acpi alsa amd64 berkdb bitmap-fonts cairo cdr cli cracklib crypt cups dbus divx dri dvd dvdr dvdread eds emboss encode esd evo fam ffmpeg firefox fortran freetype gdbm gif gpm gstreamer gtk hal iconv ipv6 isdnlog jpeg kerberos ldap mad midi mikmod mmx mp3 mpeg mudflap ncurses nls nptl nptlonly nsplugin ogg opengl openmp oss pam pcre pdf perl png pppd python qt3support quicktime readline reflection sdl session spell spl sse sse2 ssl startup-notification svg tcpd tiff truetype truetype-fonts type1 type1-fonts unicode vorbis x264 xml xorg xscreensaver xv xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" ELIBC="glibc" INPUT_DEVICES="keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="de en" USERLAND="GNU" VIDEO_CARDS="nvidia vesa"

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LDFLAGS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

```

----------

## Keruskerfuerst

It should be

```
CFLAGS="-march=k8 -O2 -pipe"
```

I would execute

```
emerge gentoo-sources
```

Last edited by Keruskerfuerst on Wed Nov 21, 2007 9:51 am; edited 1 time in total

----------

## at_chaos

Hi Keruskerfuerst,

thanks for your tip. Unfortunately it did not work. AFAIK are -march and -mtune similar. 

Other ideas?

Danke, ein Versuch war es wert.  :Smile: 

----------

## Keruskerfuerst

```
AFAIK are -march and -mtune similar. 
```

False.

```
# ls -la /usr/src/linux

lrwxrwxrwx 1 root root 22 18. Nov 11:20 /usr/src/linux -> linux-2.6.22-gentoo-r9
```

should be

```
# ls -l /usr/src/

lrwxrwxrwx 1 root root 22 18. Nov 11:20 /usr/src/linux -> linux-2.6.22-gentoo-r9
```

Are the kernel-headers correctly installed?

----------

## at_chaos

 *Keruskerfuerst wrote:*   

> 
> 
> ```
> AFAIK are -march and -mtune similar. 
> ```
> ...

 

GCC Manual says:

 *Quote:*   

> -march=cpu-type
> 
>     Generate instructions for the machine type cpu-type. The choices for cpu-type are the same as for -mtune. Moreover, specifying -march=cpu-type implies -mtune=cpu-type.
> 
> -mcpu=cpu-type
> ...

 

See: http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/i386-and-x86_002d64-Options.html#i386-and-x86_002d64-Options

But ok, does not matter. Did not solve the problem.

 *Quote:*   

> 
> 
> ```
> # ls -la /usr/src/linux
> 
> ...

 

???

You list the whole /usr/src directory and I list only the symlink /usr/src/linux .. both are the same - the point of view is different. The symlink is not the problem.

 *Quote:*   

> 
> 
> Are the kernel-headers correctly installed?

 

I think so. How can I check if they are not correctly installed?

Thank you.

----------

## Keruskerfuerst

Does this problem occur every time, you want to compile a kernel?

----------

## at_chaos

Hi,

sorry if it is not clear enough. As I described above the kernel compiles fine. What fails are packages such as lm_sensors, nvidida-drivers and truecrypt. They are not able to calculate the kernel version although symlinks are correct and kernel sources are there. See failure notice above.

Greets,

Andy

----------

## at_chaos

omg, 

shame on me... I played with xen and forgot to remove one important line after switching back to gentoo-sources. In /etc/make.conf I forgot to remove the line which switches KBUILD_OUTPUT to /usr/src/linux/_dom0   :Embarassed: 

sorry, solved.

Greets,

Andy

----------

## PiBis

@at_chaos 

You know what? The same here!!! Thanks for posting!

----------

