{"id":773,"date":"2017-03-20T18:39:42","date_gmt":"2017-03-20T10:39:42","guid":{"rendered":"http:\/\/www.sulabs.net\/?p=773"},"modified":"2017-03-20T18:42:06","modified_gmt":"2017-03-20T10:42:06","slug":"centos-7%e5%86%85%e6%a0%b8%e6%ba%90%e7%a0%81%e5%8c%85kernel-src-rpm%e4%bf%ae%e6%94%b9%e6%89%93%e8%a1%a5%e4%b8%81%e5%92%8c%e7%bc%96%e8%af%91","status":"publish","type":"post","link":"https:\/\/www.sulabs.net\/?p=773","title":{"rendered":"CentOS 7\u5185\u6838\u6e90\u7801\u5305(kernel.src.rpm)\u7684\u4fee\u6539\u548c\u6253\u8865\u4e01\u7f16\u8bd1"},"content":{"rendered":"<p>&nbsp; &nbsp; &nbsp;\u5728\u67d0\u4e9b\u7279\u5b9a\u5e94\u7528\u73af\u5883\u4e2d\uff0c\u6211\u4eec\u4f1a\u6d89\u53ca\u5230Linux\u5185\u6838\u7684\u6e90\u7801\u4fee\u6539\u548c\u7f16\u8bd1\u5b89\u88c5\uff0c\u901a\u5e38\u662f\u9009\u62e9\u4ecekernel.org\u83b7\u53d6\u6700\u65b0\u7684\u7a33\u5b9a\u53d1\u884c\u7248\u5185\u6838\u8fdb\u884c\u4fee\u6539\u5e76\u7f16\u8bd1\u5b89\u88c5\uff0c\u4f46\u5b9e\u9645\u60c5\u51b5\u4e2d\uff0cCentOS\u7684\u5185\u6838\u662f\u57fa\u4e8e\u5b98\u65b9\u5185\u6838\u505a\u4e86\u4e00\u4e9b\u5b9a\u5236\u88c1\u526a\u7684\uff0c\u9009\u7528CentOS\u7684\u5185\u6838\u6e90\u7801\u5305\u505a\u4e00\u4e9b\u9002\u5e94\u6027\u4fee\u6539\uff0c\u91cd\u7f16\u8bd1\u6253\u5305\u6210RPM\u505a\u5206\u53d1\u4f1a\u66f4\u9002\u5408\u751f\u4ea7\u9700\u8981\uff0c\u56e0\u6b64\u8bb0\u5f55\u4e0b\u6e90\u7801\u5305kernel.src.rpm\u7684\u6253\u8865\u4e01\u548c\u91cd\u7f16\u8bd1\u8fc7\u7a0b\u3002<br \/>\n<!--more--><\/p>\n<pre class=\"brush: shell; gutter: true\">[root@localhost ~]#uname -a\r\nLinux localhost 3.10.0-327.36.3.el7.x86_64 #1 SMP Mon Oct 24 16:09:20 UTC 2016 x86_64 x86_64 x86_64 GNU\/Linux<\/pre>\n<p>\/\/\u83b7\u53d6\u5f53\u524d\u7cfb\u7edf\u7684\u5185\u6838\u7248\u672c\u53f7<\/p>\n<pre class=\"brush: shell; gutter: true\">[root@localhost ~]# cat \/etc\/redhat-release \r\nCentOS Linux release 7.2.1511 (Core)&amp;nbsp;<\/pre>\n<p>\/\/\u83b7\u53d6\u5f53\u524d\u7cfb\u7edf\u7684\u53d1\u884c\u7248\u672c\u53f7<\/p>\n<pre class=\"brush: shell; gutter: true\">[root@localhost ~]# wget http:\/\/vault.centos.org\/7.2.1511\/updates\/Source\/SPackages\/kernel-3.10.0-327.22.2.el7.src.rpm<\/pre>\n<p>\/\/\u4ecehttp:\/\/valut.centos.org \u83b7\u53d6\u5bf9\u5e94\u7248\u672c\u5185\u6838src\u6e90\u7801\u5305\u5e76\u4e0b\u8f7d\uff0c\u8fd9\u91cc\u4ee5kernel-3.10.0-327.22.2.el7.src.rpm\u4e3a\u4f8b.<\/p>\n<pre class=\"brush: shell; gutter: true\">[root@localhost ~]# rpm -ivh kernel-3.10.0-327.36.3.el7.src.rpm<\/pre>\n<p>\/\/\u5b89\u88c5\u6e90\u7801\u5305,\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a rpmbuild \u6587\u4ef6\u5939<\/p>\n<p>\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u4e00\u4e0b\u63d0\u793a,builder\u7528\u6237\u540d\u548c\u7ec4\u4e0d\u5b58\u5728\u63d0\u793a\u53ef\u4ee5\u5ffd\u7565,\u5b98\u65b9\u7684\u6e90\u7801\u5305\u662f\u5728builder\u7528\u6237\u4e0b\u6784\u5efa\u7684.<br \/>\nwarning: user builder does not exist - using root<br \/>\nwarning: group builder does not exist - using root<\/p>\n<pre class=\"brush: shell; gutter: true\">[root@localhost ~]# yum install wget gcc gc bc gd make perl ncurses-devel xz rpm-build xmlto asciidoc hmaccalc python-devel \\\r\nnewt-devel pesign binutils-devel audit-libs-devel numactl-devel pciutils-devel perl-ExtUtils-Embed -y<\/pre>\n<p>\/\/\u4e3a\u907f\u514d\u7f16\u8bd1\u7f3a\u5c11\u5bf9\u5e94\u7684\u4f9d\u8d56\u5305\u5934\u6587\u4ef6\u548c\u5de5\u5177\uff0c\u4f7f\u7528yum\u5b89\u88c5\u6784\u5efa\u7f16\u8bd1\u6240\u9700\u7684\u5de5\u5177<\/p>\n<p>\u5728\u4f7f\u7528rpmbuild \u81ea\u52a8\u6784\u5efa\u5185\u6838rpm\u5305\u65f6,\u9996\u5148\u8bfb\u53d6SEPCS\u76ee\u5f55\u4e0b\u7684kernel.spec \u914d\u7f6e\u6587\u4ef6\uff0c\u89e3\u538bSOURCES \u76ee\u5f55\u4e2d\u7684\u5185\u6838\u6e90\u7801\u5305,\u5e76\u6253\u4e0a\u5bf9\u5e94\u7684patch \u6587\u4ef6, \u914d\u7f6e\u540e\u8fdb\u884c\u7f16\u8bd1\u751f\u6210rpm\u5305, \u56e0\u6b64\u4fee\u6539\u5185\u6838\u6e90\u7801\u67092\u79cd\u65b9\u5f0f\u3002<br \/>\n<span style=\"color: #ff0000;\">1. \u76f4\u63a5\u89e3\u538b\u5185\u6838tar.xz\u5305,\u4fee\u6539\u7f16\u8f91\u5b8c\u6210\u540e\u76f4\u63a5\u6253\u5305\u8986\u76d6\u539f\u6709\u7684tar.zx\u5305\uff0c\u6267\u884crpmbuild\u547d\u4ee4\u6784\u5efa.<\/span><br \/>\n<span style=\"color: #008000;\">2. \u89e3\u538b\u5185\u6838tar.zx\u5305,\u5907\u4efd\u9700\u8981\u4fee\u6539\u7684\u6e90\u6587\u4ef6,\u4fee\u6539\u540e\u5bf9\u6bd4\u6e90\u6587\u4ef6\u751f\u6210patch\u8865\u4e01,\u5e76\u5728kernel.spec\u914d\u7f6e\u4e2d\u6307\u5b9a\u8865<\/span><br \/>\n<span style=\"color: #008000;\">&nbsp; &nbsp;\u4e01\u6587\u4ef6,\u6267\u884crpmbuild\u6784\u5efa<\/span><\/p>\n<p>\u7b2c\u4e00\u79cd\u65b9\u5f0f\u89e3\u538b\u6253\u5305\u6bd4\u8f83\u7e41\u7410\uff0c\u4e0d\u5982\u5236\u4f5cpatch\u8865\u4e01\u6765\u7684\u65b9\u4fbf,\u5728\u5927\u7248\u672c\u4e0d\u53d8\u7684\u60c5\u51b5\u4e0b\u53ea\u9700\u8981\u5f15\u5165patch\u6587\u4ef6\u5373\u53ef,\u901a\u7528\u6027\u66f4\u597d.\u63a8\u8350\u4f7f\u7528<\/p>\n<pre class=\"brush: shell; gutter: true\">[root@localhost ~]# cd rpmbuild\/SOURCES\/\r\n[root@localhost SOURCES]# tar -xf linux-3.10.0-327.36.3.el7.tar.xz -C \/tmp<\/pre>\n<p>\/\/\u89e3\u538b\u5185\u6838\u6e90\u7801\u5305\u5230 \/tmp\u4e0b<\/p>\n<p>\u8fd9\u91cc\u4ee5\u4fee\u6539TCP\u53c2\u6570\u5934\u6587\u4ef6tcp.h\u4e3a\u4f8b<\/p>\n<pre class=\"brush: shell; gutter: true\">[root@localhost ~]# cd \/tmp\/linux-3.10.0-327.36.3.el7\/include\/net\r\n[root@localhost net]# cp tcp.h tcp_orig.h<\/pre>\n<p>\/\/\u8fdb\u5165\u9700\u8981\u4fee\u6539\u7684\u6587\u4ef6\u76ee\u5f55,\u5907\u4efd\u6e90\u6587\u4ef6\u4e3atcp_orig.h<\/p>\n<p>\u6b64\u65f6\u53ef\u5bf9tcp.h \u8fdb\u884c\u53c2\u6570\u4fee\u6539,\u5b8c\u6210\u540e\uff0c\u5728\u5185\u6838\u6e90\u7801\u5305\u6839\u8def\u5f84\u4e0b\uff0c\u4f7f\u7528diff\u751f\u6210patch\u8865\u4e01\u6587\u4ef6<\/p>\n<pre class=\"brush: shell; gutter: true\">[root@localhost ~]# cd \/tmp\/linux-3.10.0-327.36.3.el7\/\r\n[root@localhost linux-3.10.0-327.36.3.el7]# diff -up include\/net\/tcp_orig.h include\/net\/tcp.h &gt;&gt; \/tmp\/custom.patch<\/pre>\n<p>\/\/\u751f\u6210patch\u6587\u4ef6, \u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3a\u539f\u59cb\u6587\u4ef6,\u7b2c\u4e8c\u4e2a\u4e3a\u4fee\u6539\u540e\u7684\u6587\u4ef6<\/p>\n<p><span style=\"color: #ff0000;\">\u5982\u9700\u8981\u5bf9\u6587\u4ef6\u5939\u4e0b\u5927\u91cf\u6587\u4ef6\u4fee\u6539,\u53ef\u4ee5\u5148\u5907\u4efd\u76ee\u5f55\u540e\u4fee\u6539\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u751f\u6210\u6279\u91cf\u6587\u4ef6\u8865\u4e01<\/span><br \/>\n<span style=\"color: #ff0000;\">diff -uprN include_orig\/net include\/net &gt;&gt; \/tmp\/custom.patch<br \/>\n<\/span><\/p>\n<pre class=\"brush: shell; gutter: true\">[root@localhost ~] cp \/tmp\/custom.patch \/root\/rpmbuild\/SOURCES\/<\/pre>\n<p>\/\/\u5c06patch\u8865\u4e01\u590d\u5236\u5230rpmbuild\u6e90\u7801\u5305\u76ee\u5f55<\/p>\n<pre class=\"brush: shell; gutter: true\">[root@localhost ~] vim \/root\/rpmbuild\/SPECS\/kernel.spec<\/pre>\n<p>\/\/\u7f16\u8f91spec\u914d\u7f6e\u6587\u4ef6<\/p>\n<p>\u67e5\u627eApplyOptionPatch\u5f00\u5934\u7684\u884c,\u65b0\u589e\u4e00\u884c\u81ea\u5b9a\u4e49\u8865\u4e01<br \/>\nApplyOptionalPatch linux-kernel-test.patch<br \/>\nApplyOptionalPatch debrand-single-cpu.patch<br \/>\nApplyOptionalPatch debrand-rh_taint.patch<br \/>\nApplyOptionalPatch debrand-rh-i686-cpu.patch<br \/>\n<span style=\"color: #ff0000;\">ApplyOptionalPatch custom.patch<\/span><\/p>\n<p>\u7ee7\u7eed\u67e5\u627ePatch1\u5f00\u5934\u7684\u884c\uff0c\u589e\u52a0\u4e00\u884c\u81ea\u5b9a\u4e49\u8865\u4e01,Patch\u540e\u9762\u7684\u6570\u5b57\u4e3a\u4f18\u5148\u7ea7,\u53ef\u4ee5\u81ea\u5b9a\u4e49.<br \/>\n# empty final patch to facilitate testing of kernel patches<br \/>\nPatch999999: linux-kernel-test.patch<br \/>\nPatch1000: debrand-single-cpu.patch<br \/>\nPatch1001: debrand-rh_taint.patch<br \/>\nPatch1002: debrand-rh-i686-cpu.patch<br \/>\n<span style=\"color: #ff0000;\">Patch4000: custom.patch<\/span><\/p>\n<p>\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5c06custom.patch \u548c kernel.spec \u6587\u4ef6\u4fdd\u7559\u4f5c\u5907\u7528\u3002<\/p>\n<pre class=\"brush: shell; gutter: true\">[root@localhost ~] cd ~\/rpmbuild\/SPECS\r\n\/\/\u8fdb\u5165spec\u914d\u7f6e\u6587\u4ef6\u5939.<\/pre>\n<pre class=\"brush: shell; gutter: true\">[root@localhost rpmbuild] rpmbuild -bb --target=$(uname -m) SPECS\/kernel.spec<\/pre>\n<p>\/\/\u4f7f\u7528rpmbuild -bb \u547d\u4ee4\u76f4\u63a5\u6784\u5efa\u4e8c\u8fdb\u5236rpm\u5b89\u88c5\u5305\uff0c\u4f1a\u81ea\u52a8\u89e3\u538b\u5185\u6838\u81f3BUILDS\u6587\u4ef6\u5939\uff0c\u5e76\u6839\u636ekernel.spec\u914d\u7f6e\u6253\u8865\u4e01\u7b49\u64cd\u4f5c\uff0c\u7b49\u5f85\u7ed3\u675f\uff0c\u4f1a\u5728RPMS\u76ee\u5f55\u4e2d\u751f\u6210\u4fee\u6539\u5b8c\u6210\u540e\u7684RPM\u5305\uff0c\u5c06\u5305\u590d\u5236\u5230\u76ee\u6807\u670d\u52a1\u5668\u6267\u884c<br \/>\nrpm -Uvh&nbsp;kernel-3.10.0-327.36.3.el7.x86_64.rpm \u91cd\u542f\u5e76\u8fdb\u884c\u9a8c\u8bc1.<br \/>\n<span style=\"color: #ff0000;\">\u786c\u4ef6\u914d\u7f6e\u5bf9\u5185\u6838\u7f16\u8bd1\u65f6\u95f4\u5f71\u54cd\u8f83\u5927\uff0c\u4ece\u51e0\u5341\u5206\u949f\u751a\u81f3\u51e0\u4e2a\u5c0f\u65f6\uff0c\u5efa\u8bae\u4f7f\u7528i7\u7ea7\u522b\u4ee5\u4e0a\u7684\u591a\u6838CPU\u63d0\u9ad8\u6548\u7387\u3002<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; &nbsp; &nbsp;\u5728\u67d0\u4e9b\u7279\u5b9a\u5e94\u7528\u73af\u5883\u4e2d\uff0c\u6211\u4eec\u4f1a\u6d89\u53ca\u5230Lin &hellip;<\/p>\n<p class=\"read-more\"><a href=\"https:\/\/www.sulabs.net\/?p=773\">\u7ee7\u7eed\u9605\u8bfb &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[107,109,108],"class_list":["post-773","post","type-post","status-publish","format-standard","hentry","category-linux","tag-kernel","tag-patch","tag-108"],"_links":{"self":[{"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/posts\/773","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=773"}],"version-history":[{"count":3,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/posts\/773\/revisions"}],"predecessor-version":[{"id":776,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/posts\/773\/revisions\/776"}],"wp:attachment":[{"href":"https:\/\/www.sulabs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=773"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}