Kissingwolf's Blog

ethtool 软件包定制

由于CentOS 6 默认自带的ethtool工具版本为3.8 ,不支持intel 万兆光纤卡的光纤衰减显示,所有需要定制新版本的ethtool工具。

  1. 确认安装rpm-build软件包

  2. 本地创建rpmbuild所需目录

    1
    # mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
  3. 在~/rpmbuild/SPECS目录下创建spec文件

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    # vim ~/rpmbuild/SPECS/ethtool.spec
    Name: ethtool
    Epoch: 3
    Version: 4.10
    Release: 1%{?dist}
    Summary: Settings tool for Ethernet NICs
    License: GPLv2
    Group: Applications/System
    URL: http://ftp.kernel.org/pub/software/network/%{name}/
    # Source0 指定ethtool源代码文件下载路径
    Source0: https://www.kernel.org/pub/software/network/ethtool/ethtool-4.10.tar.xz
    BuildRequires: automake, autoconf
    #Conflicts: filesystem < 3
    %description
    This utility allows querying and changing settings such as speed,
    port, auto-negotiation, PCI locations and checksum offload on many
    network devices, especially of Ethernet devices.
    %prep
    %setup -q -n %{name}-%{version}%{?pre}
    %build
    %configure --sbindir=/sbin
    make %{?_smp_mflags}
    %install
    rm -rf %{buildroot}
    make DESTDIR=%{buildroot} INSTALL='install -p' install
    # Some legacy support for scripts etc. out there
    mkdir -p %{buildroot}%{_sbindir}
    ln -sf ../../sbin/%{name} %{buildroot}%{_sbindir}/%{name}
    %clean
    rm -rf %{buildroot}
    %files
    %defattr(-,root,root,-)
    %doc AUTHORS ChangeLog* COPYING LICENSE NEWS README
    /sbin/%{name}
    %{_sbindir}/%{name}
    %{_mandir}/man8/%{name}.8*
  4. 编译创建ethtool rpm包

    1
    # rpmbuild -ba ~/rpmbuild/SPECS/ethtool.spec
  5. 编译好的ethtool rpm文件在~/rpmbuild/RPMS/目录下。