分类: LINUX
2011-04-19 09:08:49
1、配置环境
注:编译SRPM内核的空余空间最少需要8G,否则会硬盘空间会耗尽;无法开机
1>安装一些需要的工具包
su -c 'yum install rpmdevtools yum-utils'
2>下载内核的SRPM包
yumdownloader --source kernel
3>使用 yum-builddep命令建立内核SRPM包依赖的环境
su -c 'yum-builddep kernel-
4>安装 kernel-
Rpm -Uvh kernel-
需要注意的:它会安装到现在使用用户的${home}目录下面 ${HOME}/rpmbuild/SOURCES and ${HOME}/rpmbuild/SPECS
在安装过程中会提示忽略安全的信息:
warning: user kojibuilder does not exist - using root
warning: group kojibuilder does not exist - using root
2、配置文件和打补丁
cd ~/rpmbuild/SPECS
rpmbuild -bp --target=$(uname -m) kernel.spec
这里主要初始化编译内核环境、配置内核配置文件、给内核打补丁;
3、编译内核
rpmbuild -ba --target=$(uname -m) kernel.spec
动态生成内核config
1277 # Dynamically generate kernel .config files from config-* files
1278 make -f %{SOURCE20} VERSION=%{version} configs
SOURCE20:Makefile.config
%{version}:内核的版本
Configs :配置Makefile.config
需要文件在SOURCE目录:config-* 、Makefile.config 、merge.pl ;
Config文件生成的整个过程是在Makefile.config完成的, 使用merge.pl 动态生成每个体系架构的config文件;会把config-* 文件转换成我们需要的kernel-
整个i686架构config 生成的过程:
cat config-generic config-nodebug > temp-generic
perl merge.pl config-x86-generic temp-generic > temp-x86-generic
perl merge.pl /dev/null temp-x86-generic i386 > kernel-2.6.34.8-i686.config
cat config-generic config-debug > temp-debug-generic
perl merge.pl config-x86-generic temp-debug-generic > temp-x86-debug-generic
perl merge.pl /dev/null temp-x86-debug-generic i386 > kernel-2.6.34.8-i686-debug.config
perl merge.pl config-i686-PAE temp-x86-generic i386 > kernel-2.6.34.8-i686-PAE.config
配置:kernel-
配置:kernel-
配置:kernel-
配置:kernel-
结束生成config文件后,在kernel.SPEC 文件的1708行 创建configs文件
通过比较target指定的结构体config,移入configs文件中,并删除无关架构config文件;
其他架构config生成的流程:
cat config-generic config-nodebug > temp-generic
perl merge.pl config-x86-generic temp-generic > temp-x86-generic
perl merge.pl /dev/null temp-x86-generic i386 > kernel-2.6.34.8-i686.config
cat config-generic config-debug > temp-debug-generic
perl merge.pl config-x86-generic temp-debug-generic > temp-x86-debug-generic
perl merge.pl /dev/null temp-x86-debug-generic i386 > kernel-2.6.34.8-i686-debug.config
perl merge.pl config-i686-PAE temp-x86-generic i386 > kernel-2.6.34.8-i686-PAE.config
perl merge.pl config-i686-PAE temp-x86-debug-generic i386 > kernel-2.6.34.8-i686-PAEdebug.config
perl merge.pl config-x86_64-generic temp-generic > temp-x86_64-generic
perl merge.pl /dev/null temp-x86_64-generic x86_64 > kernel-2.6.34.8-x86_64.config
perl merge.pl config-x86_64-generic temp-debug-generic > temp-x86_64-debug-generic
perl merge.pl /dev/null temp-x86_64-debug-generic x86_64 > kernel-2.6.34.8-x86_64-debug.config
perl merge.pl config-s390x temp-generic > temp-s390-generic
perl merge.pl config-s390x temp-s390-generic s390 > kernel-2.6.34.8-s390x.config
perl merge.pl config-arm temp-generic arm > kernel-2.6.34.8-arm.config
perl merge.pl config-powerpc-generic temp-generic > temp-powerpc-generic
perl merge.pl config-powerpc32-generic temp-powerpc-generic > temp-powerpc32-generic
perl merge.pl /dev/null temp-powerpc32-generic powerpc > kernel-2.6.34.8-ppc.config
perl merge.pl config-powerpc32-smp temp-powerpc32-generic powerpc > kernel-2.6.34.8-ppc-smp.config
perl merge.pl config-sparc64-generic temp-generic > temp-sparc64-generic
perl merge.pl /dev/null temp-sparc64-generic sparc64 > kernel-2.6.34.8-sparc64.config
perl merge.pl config-powerpc64 temp-powerpc-generic powerpc > kernel-2.6.34.8-ppc64.config
perl merge.pl config-powerpc-generic temp-debug-generic > temp-powerpc-debug-generic
perl merge.pl config-powerpc64 temp-powerpc-debug-generic powerpc > kernel-2.6.34.8-ppc64-debug.config
perl merge.pl config-ia64-generic temp-generic > temp-ia64-generic
perl merge.pl /dev/null temp-ia64-generic ia64 > kernel-2.6.34.8-ia64.config