# sources have not yet been prepared?

## BillWho

This is a new one for me   :Rolling Eyes: 

I compiled 3.7-rc1 first using make oldconfig from -3.6-rc7 kernel .config file. The kernel built fine as listed in /boot

```
-rw-r--r-- 1 root root 3973920 Oct 16 11:13 kernel-genkernel-x86_64-3.7.0-rc1
```

Then I emerged x11-drivers/ati-drivers and received this error:

```
 * Messages for package x11-drivers/ati-drivers-12.9:

 * These sources have not yet been prepared.

 * We cannot build against an unprepared tree.

 * To resolve this, please type the following:

 * 

 * # cd /usr/src/linux

 * # make oldconfig

 * # make modules_prepare

```

I got the same error attempting to emerge app-emulation/virtualbox-modules. I tried make modules_prepare, which I never had to do before, but it didn't make any difference.

Anyone else here encounter this or any suggestions on how to correct this   :Question:   I didn't see any bugs written on this....

Thanks

----------

## Thistled

Could it have something to do with linux-headers?

----------

## BillWho

 *Thistled wrote:*   

> Could it have something to do with linux-headers?

 

I guess anything is possible   :Very Happy: 

This is what I have;

```
bill@gentoo-gateway ~/script $ equery l -p linux-headers

 * Searching for linux-headers ...

[-P-] [ -] sys-kernel/linux-headers-2.4.33.3:0

[-P-] [ -] sys-kernel/linux-headers-2.4.36:0

[-P-] [  ] sys-kernel/linux-headers-3.1:0

[-P-] [  ] sys-kernel/linux-headers-3.2-r1:0

[-P-] [  ] sys-kernel/linux-headers-3.3:0

[-P-] [  ] sys-kernel/linux-headers-3.4:0

[-P-] [  ] sys-kernel/linux-headers-3.4-r1:0

[-P-] [  ] sys-kernel/linux-headers-3.4-r2:0

[-P-] [  ] sys-kernel/linux-headers-3.5:0

[IP-] [  ] sys-kernel/linux-headers-3.6:0

```

If there's supposed to be a 3.7 version it's not there   :Confused: 

----------

## Hu

 *Thistled wrote:*   

> Could it have something to do with linux-headers?

 Although possible, that seems very unlikely for this error message.

OP: what is the output of ls -l /usr/src/?  Did you build the kernel in-tree or out-of-tree (good)?  If out-of-tree, have you set the Portage environment and filesystem permissions such that Portage can find and access the generated objects?

----------

## BillWho

 *Hu wrote:*   

>  *Thistled wrote:*   Could it have something to do with linux-headers? Although possible, that seems very unlikely for this error message.
> 
> OP: what is the output of ls -l /usr/src/?  Did you build the kernel in-tree or out-of-tree (good)?  If out-of-tree, have you set the Portage environment and filesystem permissions such that Portage can find and access the generated objects?

 

Hu, 

Thanks for looking - here's the requested info:

```
chroot to ->(gentoo) # ls -lh

total 2.3M

lrwxrwxrwx  1 root root   13 Oct 16 22:33 linux -> linux-3.7-rc1/

drwxr-xr-x 26 root root 4.0K Sep 18 18:43 linux-3.6-rc6/

drwxr-xr-x 26 root root 4.0K Sep 27 13:47 linux-3.6-rc7/

drwxr-xr-x 26 root root 4.0K Oct 16 11:45 linux-3.7-rc1/

drwxrwxr-x  4 root root 4.0K Nov 20  2011 testdisk-6.13/

-rw-r--r--  1 root root 2.3M Nov 15  2011 testdisk-6.13.linux26.tar.bz2

```

I've always built the kernel the same way -  i.e. set the symlink with eselect kernel set 3, copy the previous .config and make oldconfig, Then

```
cat /home/bill/script/mkkernel

#!/bin/bash

#

genkernel  --kernel-config=/usr/src/linux/.config --mountboot --install --symlink all

#

emerge x11-drivers/ati-drivers

#

emerge app-emulation/virtualbox-modules

#

module-rebuild populate

```

Nothing was done different here so that's why it got me a little confused   :Confused: 

----------

## unitstep

Hi!

I'm getting the same errors trying to compile external modules for 3.7-rc1. 

The error seems to come from the following function in: /usr/portage/eclass/linux-info.eclass

```

...

# @FUNCTION: check_kernel_built

# @DESCRIPTION:

# This function verifies that the current kernel sources have been already prepared otherwise it dies.

check_kernel_built() {

   # if we haven't determined the version yet, we need to

   require_configured_kernel

   get_version

   if [ ! -f "${KV_OUT_DIR}/include/linux/version.h" ]

   then

      eerror "These sources have not yet been prepared."

      eerror "We cannot build against an unprepared tree."

      eerror "To resolve this, please type the following:"

      eerror

      eerror "# cd ${KV_DIR}"

      eerror "# make oldconfig"

      eerror "# make modules_prepare"

      eerror

      eerror "Then please try merging this module again."

      die "Kernel sources need compiling first"

   fi

}

...

```

As can be seen, the function is checking for the file "include/linux/version.h". However, in the 3.7 kernel, this file seems to have moved to "include/generated/uapi/linux/version.h"

So, the question is what is a good solution to solve this?

Edit: Here are the commits moving it to its current path:

UAPI: Plumb the UAPI Kbuilds into the user header installation and checking

UAPI: Move linux/version.h

----------

## BillWho

unitstep,

Coincidentally I just discovered this in linux-info-eclass   :Very Happy: 

```
root@gentoo-gateway linux # pwd

/lib/modules/3.7.0-rc1/build/include/linux

root@gentoo-gateway linux # ls version.h

ls: cannot access version.h: No such file or directory

```

It's there for 3.6-rc7

```
root@gentoo-gateway linux # pwd

/usr/src/linux-3.6-rc7/include/linux

root@gentoo-gateway linux # ls version.h 

version.h

```

I got passed that error by changing the line to if [ ! -f "${KV_OUT_DIR}/include/generated/uapi/linux/version.h" ], but it failed further on   :Crying or Very sad: 

Since this error will propagate soon, I'll stay with 3.6-rc7 for now and just wait it out.

UPDATE: I also tried a symlink ln -s .././generated/uapi/linux/version.h version.h and it failed the same as when I modified the path   :Crying or Very sad: 

----------

## petlab

I am trying to emerge git-sources-3.7_rc1.. My first problem was needing a simple patch from lkml: [PATCH] Make uapi/linux/irqnr.h non-empty oh, and now I see the rest of that thread.  It seems unrelated to our out-of-tree error tho.

I am also using a kernel-patch type ebuild.  sys-fs/aufs3-3_p20121015.  I am getting the "Kernel sources need compiling first" and also can't resolve it.  I tried  making modules_prepare / prepare / all, as well as a "genkernel all" before emerging this ebuild.

Has anyone found or filed a bug for this?

Stuff below.

```
# emerge -pv aufs3 git-sources linux-headers genkernel

Calculating dependencies... done!

[ebuild     U ~] sys-kernel/linux-headers-3.6 [3.4-r2] 5,145 kB

[ebuild   R   ~] sys-kernel/git-sources-3.7_rc1  USE="-build -symlink" 0 kB

[ebuild     U ~] sys-fs/aufs3-3_p20121015 [3_p20120813] USE="inotify kernel-patch ramfs -debug -doc -fuse -hfs -nfs -pax_kernel" 0 kB

[ebuild     U ~] sys-kernel/genkernel-3.4.44.2 [3.4.24_p2] USE="crypt%* -cryptsetup% (-ibm) (-selinux)" 424 kB

[blocks B      ] <sys-apps/openrc-0.9.9 ("<sys-apps/openrc-0.9.9" is blocking sys-kernel/genkernel-3.4.44.2)

```

```
Portage 2.2.0_alpha121_p31 (default/linux/amd64/10.0/desktop/kde, gcc-4.6.3, glibc-2.15-r2, 3.6.0-rc1aufs3 x86_64)

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

System uname: Linux-3.6.0-rc1aufs3-x86_64-AMD_Phenom-tm-_II_X6_1100T_Processor-with-gentoo-2.2

Timestamp of tree: Wed, 17 Oct 2012 11:00:01 +0000

app-shells/bash:          4.2_p37

dev-java/java-config:     2.1.11-r3

dev-lang/python:          2.7.3-r2, 3.2.3

dev-util/cmake:           2.8.9

dev-util/pkgconfig:       0.27.1

sys-apps/baselayout:      2.2

sys-apps/openrc:          0.9.8.4

sys-apps/sandbox:         2.5

sys-devel/autoconf:       2.13, 2.68

sys-devel/automake:       1.9.6-r3, 1.11.6

sys-devel/binutils:       2.22-r1

sys-devel/gcc:            4.5.4, 4.6.3

sys-devel/gcc-config:     1.7.3

sys-devel/libtool:        2.4-r1

sys-devel/make:           3.82-r3

sys-kernel/linux-headers: 3.4-r2 (virtual/os-headers)

sys-libs/glibc:           2.15-r2

Repositories: gentoo x11 rion mozilla zugaina mv ykill

ACCEPT_KEYWORDS="amd64"

ACCEPT_LICENSE="*"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-fgraphite-identity -floop-block -floop-interchange -floop-strip-mine -ftree-loop-distribution -march=native -mtune=native -O2 -pipe -DPIC -fPIC"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"

CPPFLAGS="-fgraphite-identity -floop-block -floop-interchange -floop-strip-mine -ftree-loop-distribution -march=native -mtune=native -O2 -pipe"

CXXFLAGS="-fgraphite-identity -floop-block -floop-interchange -floop-strip-mine -ftree-loop-distribution -march=native -mtune=native -O2 -pipe -DPIC -fPIC"

DISTDIR="/usr/portage/distfiles"

EMERGE_DEFAULT_OPTS="--keep-going --autounmask-write"

FCFLAGS="-O2 -pipe"

FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fail-clean fixlafiles news parallel-fetch parallel-install parse-eapi-ebuild-head preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"

FFLAGS="-O2 -pipe"

GENTOO_MIRRORS="gentoo.osuosl.org"

LANG="en_US"

LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-O1 -Wl,--as-needed"

LINGUAS="en en_US"

MAKEOPTS="-j13 -s --no-print-directory"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/var/lib/layman/x11 /var/lib/layman/rion /var/lib/layman/mozilla /var/lib/layman/zugaina /var/lib/layman/mv /var/lib/layman/ykill"

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

USE="X a52 aac acl acpi alsa amd64 berkdb bluetooth branding bzip2 cairo cdda cdr cli consolekit cracklib crypt cups cxx dbus declarative dri dts dvd dvdr emboss encode exif fam firefox flac fortran gdbm gif gpm graphite gtk iconv ipv6 jpeg kde kipi kvm lcms ldap libnotify lm_sensors mad mmx mng modules mp3 mp4 mpeg mudflap multilib mythtv ncurses nls nptl nsplugin ogg opengl openmp pam pango pcre pdf phonon plasma png policykit ppds pppd qt3support qt4 readline samba sdl semantic-desktop session spell sse sse2 ssl startup-notification svg tcpd tiff truetype udev udisks unicode upower usb v4l vorbis wxwidgets x264 xcb xcomposite xinerama xml 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 mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="braindump flow karbon plan stage" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" GRUB_PLATFORMS="pc" INPUT_DEVICES="keyboard mouse evdev joystick" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en en_US" PHP_TARGETS="php5-3" PYTHON_TARGETS="python3_2 python2_7" QEMU_SOFTMMU_TARGETS="i386 ppc ppc64 x86_64" QEMU_USER_TARGETS="arm i386 x86_64" RUBY_TARGETS="ruby18 ruby19" USERLAND="GNU" VIDEO_CARDS="radeon v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"

Unset:  CTARGET, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON

```

----------

## BillWho

petlab,

Welcome to git-sources-3.7_rc1 - it's off to a good start   :Very Happy: 

From your post I see you had some problems that I didn't encounter. The kernel compiled just fine for me with no additional patching required. The first problem I had was with virtualbox-modules.

This afternoon I ran emerge @preserved-rebuild and now xbmc refuses to compile. I didn't dig into it too much, but I have a feeling it's related to the header location change.

To answer your question about filing a bug I didn't file one and I haven't found one at bugzilla.kernel.org or /bugs.gentoo.org/

----------

## Hu

 *BillWho wrote:*   

> Since this error will propagate soon, I'll stay with 3.6-rc7 for now and just wait it out.

 Why are you using 3.6-rc7 when Linus released 3.6 final and GregKH has released two stable kernels beyond that?  I understand if you want to run a 3.7-rc to get the latest code, but 3.6-rc7 is not even the latest version of the 3.6 kernel.

----------

## BillWho

 *Hu wrote:*   

>  *BillWho wrote:*   Since this error will propagate soon, I'll stay with 3.6-rc7 for now and just wait it out. Why are you using 3.6-rc7 when Linus released 3.6 final and GregKH has released two stable kernels beyond that?  I understand if you want to run a 3.7-rc to get the latest code, but 3.6-rc7 is not even the latest version of the 3.6 kernel.

 

Because 3.6_rc7 is the prior git-sources version

----------

## petlab

I was wrong above.  I think the out-of-tree-module ebuilds probably are having problems due to these files moving.  We need an update to the mechanisms that are verifying the source being configured/built or not.  I barely know what I'm talking about here.  Something with version.h files having different locations, and portage not knowing where those are.

I think gentoo devs are going to see this problem quickly, it seems to affect all out-of-tree-module ebuilds.  Sorry I am of no help actually fixing it.

----------

## unitstep

Here is a patch that fixes the build errors for virtualbox-modules-4.2 for me. I don't know if it applies to other versions.

http://pastie.textmate.org/5080461

I found it here, on openSUSE forums.

Edit: You will also need to fix the thing with "sources not prepared". I did that by updating the path in the eclass.

----------

## petlab

There is a problem between portage and the git-tree that seems to be the real issue.  I have emailed the git-sources ebuild maintainer to help triage what to do with this.  I hope this helps.

----------

## unitstep

 *petlab wrote:*   

> There is a problem between portage and the git-tree that seems to be the real issue.  I have emailed the git-sources ebuild maintainer to help triage what to do with this.  I hope this helps.

 

Are you sure? Because I managed to build virtualbox-modules and am running the kernel now:

1) Changing the line in linux-info.eclass

```
if [ ! -f "${KV_OUT_DIR}/include/linux/version.h" ]
```

to

```
if [ ! -f "${KV_OUT_DIR}/include/generated/uapi/linux/version.h" ]
```

2) Creating a local ebuild for virtualbox-modules with the above patch.

Just a dirty fix for the eclass. Which path to check should obviously be conditional, depending on kernel version.

I also had some problems compiling nvidia-drivers-304.51. That could be fixed with the following patch: http://pastie.textmate.org/5081219.

The patch is applying the patch in the first post and removes VM_RESERVED from nv-mmap.c as suggested in the 2nd post: http://www.nvnews.net/vbulletin/showthread.php?t=194465

----------

## petlab

I don't understand your question.  I'm sure that portage needs some fix, if that's what youre getting at.  If your change to linux-info.eclass is the best answer, great.  I think that the "sources not prepared" error was getting confused with other errors that didn't involve portage.

----------

## unitstep

 *petlab wrote:*   

> If your change to linux-info.eclass is the best answer, great.

 

The above change is definetly not the best, since you would get the "sources not prepared" error for kernels prior 3.7 instead. Something like this maybe? 

```

...

check_kernel_built() {

   # if we haven't determined the version yet, we need to

   require_configured_kernel

   get_version

   local versionhpath

   if kernel_is -ge 3 7; then

      versionhpath="include/generated/uapi/linux/version.h"

   else

      versionhpath="include/linux/version.h"

   fi

   if [ ! -f "${KV_OUT_DIR}/${versionhpath}" ]

   then

      eerror "These sources have not yet been prepared."

...

```

 *petlab wrote:*   

> I think that the "sources not prepared" error was getting confused with other errors that didn't involve portage.

 

Agreed, sorry!

----------

## BillWho

unitstep,

Thanks for the patch - worked fine   :Very Happy: 

Just an fyi if you create a symlink from /usr/src/linux/include/linux to ../../include/generated/uapi/linux/version.h that will get past the 'not yet been prepared' error.

I just found out that I have bigger problems with 3.7. I was preparing everything booted to 3.6-rc7. When I booted 3.7 all I get is a gray box and white border with 'input not found' message floating around the screen  :Sad: 

The next challenge   :Very Happy: 

----------

## BillWho

petlab,

Is this the problem you had   :Question: 

```
xen linux # time make && make modules_install && make install

scripts/kconfig/conf --silentoldconfig Kconfig

  SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_32.h

  SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_64.h

  SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_x32.h

  SYSTBL  arch/x86/syscalls/../include/generated/asm/syscalls_32.h

  SYSHDR  arch/x86/syscalls/../include/generated/asm/unistd_32_ia32.h

  SYSHDR  arch/x86/syscalls/../include/generated/asm/unistd_64_x32.h

  SYSTBL  arch/x86/syscalls/../include/generated/asm/syscalls_64.h

  HOSTCC  arch/x86/tools/relocs

  WRAP    arch/x86/include/generated/asm/clkdev.h

  CHK     include/generated/uapi/linux/version.h

  UPD     include/generated/uapi/linux/version.h

  CHK     include/generated/utsrelease.h

  UPD     include/generated/utsrelease.h

  CC      kernel/bounds.s

  GEN     include/generated/bounds.h

  CC      arch/x86/kernel/asm-offsets.s

In file included from include/linux/irq.h:22:0,

                 from /usr/src/linux-3.7-rc1/arch/x86/include/asm/hardirq.h:5,

                 from include/linux/hardirq.h:7,

                 from arch/x86/kernel/asm-offsets.c:11:

include/linux/irqnr.h:4:30: fatal error: uapi/linux/irqnr.h: No such file or directory

compilation terminated.

make[1]: *** [arch/x86/kernel/asm-offsets.s] Error 1

make: *** [prepare0] Error 2

```

This is from another installation using time make && make modules_install && make install.  I didn't run into this with the genkernel version   :Confused: 

----------

## mpagano

Without looking at the eclass, at this point I like unitstep's suggestion.  I need to look deeper to make sure this is all we need, and I don't introduce any regressions.

I will take a look at this over the weekend. 

Thanks,

Mike

----------

## petlab

unitstep,

I applied your change to linux-info.eclass, thanks for that!  However, now it seems the aufs3-3_p20121015 won't patch 3.7-rc1 correctly.. That's not so bad, I might fix that myself.  Such is -git!

----------

## unitstep

Just realized the eclass gets overwritten on emerge --sync. Anyways, I'm sure a fix will come soon!

----------

## petlab

BillWho,

Yes, the first issue I had with 3.7-rc1 was regarding irqnr.h being empty or non-empty.  I applied the patch that filled the file with a comment.  Then the sources would compile.  Later, I tried to emerge aufs3, and had the error regarding sources-not-prepared.

----------

