编译Linux内核时出错

编译Linux内核时出错

我在基于 Ubuntu 的 Elementary OS Luna 上尝试编译 Linux 内核 3.8.0-32 时遇到错误。我有一台联想 S400 笔记本,我使用的命令是:

sudo make-kpkg --initrd --append-to-version=-sergiykhalymonkernel kernel_image kernel_headers

...这导致了以下错误:

exec make kpkg_version=12.036+nmu2 -f /usr/share/kernel-package/ruleset/minimal.mk debian APPEND_TO_VERSION=-sergiykhalymonkernel  INITRD=YES 
====== making target debian/stamp/conf/minimal_debian [new prereqs: ]======
This is kernel package version 12.036+nmu2.
test -d debian             || mkdir debian
test ! -e stamp-building || rm -f stamp-building
install -p -m 755 /usr/share/kernel-package/rules debian/rules
for file in ChangeLog  Control  Control.bin86 config templates.in rules; do                                      \
            cp -f  /usr/share/kernel-package/$file ./debian/;                               \
        done
for dir  in Config docs examples ruleset scripts pkg po;  do                                      \
          cp -af /usr/share/kernel-package/$dir  ./debian/;                                 \
        done
test -f debian/control || sed         -e 's/=V/3.8.13.10-sergiykhalymonkernel/g'  \
                -e 's/=D/3.8.13.10-sergiykhalymonkernel-10.00.Custom/g'         -e 's/=A/amd64/g'  \
        -e 's/=SA//g'  \
        -e 's/=I//g'                    \
        -e 's/=CV/3.8/g'                \
        -e 's/=M/Unknown Kernel Package Maintainer <[email protected]>/g'             \
        -e 's/=ST/linux/g'      -e 's/=B/x86_64/g'    \
                  /usr/share/kernel-package/Control > debian/control
test -f debian/changelog ||  sed -e 's/=V/3.8.13.10-sergiykhalymonkernel/g'       \
            -e 's/=D/3.8.13.10-sergiykhalymonkernel-10.00.Custom/g'        -e 's/=A/amd64/g'       \
            -e 's/=ST/linux/g'     -e 's/=B/x86_64/g'         \
            -e 's/=M/Unknown Kernel Package Maintainer <[email protected]>/g'                            \
             /usr/share/kernel-package/changelog > debian/changelog
chmod 0644 debian/control debian/changelog
test -d ./debian/stamp || mkdir debian/stamp 
make -f debian/rules debian/stamp/conf/kernel-conf
make[1]: Entering directory `/usr/src/linux-headers-3.8.0-32'
====== making target debian/stamp/conf/kernel-conf [new prereqs: ]======
make EXTRAVERSION=.10-sergiykhalymonkernel   ARCH=x86_64 \
                    oldconfig;
make[2]: Entering directory `/usr/src/linux-headers-3.8.0-32'
scripts/kconfig/conf --oldconfig Kconfig
#
# configuration written to .config
#
make[2]: Leaving directory `/usr/src/linux-headers-3.8.0-32'
make EXTRAVERSION=.10-sergiykhalymonkernel   ARCH=x86_64 prepare
make[2]: Entering directory `/usr/src/linux-headers-3.8.0-32'
scripts/kconfig/conf --silentoldconfig Kconfig
make[2]: Leaving directory `/usr/src/linux-headers-3.8.0-32'
make[2]: Entering directory `/usr/src/linux-headers-3.8.0-32'
make[3]: *** No rule to make target `/usr/src/linux-headers-3.8.0-32/arch/x86/syscalls/syscall_32.tbl', needed by `arch/x86/syscalls/../include/generated/uapi/asm/unistd_32.h'.  Stop.
make[2]: *** [archheaders] Error 2
make[2]: Leaving directory `/usr/src/linux-headers-3.8.0-32'
make[1]: *** [debian/stamp/conf/kernel-conf] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.8.0-32'
make: *** [debian/stamp/conf/minimal_debian] Error 2
Failed to create a ./debian directory:  at /usr/bin/make-kpkg line 984.

我已经安装了编译所需的所有软件,但我不知道是什么导致了错误。我该怎么办?谢谢帮助!

更新 我下载了不同的内核,编译得很好。谢谢您的回答!

答案1

我不熟悉 ElementaryOS,但从你的错误来看,我想知道你是否缺少整个源代码树。在我的 Debian/Ubuntu 系统中,我有一个 Makefile

/usr/src/linux-headers-$(uname -r)/arch/x86/syscalls/

Makefile 似乎需要整个源代码树:我仅引用其中几行,

 syscall32 := $(srctree)/$(src)/syscall_32.tbl
 syscall64 := $(srctree)/$(src)/syscall_64.tbl

来证实我的怀疑。

因此,您必须安装整个源代码。您有两种不同的可能性,

  1. 获取内核的源包并重建它
  2. 直接从 kernel.org 获取主线内核并构建它。

答案2

我在 Ubuntu 14.04 上遇到了这个错误,我运行了以下命令并立即解决了该错误:

sudo apt-get install bc

相关内容