From 2081905c43960871fd6db2bb032a59aec80a4417 Mon Sep 17 00:00:00 2001 From: Alex Gronenwoud Date: Thu, 5 Feb 2004 22:17:48 +0000 Subject: Simplifying the second copying of the kernel headers. git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@3229 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689 --- chapter06/chapter06.xml | 2 +- chapter06/kernel-exp-headers.xml | 42 ----------------------- chapter06/kernel-headers.xml | 74 ++++++++++++++++++++++++++++++++++++++++ chapter06/kernel.xml | 70 ------------------------------------- 4 files changed, 75 insertions(+), 113 deletions(-) delete mode 100644 chapter06/kernel-exp-headers.xml create mode 100644 chapter06/kernel-headers.xml delete mode 100644 chapter06/kernel.xml (limited to 'chapter06') diff --git a/chapter06/chapter06.xml b/chapter06/chapter06.xml index 39dc0139a..a9ddc2a71 100644 --- a/chapter06/chapter06.xml +++ b/chapter06/chapter06.xml @@ -296,7 +296,7 @@ file records the bad login attempts. &c6-makedev; -&c6-kernel; +&c6-kernel-headers; &c6-manpages; &c6-glibc; diff --git a/chapter06/kernel-exp-headers.xml b/chapter06/kernel-exp-headers.xml deleted file mode 100644 index 9829fe2c9..000000000 --- a/chapter06/kernel-exp-headers.xml +++ /dev/null @@ -1,42 +0,0 @@ -   - - -Why we copy the kernel headers and don't symlink them - -In the past it was common practice to symlink the -/usr/include/{linux,asm} directories -to /usr/src/linux/include/{linux,asm}. -This was a bad practice, as the following extract from a -post by Linus Torvalds to the Linux Kernel Mailing List points out: - -I would suggest that people who compile new kernels should: - - - not have a single symbolic link in sight (except the one that the - kernel build itself sets up, namely the "linux/include/asm" symlink - that is only used for the internal kernel compile itself) - -And yes, this is what I do. My /usr/src/linux still has the old 2.2.13 -header files, even though I haven't run a 2.2.13 kernel in a _loong_ -time. But those headers were what Glibc was compiled against, so those -headers are what matches the library object files. - -And this is actually what has been the suggested environment for at -least the last five years. I don't know why the symlink business keeps -on living on, like a bad zombie. Pretty much every distribution still -has that broken symlink, and people still remember that the linux -sources should go into "/usr/src/linux" even though that hasn't been -true in a _loong_ time. - -The essential part is where Linus states that the header files should be -the ones which Glibc was compiled against. These are -the headers that should be used when you later compile other packages, as they -are the ones that match the object-code library files. By copying the headers, -we ensure that they remain available if later you upgrade your kernel. - -Note, by the way, that it is perfectly all right to have the kernel sources -in /usr/src/linux, as long as you don't -have the /usr/include/{linux,asm} -symlinks. - - - diff --git a/chapter06/kernel-headers.xml b/chapter06/kernel-headers.xml new file mode 100644 index 000000000..14d73d992 --- /dev/null +++ b/chapter06/kernel-headers.xml @@ -0,0 +1,74 @@ + +Installing Linux-&kernel-version; headers + + +&buildtime; &kernel-time-headers; +&diskspace; &kernel-compsize-headers; + +   + + +Installation of the kernel headers + +We won't be compiling a new kernel yet -- we'll do that when we have +finished the installation of all the packages. But the libraries installed in +the next section need to refer to the kernel header files in order to know how +to interface with the kernel. Instead of unpacking the kernel sources again, +making the version file and the symlinks and so on, we will simply copy the +headers from the temporary tools directory in one swoop: + +cp -a /tools/include/{asm,asm-generic,linux} /usr/include + +A few kernel header files refer to the autoconf.h +header file. Since we have not yet configured the kernel, we need to create +this file ourselves in order to avoid a compilation failure of Sysklogd. +Create an empty autoconf.h file with: + +touch /usr/include/linux/autoconf.h + + + +   + + +Why we copy the kernel headers + +In the past it was common practice to symlink the +/usr/include/{linux,asm} directories +to /usr/src/linux/include/{linux,asm}. +This was a bad practice, as the following extract from a +post by Linus Torvalds to the Linux Kernel Mailing List points out: + +I would suggest that people who compile new kernels should: + + - not have a single symbolic link in sight (except the one that the + kernel build itself sets up, namely the "linux/include/asm" symlink + that is only used for the internal kernel compile itself) + +And yes, this is what I do. My /usr/src/linux still has the old 2.2.13 +header files, even though I haven't run a 2.2.13 kernel in a _loong_ +time. But those headers were what Glibc was compiled against, so those +headers are what matches the library object files. + +And this is actually what has been the suggested environment for at +least the last five years. I don't know why the symlink business keeps +on living on, like a bad zombie. Pretty much every distribution still +has that broken symlink, and people still remember that the linux +sources should go into "/usr/src/linux" even though that hasn't been +true in a _loong_ time. + +The essential part is where Linus states that the header files should be +the ones which Glibc was compiled against. These are +the headers that should be used when you later compile other packages, as they +are the ones that match the object-code library files. By copying the headers, +we ensure that they remain available if later you upgrade your kernel. + +Note, by the way, that it is perfectly all right to have the kernel sources +in /usr/src/linux, as long as you don't +have the /usr/include/{linux,asm} +symlinks. + + + + + diff --git a/chapter06/kernel.xml b/chapter06/kernel.xml deleted file mode 100644 index b90356b67..000000000 --- a/chapter06/kernel.xml +++ /dev/null @@ -1,70 +0,0 @@ - -Installing Linux-&kernel-version; headers - - -&buildtime; &kernel-time-headers; -&diskspace; &kernel-compsize-headers; - -   - - -Installation of the kernel headers - -We won't be compiling a new kernel yet -- we'll do that when we have -finished the installation of all the packages. But as some packages need the -kernel header files, we're going to unpack the kernel archive now, set it up -and copy the header files so they can be found by these packages. - -It is important to note that the files in the kernel source directory -are not owned by root. Whenever you unpack a package as -user root (like we do here inside chroot), the files end -up having the user and group IDs of whatever they were on the packager's -computer. This is usually not a -problem for any other package you install because you remove the source -tree after the installation. But the Linux kernel source tree is often kept -around for a long time, so there's a chance that whatever user ID the packager -used will be assigned to somebody on your machine and then that person would -have write access to the kernel source. - -In light of this, you might want to run chown -R 0:0 -on the linux-&kernel-version; directory -to ensure all files are owned by user root. - -Prepare for header installation: - -make mrproper - -This ensures that the kernel tree is absolutely clean. The kernel team -recommends that this command be issued prior to each kernel -compilation. You shouldn't rely on the source tree being clean after -untarring. - -Create the include/linux/version.h file: - -make include/linux/version.h - -Create the platform-specific include/asm -symlink: - -make symlinks - -Install the platform specific-header files: - -cp -HR include/asm /usr/include -cp -R include/asm-generic /usr/include - -Install the cross-platform kernel header files: - -cp -R include/linux /usr/include - -There are a few kernel header files which make use of the -autoconf.h header file. Since we do not yet configure the -kernel, we need to create this file ourselves in order to avoid compilation -failures. Create an empty autoconf.h file: - -touch /usr/include/linux/autoconf.h - - -&c6-kernel-exp-headers; - - -- cgit v1.2.3-54-g00ecf