1.安装依赖
代码语言:javascript复制yum install -y gcc bison patchutils rpm-build redhat-rpm-config asciidoc hmaccalc perl-ExtUtils-Embed pesign xmlto audit-libs-devel binutils-devel elfutils-devel elfutils-libelf-devel ncurses-devel newt-devel numactl-devel pciutils-devel python-devel zlib-devel
2.创建内核源码树
代码语言:javascript复制mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
3.获取当前内核版本
代码语言:javascript复制uname -r
==>
2.6.32-431.el6.x86_64
4.获取内核源码rpm包
http://vault.centos.org/6.5/os/Source/SPackages/kernel-2.6.32-431.el6.src.rpm
备注:如果内核版本有小版本补丁,则对应地址为:
http://vault.centos.org/6.5/updates/Source/SPackages/
5.安装rpm至目录树
代码语言:javascript复制rpm -i kernel-2.6.32-431.el6.src.rpm 2>&1 | grep -v exist
cd ~/rpmbuild/SPECS
rpmbuild -bp --target=$(uname -m) kernel.spec
经过几分钟后内核源码应该在:
代码语言:javascript复制~/rpmbuild/BUILD/kernel-2.6.32-431.el6