centOS 6.4 内核源代码安装

CentOS 6.4 在默认情况下,没有指定源代码仓库。

如果想方便地下载 CentOS 6.4 的内核源代码,可按如下操作进行。

 
1. 进入仓库的目录 cd /etc/yum.repos.d/
2. 创建源代码仓库文件 touch CentOS-Source.repo
3. 将如下内容复制到 CentOS-Source.repo 中
[base-source]
name=CentOS-$releasever - Base Source
baseurl=http://vault.centos.org/6.4/os/Source/
enabled=1
[updates-source]
name=CentOS-$releasever - Updates Source
baseurl=http://vault.centos.org/6.4/updates/Source/
enabled=1
[extras-source]
name=CentOS-$releasever - Extras Source
baseurl=http://vault.centos.org/6.4/extras/Source/
enabled=1
[centosplus-source]
name=CentOS-$releasever - Plus Source
baseurl=http://vault.centos.org/6.4/centosplus/Source/
enabled=1
4. 更新 yum 缓存。
   yum clean all
   yum makecache

5. 这样完成了源代码仓库的添加和启用操作

运行命令:

#yumdownloader --source kernel.x86_64  

下载源代码的rpm包到当前目录

6. create the ‘mockbuild’ user

# useradd -s /sbin/nologin mockbuild

7. As an ordinary user, not root, create a build tree based on a ~/rpmbuild/ directory

[user@host]$ mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
[user@host]$ echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros
 You are strongly advised against package building as root. (see:http://www.owlriver.com/tips/non-root/)

8.To install the source package and tools for CentOS 6:

As root, install the rpm-build, redhat-rpm-config, asciidoc, hmaccalc, perl-ExtUtils-Embed, xmlto, binutils-devel, elfutils-libelf-devel, newt-devel, python-devel and zlib-devel patchutils bison packages:

[root@host]# yum install rpm-build redhat-rpm-config asciidoc hmaccalc perl-ExtUtils-Embed xmlto 
[root@host]# yum install binutils-devel elfutils-libelf-devel newt-devel python-devel zlib-devel  patchutils bison

9.安装rpm packet

rpm -ivh kernel-2.6.32-358.2.1.e16.src.rpm

Now that the source package and tools are installed, unpack and prepare the source files:

[user@host]$ cd ~/rpmbuild/SPECS
[user@host SPECS]$ rpmbuild -bp --target=$(uname -m) kernel.spec

The value of $(uname -m) sets the target to the architecture of your current kernel. This is generally accepted, as most people will need either i686 or x86_64 as the target.

The kernel source tree will now be found under the ~/rpmbuild/BUILD/kernel*/linux*/ directory.



   

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值