环境 RHEL7.2
编译src,这里以igb网卡驱动为例
[root@back rpm]# ls
igb-5.2.15_k-1.el7_2.src.rpm
step1:安装编译环境
网上所有文章都在说怎么编译,没有人说(或者有人说,只是我没有找到)编译环境要安装什么包
yum install gcc rpm-build rpm-devel rpmlint make python bash coreutils diffutils patch rpmdevtools ==这是官方推荐的编译环境
我还安装了如下包
yum install kernel-devel
step2:使用rpm命令安装igb-5.2.15_k-1.el7_2.src.rpm
[root@back rpm]# rpm -ivh igb-5.2.15_k-1.el7_2.src.rpm
Updating / installing...
1:igb-5.2.15_k-1.el7_2 ################################# [100%]
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
这里有一些warning,不用管它,我就用root编译
[root@back ~]# cd rpmbuild/
[root@back rpmbuild]# ls
SOURCES SPECS
这里只建立了两个目录,没有建立RPM等目录,也不用管,之后会自己建立的
step3:执行rpmbuild -bp 命令
[root@back SPECS]# rpmbuild -bp igb.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.FWVIrY
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd /root/rpmbuild/BUILD
+ rm -rf igb-5.2.15_k
+ /usr/bin/bzip2 -dc /root/rpmbuild/SOURCES/igb-5.2.15_k.tar.bz2
+ /usr/bin/tar -xvvf -
drwxrwxr-x poros/poros 0 2015-12-01 16:55 igb-5.2.15_k/
drwxrwxr-x poros/poros 0 2015-12-01 16:55 igb-5.2.15_k/drivers/
drwxrwxr-x poros/poros 0 2015-12-01 16:55 igb-5.2.15_k/drivers/net/
drwxrwxr-x poros/poros 0 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/
drwxrwxr-x poros/poros 0 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/
drwxrwxr-x poros/poros 0 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/
-rw-rw-r-- poros/poros 79052 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_82575.c
-rw-rw-r-- poros/poros 11526 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_82575.h
-rw-rw-r-- poros/poros 46243 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_defines.h
-rw-rw-r-- poros/poros 13152 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_hw.h
-rw-rw-r-- poros/poros 23862 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_i210.c
-rw-rw-r-- poros/poros 3484 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_i210.h
-rw-rw-r-- poros/poros 46510 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_mac.c
-rw-rw-r-- poros/poros 3082 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_mac.h
-rw-rw-r-- poros/poros 11246 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_mbx.c
-rw-rw-r-- poros/poros 3212 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_mbx.h
-rw-rw-r-- poros/poros 20246 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_nvm.c
-rw-rw-r-- poros/poros 1921 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_nvm.h
-rw-rw-r-- poros/poros 69865 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_phy.c
-rw-rw-r-- poros/poros 7100 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_phy.h
-rw-rw-r-- poros/poros 22660 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_regs.h
-rw-rw-r-- poros/poros 87993 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/igb_ethtool.c
-rw-rw-r-- poros/poros 16373 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/igb.h
-rw-rw-r-- poros/poros 6800 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/igb_hwmon.c
-rw-rw-r-- poros/poros 221625 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/igb_main.c
-rw-rw-r-- poros/poros 33386 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/igb_ptp.c
-rw-rw-r-- poros/poros 1392 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/Makefile
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd igb-5.2.15_k
+ /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ set -- drivers
+ mkdir source
+ mv drivers source/
+ mkdir obj
+ exit 0
可以看到,系统自动建立了这几个目录
[root@back rpmbuild]# ls
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
BUILD和BUILDROOT是编译过程中需要的目录,其中BUILDROOT是中间过程目录
RPMS是编译完成后生成的rpm包的存放地址
SOURCES是编译过程在自动解压后,存放解压文件的目录
SPECS目录很重要,是你制作或修改spec文件的存放目录
SRPMS是存放.src.rpm文件的目录
step4:执行rpmbuild -ba命令
[root@back SPECS]# rpmbuild -ba igb.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.GBNCGu
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd /root/rpmbuild/BUILD
+ rm -rf igb-5.2.15_k
+ /usr/bin/bzip2 -dc /root/rpmbuild/SOURCES/igb-5.2.15_k.tar.bz2
+ /usr/bin/tar -xvvf -
drwxrwxr-x poros/poros 0 2015-12-01 16:55 igb-5.2.15_k/
drwxrwxr-x poros/poros 0 2015-12-01 16:55 igb-5.2.15_k/drivers/
drwxrwxr-x poros/poros 0 2015-12-01 16:55 igb-5.2.15_k/drivers/net/
drwxrwxr-x poros/poros 0 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/
drwxrwxr-x poros/poros 0 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/
drwxrwxr-x poros/poros 0 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/
-rw-rw-r-- poros/poros 79052 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_82575.c
-rw-rw-r-- poros/poros 11526 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_82575.h
-rw-rw-r-- poros/poros 46243 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_defines.h
-rw-rw-r-- poros/poros 13152 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_hw.h
-rw-rw-r-- poros/poros 23862 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_i210.c
-rw-rw-r-- poros/poros 3484 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_i210.h
-rw-rw-r-- poros/poros 46510 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_mac.c
-rw-rw-r-- poros/poros 3082 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_mac.h
-rw-rw-r-- poros/poros 11246 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_mbx.c
-rw-rw-r-- poros/poros 3212 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_mbx.h
-rw-rw-r-- poros/poros 20246 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_nvm.c
-rw-rw-r-- poros/poros 1921 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_nvm.h
-rw-rw-r-- poros/poros 69865 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_phy.c
-rw-rw-r-- poros/poros 7100 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_phy.h
-rw-rw-r-- poros/poros 22660 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_regs.h
-rw-rw-r-- poros/poros 87993 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/igb_ethtool.c
-rw-rw-r-- poros/poros 16373 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/igb.h
-rw-rw-r-- poros/poros 6800 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/igb_hwmon.c
-rw-rw-r-- poros/poros 221625 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/igb_main.c
-rw-rw-r-- poros/poros 33386 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/igb_ptp.c
-rw-rw-r-- poros/poros 1392 2015-12-01 16:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/Makefile
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd igb-5.2.15_k
+ /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ set -- drivers
+ mkdir source
+ mv drivers source/
+ mkdir obj
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.cqRFAO
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd igb-5.2.15_k
+ for flavor in default
+ rm -rf obj/default
+ cp -r source obj/default
+ symvers=source/Module.symvers-x86_64
+ '[' -e source/Module.symvers-x86_64 ']'
++ '[' default = default ']'
+ make -C /usr/src/kernels/3.10.0-327.el7.x86_64 M=/root/rpmbuild/BUILD/igb-5.2.15_k/obj/default/drivers/net/ethernet/intel/igb 'NOSTDINC_FLAGS=-I /root/rpmbuild/BUILD/igb-5.2.15_k/obj/default/include'
make: Entering directory `/usr/src/kernels/3.10.0-327.el7.x86_64'
LD /root/rpmbuild/BUILD/igb-5.2.15_k/obj/default/drivers/net/ethernet/intel/igb/built-in.o
CC [M] /root/rpmbuild/BUILD/igb-5.2.15_k/obj/default/drivers/net/ethernet/intel/igb/igb_main.o
CC [M] /root/rpmbuild/BUILD/igb-5.2.15_k/obj/default/drivers/net/ethernet/intel/igb/igb_ethtool.o
CC [M] /root/rpmbuild/BUILD/igb-5.2.15_k/obj/default/drivers/net/ethernet/intel/igb/e1000_82575.o
CC [M] /root/rpmbuild/BUILD/igb-5.2.15_k/obj/default/drivers/net/ethernet/intel/igb/e1000_mac.o
CC [M] /root/rpmbuild/BUILD/igb-5.2.15_k/obj/default/drivers/net/ethernet/intel/igb/e1000_nvm.o
CC [M] /root/rpmbuild/BUILD/igb-5.2.15_k/obj/default/drivers/net/ethernet/intel/igb/e1000_phy.o
CC [M] /root/rpmbuild/BUILD/igb-5.2.15_k/obj/default/drivers/net/ethernet/intel/igb/e1000_mbx.o
CC [M] /root/rpmbuild/BUILD/igb-5.2.15_k/obj/default/drivers/net/ethernet/intel/igb/e1000_i210.o
CC [M] /root/rpmbuild/BUILD/igb-5.2.15_k/obj/default/drivers/net/ethernet/intel/igb/igb_ptp.o
CC [M] /root/rpmbuild/BUILD/igb-5.2.15_k/obj/default/drivers/net/ethernet/intel/igb/igb_hwmon.o
LD [M] /root/rpmbuild/BUILD/igb-5.2.15_k/obj/default/drivers/net/ethernet/intel/igb/igb.o
Building modules, stage 2.
MODPOST 1 modules
CC /root/rpmbuild/BUILD/igb-5.2.15_k/obj/default/drivers/net/ethernet/intel/igb/igb.mod.o
LD [M] /root/rpmbuild/BUILD/igb-5.2.15_k/obj/default/drivers/net/ethernet/intel/igb/igb.ko
make: Leaving directory `/usr/src/kernels/3.10.0-327.el7.x86_64'
+ find obj/default/drivers/net/ethernet/intel/igb -name '*.ko' -type f -exec chmod u+x '{}' +
+ /root/rpmbuild/SOURCES/depmodconf igb 3.10.0-327.el7 obj
+ greylist=source/symbols.greylist-x86_64
+ '[' -f source/symbols.greylist-x86_64 ']'
+ touch source/symbols.greylist
+ '[' -d source/firmware ']'
+ exit 0
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.aee3Dx
+ umask 022
+ cd /root/rpmbuild/BUILD
+ '[' /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64 '!=' / ']'
+ rm -rf /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64
++ dirname /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64
+ mkdir -p /root/rpmbuild/BUILDROOT
+ mkdir /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64
+ cd igb-5.2.15_k
+ export INSTALL_MOD_PATH=/root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64
+ INSTALL_MOD_PATH=/root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64
+ export INSTALL_MOD_DIR=extra/igb
+ INSTALL_MOD_DIR=extra/igb
+ for flavor in default
++ '[' default = default ']'
+ make -C /usr/src/kernels/3.10.0-327.el7.x86_64 modules_install M=/root/rpmbuild/BUILD/igb-5.2.15_k/obj/default/drivers/net/ethernet/intel/igb
make: Entering directory `/usr/src/kernels/3.10.0-327.el7.x86_64'
INSTALL /root/rpmbuild/BUILD/igb-5.2.15_k/obj/default/drivers/net/ethernet/intel/igb/igb.ko
Can't read private key
DEPMOD 3.10.0-327.el7.x86_64
depmod: WARNING: could not open /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/lib/modules/3.10.0-327.el7.x86_64/modules.order: No such file or directory
depmod: WARNING: /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/lib/modules/3.10.0-327.el7.x86_64/extra/igb/igb.ko needs unknown symbol i2c_new_device
depmod: WARNING: /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/lib/modules/3.10.0-327.el7.x86_64/extra/igb/igb.ko needs unknown symbol dca_remove_requester
depmod: WARNING: /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/lib/modules/3.10.0-327.el7.x86_64/extra/igb/igb.ko needs unknown symbol i2c_bit_add_bus
depmod: WARNING: /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/lib/modules/3.10.0-327.el7.x86_64/extra/igb/igb.ko needs unknown symbol ptp_clock_index
depmod: WARNING: /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/lib/modules/3.10.0-327.el7.x86_64/extra/igb/igb.ko needs unknown symbol ptp_find_pin
depmod: WARNING: /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/lib/modules/3.10.0-327.el7.x86_64/extra/igb/igb.ko needs unknown symbol i2c_del_adapter
depmod: WARNING: /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/lib/modules/3.10.0-327.el7.x86_64/extra/igb/igb.ko needs unknown symbol dca_add_requester
depmod: WARNING: /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/lib/modules/3.10.0-327.el7.x86_64/extra/igb/igb.ko needs unknown symbol ptp_clock_register
depmod: WARNING: /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/lib/modules/3.10.0-327.el7.x86_64/extra/igb/igb.ko needs unknown symbol dca_unregister_notify
depmod: WARNING: /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/lib/modules/3.10.0-327.el7.x86_64/extra/igb/igb.ko needs unknown symbol dca_register_notify
depmod: WARNING: /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/lib/modules/3.10.0-327.el7.x86_64/extra/igb/igb.ko needs unknown symbol ptp_clock_event
depmod: WARNING: /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/lib/modules/3.10.0-327.el7.x86_64/extra/igb/igb.ko needs unknown symbol dca3_get_tag
depmod: WARNING: /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/lib/modules/3.10.0-327.el7.x86_64/extra/igb/igb.ko needs unknown symbol ptp_clock_unregister
depmod: WARNING: /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/lib/modules/3.10.0-327.el7.x86_64/extra/igb/igb.ko needs unknown symbol i2c_smbus_write_byte_data
depmod: WARNING: /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/lib/modules/3.10.0-327.el7.x86_64/extra/igb/igb.ko needs unknown symbol i2c_smbus_read_byte_data
depmod: WARNING: could not open /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/lib/modules/3.10.0-327.el7.x86_64/modules.builtin: No such file or directory
make: Leaving directory `/usr/src/kernels/3.10.0-327.el7.x86_64'
+ find /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/lib/modules -iname 'modules.*' -exec rm '{}' ';'
+ install -m 644 -D source/depmod.conf /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/etc/depmod.d/igb.conf
+ install -m 644 -D source/symbols.greylist /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/usr/share/doc/kmod-igb/greylist.txt
+ '[' -d source/firmware ']'
+ /usr/lib/rpm/find-debuginfo.sh --strict-build-id -m --run-dwz --dwz-low-mem-die-limit 10000000 --dwz-max-die-limit 110000000 /root/rpmbuild/BUILD/igb-5.2.15_k
extracting debug info from /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/lib/modules/3.10.0-327.el7.x86_64/extra/igb/igb.ko
nm: /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64/lib/modules/3.10.0-327.el7.x86_64/extra/igb/igb.ko: No symbols
dwz: Too few files for multifile optimization
dwz: "./lib/modules/3.10.0-327.el7.x86_64/extra/igb/igb.ko.debug" is not a shared library
/usr/lib/rpm/sepdebugcrcfix: Updated 0 CRC32s, 1 CRC32s did match.
1360 blocks
+ /usr/lib/rpm/check-buildroot
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/brp-python-bytecompile /usr/bin/python 1
+ /usr/lib/rpm/redhat/brp-python-hardlink
+ /usr/lib/rpm/redhat/brp-java-repack-jars
Processing files: kmod-igb-5.2.15_k-1.el7.x86_64
Finding Provides: /root/rpmbuild/SOURCES/find-provides.ksyms igb 5.2.15_k-1.el7
Finding Requires(interp):
Finding Requires(rpmlib):
Finding Requires(verify):
Finding Requires(pre):
Finding Requires(post):
Finding Requires(preun):
Finding Requires(postun):
Finding Requires(pretrans):
Finding Requires(posttrans):
Finding Requires: /root/rpmbuild/SOURCES/find-requires.ksyms
Provides: kernel-modules = 3.10.0-327.el7.x86_64 igb-kmod = 5.2.15_k-1.el7 kmod-igb = 5.2.15_k-1.el7 kmod-igb(x86-64) = 5.2.15_k-1.el7
Requires(interp): /bin/sh /bin/sh /bin/sh
Requires(rpmlib): rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
Requires(post): /usr/sbin/depmod /bin/sh
Requires(preun): /bin/sh
Requires(postun): /usr/sbin/depmod /bin/sh
Requires: kernel(alloc_etherdev_mqs) = 0x906ac89f kernel(__alloc_pages_nodemask) = 0x8616cca3 kernel(__alloc_skb) = 0xaf3f0d3e kernel(__bitmap_weight) = 0x4cbbd171 kernel(cancel_delayed_work_sync) = 0x797c8fa9 kernel(cancel_work_sync) = 0x088bfa7e kernel(_cond_resched) = 0xa1c76e0a kernel(__const_udelay) = 0xeae3dfd6 kernel(consume_skb) = 0x95baac39 kernel(_copy_from_user) = 0x077e2f33 kernel(_copy_to_user) = 0x71de9b3f kernel(cpu_number) = 0x54efb5d6 kernel(cpu_online_mask) = 0x930484aa kernel(csum_ipv6_magic) = 0x27c33efe kernel(dca3_get_tag) = 0x97023c74 kernel(dca_add_requester) = 0x16263f45 kernel(dca_register_notify) = 0xac34ecec kernel(dca_remove_requester) = 0x3838ebc6 kernel(dca_unregister_notify) = 0x01a33ab9 kernel(delayed_work_timer_fn) = 0x6b06fdce kernel(del_timer_sync) = 0xd5f2172f kernel(dev_close) = 0xf40262b1 kernel(dev_err) = 0x0d795224 kernel(dev_get_drvdata) = 0x7cf5b2b3 kernel(device_set_wakeup_enable) = 0x35c52bf9 kernel(_dev_info) = 0x4cce8b07 kernel(__dev_kfree_skb_any) = 0xe1d1af76 kernel(devm_hwmon_device_register_with_groups) = 0xc4e2dd17 kernel(devm_kmalloc) = 0x636462f8 kernel(dev_open) = 0x2e3d0c4c kernel(dev_set_drvdata) = 0xc483a55a kernel(dev_warn) = 0x43b38448 kernel(dma_ops) = 0x584c5b17 kernel(dma_set_mask) = 0x59d5a7f7 kernel(dma_supported) = 0x7a7f7d68 kernel(dql_completed) = 0xa00aca2a kernel(dql_reset) = 0x4ea25709 kernel(driver_for_each_device) = 0xaac87aa7 kernel(__dynamic_dev_dbg) = 0xc140ad72 kernel(__dynamic_netdev_dbg) = 0xd8836e80 kernel(__dynamic_pr_debug) = 0xf087137d kernel(eth_get_headlen) = 0xc911b9d5 kernel(eth_type_trans) = 0xad480ea0 kernel(eth_validate_addr) = 0xdec0caf5 kernel(__fentry__) = 0xbdfb6dbb kernel(find_first_bit) = 0xb352177e kernel(find_next_bit) = 0xc0a3d105 kernel(free_irq) = 0xf20dabd8 kernel(free_netdev) = 0x708b5f0c kernel(__free_pages) = 0xa281370e kernel(i2c_bit_add_bus) = 0xbb2dd838 kernel(i2c_del_adapter) = 0xca4d038b kernel(i2c_new_device) = 0x62f8040e kernel(i2c_smbus_read_byte_data) = 0x6af8907c kernel(i2c_smbus_write_byte_data) = 0x6175e5a3 kernel(init_timer_key) = 0x0593a99b kernel(iounmap) = 0xedc03953 kernel(jiffies) = 0x7d11c268 kernel(kernel_stack) = 0x4c4fef19 kernel(kfree) = 0x037a0cba kernel(kfree_call_rcu) = 0x09469482 kernel(kfree_skb) = 0x195c9f2c kernel(__kmalloc) = 0xd2b09ce5 kernel(ktime_get_real) = 0x2447533c kernel(memcpy) = 0x69acdf38 kernel(memset) = 0xfb578fc5 kernel(mod_timer) = 0x8834396c kernel(module_layout) = 0x28950ef1 kernel(msleep) = 0xf9a482f9 kernel(msleep_interruptible) = 0xcc5005fe kernel(__napi_alloc_skb) = 0x42045456 kernel(napi_complete_done) = 0x905307be kernel(napi_disable) = 0xd93737a0 kernel(napi_gro_receive) = 0xae250af1 kernel(__napi_schedule) = 0xd17f4c5b kernel(netdev_err) = 0xd6967e61 kernel(netdev_info) = 0x262e1c2b kernel(netdev_rss_key_fill) = 0x467df16d kernel(netdev_warn) = 0x2931cd0f kernel(netif_carrier_off) = 0x3eff7be7 kernel(netif_carrier_on) = 0xe6d7097b kernel(netif_device_attach) = 0x423058c9 kernel(netif_device_detach) = 0x2fa56500 kernel(__netif_napi_add) = 0x7efd609f kernel(netif_napi_del) = 0x81ad6f16 kernel(__netif_schedule) = 0xc4bff15e kernel(netif_set_real_num_rx_queues) = 0x2a62b5bc kernel(netif_set_real_num_tx_queues) = 0x5562fbb2 kernel(net_ratelimit) = 0xf6ebc03b kernel(node_data) = 0x3142b10b kernel(nr_cpu_ids) = 0xfe7c4287 kernel(ns_to_timespec) = 0x0f4c91ed kernel(numa_node) = 0x618911fc kernel(param_ops_int) = 0x15692c87 kernel(param_ops_uint) = 0x6d044c26 kernel(passthru_features_check) = 0x57f24cd6 kernel(pci_cleanup_aer_uncorrect_error_status) = 0x18045377 kernel(pci_device_is_present) = 0x85179274 kernel(pci_disable_device) = 0x1c3e657e kernel(pci_disable_msi) = 0x79142775 kernel(pci_disable_msix) = 0x58ecf574 kernel(pci_disable_pcie_error_reporting) = 0x6a4ce13c kernel(pci_disable_sriov) = 0x547ca86d kernel(pcie_capability_read_word) = 0x9427acde kernel(pcie_capability_write_word) = 0x44d12756 kernel(pci_enable_device_mem) = 0x1cfb9239 kernel(pci_enable_msi_range) = 0xabda77d3 kernel(pci_enable_msix_range) = 0x683abeb9 kernel(pci_enable_pcie_error_reporting) = 0x2abcf5b4 kernel(pci_enable_sriov) = 0x1a80987d kernel(pci_enable_wake) = 0x909c8ff0 kernel(pci_iomap) = 0x8055d058 kernel(pci_iounmap) = 0x127b8725 kernel(pci_num_vf) = 0x15b2fb0d kernel(pci_prepare_to_sleep) = 0xcee87277 kernel(pci_read_config_word) = 0xc2560ac2 kernel(__pci_register_driver) = 0x99487493 kernel(pci_release_selected_regions) = 0x841b8930 kernel(pci_request_selected_regions) = 0xdc61ce31 kernel(pci_restore_state) = 0x5bbdc39c kernel(pci_save_state) = 0x53108e44 kernel(pci_select_bars) = 0x15455c9c kernel(pci_set_master) = 0xbe4a1520 kernel(pci_set_power_state) = 0x5ede9448 kernel(pci_sriov_set_totalvfs) = 0x73cdb64d kernel(pci_unregister_driver) = 0x2cb61da5 kernel(pci_vfs_assigned) = 0x09a7d782 kernel(pci_wake_from_d3) = 0xcc3659e8 kernel(pci_write_config_word) = 0x8bd590db kernel(phys_base) = 0x4c9d28b0 kernel(__pm_runtime_idle) = 0xba954a0e kernel(__pm_runtime_resume) = 0x7baababe kernel(pm_schedule_suspend) = 0x4e31f4a1 kernel(print_hex_dump) = 0x167c5967 kernel(printk) = 0x27e1a049 kernel(pskb_expand_head) = 0x826789e8 kernel(__pskb_pull_tail) = 0xe0dbd0e4 kernel(ptp_clock_event) = 0xf8962d40 kernel(ptp_clock_index) = 0x1627b4d4 kernel(ptp_clock_register) = 0x3b0cba11 kernel(ptp_clock_unregister) = 0x8b63315e kernel(ptp_find_pin) = 0x4d2bcad6 kernel(pv_irq_ops) = 0x78764f4e kernel(queue_delayed_work_on) = 0xeeec26a7 kernel(queue_work_on) = 0x2e0d2f7f kernel(_raw_spin_lock) = 0xd52bf1ce kernel(_raw_spin_lock_irqsave) = 0x9327f5ce kernel(_raw_spin_unlock) = 0xda3e43d1 kernel(_raw_spin_unlock_irqrestore) = 0x08f64aa4 kernel(register_netdev) = 0xd7efe2ef kernel(request_threaded_irq) = 0xd6b8e852 kernel(round_jiffies) = 0x091eb9b4 kernel(rtnl_lock) = 0xc7a4fbed kernel(rtnl_unlock) = 0x6e720ff2 kernel(set_normalized_timespec) = 0x0e6da44a kernel(skb_add_rx_frag) = 0xd1c8097c kernel(skb_clone_tx_timestamp) = 0x83433c92 kernel(skb_pad) = 0x611c9b4b kernel(skb_put) = 0x2ac95217 kernel(skb_tstamp_tx) = 0x22095d00 kernel(__smp_mb__before_atomic) = 0x384e70ae kernel(snprintf) = 0x28318305 kernel(sprintf) = 0x91715312 kernel(__stack_chk_fail) = 0xf0fdf6cb kernel(strlcpy) = 0x5792f848 kernel(strncpy) = 0x9166fada kernel(synchronize_irq) = 0xe523ad75 kernel(system_state) = 0xa8721b97 kernel(system_wq) = 0x2d3385d3 kernel(timecounter_cyc2time) = 0xa8b76a68 kernel(timecounter_init) = 0x99840d00 kernel(timecounter_read) = 0xc542933a kernel(__udelay) = 0x9e7d6bd0 kernel(unregister_netdev) = 0x7eb952e6 kernel(usleep_range) = 0x12a38747 kernel(vfree) = 0x999e8297 kernel(vmalloc) = 0xd6ee688f kernel(vzalloc) = 0x40a9b349 kernel(warn_slowpath_fmt) = 0x1e047854 kernel(warn_slowpath_null) = 0x16305289 kernel(x86_dma_fallback_dev) = 0x5b8adbca
Processing files: igb-debuginfo-5.2.15_k-1.el7.x86_64
Provides: igb-debuginfo = 5.2.15_k-1.el7 igb-debuginfo(x86-64) = 5.2.15_k-1.el7
Requires(rpmlib): rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
Checking for unpackaged file(s): /usr/lib/rpm/check-files /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64
Wrote: /root/rpmbuild/SRPMS/igb-5.2.15_k-1.el7.src.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/kmod-igb-5.2.15_k-1.el7.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/igb-debuginfo-5.2.15_k-1.el7.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.7QT6DU
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd igb-5.2.15_k
+ rm -rf /root/rpmbuild/BUILDROOT/igb-5.2.15_k-1.el7.x86_64
+ exit 0
[root@back SPECS]#
[root@back rpmbuild]# ls
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
[root@back rpmbuild]# cd RPMS/
[root@back RPMS]# ls
x86_64
[root@back RPMS]# cd x86_64/
[root@back x86_64]# ls
igb-debuginfo-5.2.15_k-1.el7.x86_64.rpm kmod-igb-5.2.15_k-1.el7.x86_64.rpm
可以看到,rhel7中编译src.rpm和6中都差不多
#############################################
补充:之前在centos 7.1上编译这个igb的时候总是报错,如下:
[root@localhost SPECS]# ls
igb.spec megaraid_sas.spec
[root@localhost SPECS]# rpmbuild -bp igb.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.Gk9E8o
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd /root/rpmbuild/BUILD
+ rm -rf igb-5.2.15_k
+ /usr/bin/bzip2 -dc /root/rpmbuild/SOURCES/igb-5.2.15_k.tar.bz2
+ /usr/bin/tar -xvvf -
drwxrwxr-x poros/poros 0 2015-12-01 03:55 igb-5.2.15_k/
drwxrwxr-x poros/poros 0 2015-12-01 03:55 igb-5.2.15_k/drivers/
drwxrwxr-x poros/poros 0 2015-12-01 03:55 igb-5.2.15_k/drivers/net/
drwxrwxr-x poros/poros 0 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/
drwxrwxr-x poros/poros 0 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/
drwxrwxr-x poros/poros 0 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/
-rw-rw-r-- poros/poros 79052 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_82575.c
-rw-rw-r-- poros/poros 11526 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_82575.h
-rw-rw-r-- poros/poros 46243 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_defines.h
-rw-rw-r-- poros/poros 13152 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_hw.h
-rw-rw-r-- poros/poros 23862 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_i210.c
-rw-rw-r-- poros/poros 3484 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_i210.h
-rw-rw-r-- poros/poros 46510 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_mac.c
-rw-rw-r-- poros/poros 3082 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_mac.h
-rw-rw-r-- poros/poros 11246 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_mbx.c
-rw-rw-r-- poros/poros 3212 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_mbx.h
-rw-rw-r-- poros/poros 20246 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_nvm.c
-rw-rw-r-- poros/poros 1921 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_nvm.h
-rw-rw-r-- poros/poros 69865 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_phy.c
-rw-rw-r-- poros/poros 7100 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_phy.h
-rw-rw-r-- poros/poros 22660 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_regs.h
-rw-rw-r-- poros/poros 87993 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/igb_ethtool.c
-rw-rw-r-- poros/poros 16373 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/igb.h
-rw-rw-r-- poros/poros 6800 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/igb_hwmon.c
-rw-rw-r-- poros/poros 221625 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/igb_main.c
-rw-rw-r-- poros/poros 33386 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/igb_ptp.c
-rw-rw-r-- poros/poros 1392 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/Makefile
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd igb-5.2.15_k
+ /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ set -- drivers
+ mkdir source
+ mv drivers source/
+ mkdir obj
+ exit 0
[root@localhost SPECS]#
[root@localhost SPECS]#
rpmbuild -bp可以正常,但rpmbuild -ba就出问题了
[root@localhost SPECS]# rpmbuild -ba igb.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.wyG9xf
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd /root/rpmbuild/BUILD
+ rm -rf igb-5.2.15_k
+ /usr/bin/bzip2 -dc /root/rpmbuild/SOURCES/igb-5.2.15_k.tar.bz2
+ /usr/bin/tar -xvvf -
drwxrwxr-x poros/poros 0 2015-12-01 03:55 igb-5.2.15_k/
drwxrwxr-x poros/poros 0 2015-12-01 03:55 igb-5.2.15_k/drivers/
drwxrwxr-x poros/poros 0 2015-12-01 03:55 igb-5.2.15_k/drivers/net/
drwxrwxr-x poros/poros 0 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/
drwxrwxr-x poros/poros 0 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/
drwxrwxr-x poros/poros 0 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/
-rw-rw-r-- poros/poros 79052 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_82575.c
-rw-rw-r-- poros/poros 11526 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_82575.h
-rw-rw-r-- poros/poros 46243 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_defines.h
-rw-rw-r-- poros/poros 13152 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_hw.h
-rw-rw-r-- poros/poros 23862 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_i210.c
-rw-rw-r-- poros/poros 3484 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_i210.h
-rw-rw-r-- poros/poros 46510 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_mac.c
-rw-rw-r-- poros/poros 3082 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_mac.h
-rw-rw-r-- poros/poros 11246 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_mbx.c
-rw-rw-r-- poros/poros 3212 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_mbx.h
-rw-rw-r-- poros/poros 20246 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_nvm.c
-rw-rw-r-- poros/poros 1921 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_nvm.h
-rw-rw-r-- poros/poros 69865 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_phy.c
-rw-rw-r-- poros/poros 7100 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_phy.h
-rw-rw-r-- poros/poros 22660 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/e1000_regs.h
-rw-rw-r-- poros/poros 87993 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/igb_ethtool.c
-rw-rw-r-- poros/poros 16373 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/igb.h
-rw-rw-r-- poros/poros 6800 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/igb_hwmon.c
-rw-rw-r-- poros/poros 221625 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/igb_main.c
-rw-rw-r-- poros/poros 33386 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/igb_ptp.c
-rw-rw-r-- poros/poros 1392 2015-12-01 03:55 igb-5.2.15_k/drivers/net/ethernet/intel/igb/Makefile
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd igb-5.2.15_k
+ /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ set -- drivers
+ mkdir source
+ mv drivers source/
+ mkdir obj
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.MJj6Ng
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd igb-5.2.15_k
+ for flavor in default
+ rm -rf obj/default
+ cp -r source obj/default
+ symvers=source/Module.symvers-x86_64
+ '[' -e source/Module.symvers-x86_64 ']'
++ '[' default = default ']'
+ make -C /usr/src/kernels/3.10.0-327.el7.x86_64 M=/root/rpmbuild/BUILD/igb-5.2.15_k/obj/default/drivers/net/ethernet/intel/igb 'NOSTDINC_FLAGS=-I /root/rpmbuild/BUILD/igb-5.2.15_k/obj/default/include'
make: *** /usr/src/kernels/3.10.0-327.el7.x86_64: No such file or directory. Stop.
error: Bad exit status from /var/tmp/rpm-tmp.MJj6Ng (%build)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.MJj6Ng (%build)
[root@localhost SPECS]#
根据报错可以发现,这里make是要找/usr/src/kernels/3.10.0-327.el7.x86_64目录,而我当前的是[root@localhost SPECS]# ls -l /usr/src/kernels/3.10.0-229.el7.x86_64/目录,这是因为我当前的OS是7.1,而igb模块的src.rpm是7.2版的(所以在make的时候会找3.10.0-327内核)
当前系统信息:
[root@localhost SPECS]# lsb_release -ia
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.1.1503 (Core)
Release: 7.1.1503
Codename: Core
rhel7.2系统的信息
[root@back x86_64]# lsb_release -ia
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 7.2 (Maipo)
Release: 7.2
Codename: Maipo
[root@back x86_64]# ll -l /usr/src/kernels/3.10.0-327.el7.x86_64/
所以该模块需要在7.2下进行编译