华为服务器(鲲鹏)aarch64/arm64架构下编译nmap RPM包

目录

安装rpmbuild

创建工作目录

安装编译环境

安装nmap依赖包

编辑Spec文件

编译nmap RPM包

验证RPM可用性


安装rpmbuild

yum -y install rpm-build

创建工作目录

# 使用rpmdev-setuptree命令创建编译目录
yum -y install rpmdevtools
rpmdev-setuptree #默认将再当前用户主目录下创建一个RPM构建根目录结构
# 或手动创建
mkdir -pv  ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

安装编译环境

yum install gcc gcc-c++ openssl-devel libtool -y

安装nmap依赖包

yum install flex bison byacc libpcap libpcap-devel -y

编辑Spec文件

cd /home/liuyl/rpmbuild

touch SPECS/ultra-nmap.spec

参考:https://svn.nmap.org/nmap-releases/nmap-7.90/nmap.spec.in

%define _topdir /home/liuyl/rpmbuild
%define _prefix /usr/local
%define _bindir /usr/local/bin
%define _datadir /usr/local/share

Name: ultra-nmap    
Version: 7.91
Release: 1%{?dist}
Summary: Network exploration tool and security scanner
License: GPLv2
URL: https://nmap.org
Source0: %{name}-%{version}.tar.bz2
Group: Applications/System
Vendor: nmap.org
Prefix: %{_prefix}
BuildRoot: %{_topdir}/BUILDROOT/%{name}-%{version}-%{release}%{?dist}.%{_arch}
%description
Nmap ("Network Mapper") is a free and open source utility for network exploration or security auditing. Many systems and network
administrators also find it useful for tasks such as network inventory, managing service upgrade schedules, and monitoring host or service uptime. Nmap uses raw IP packets in novel ways to determine what hosts are available on the network, what services (application name and version) those hosts are offering, what operating systems (and OS versions) they are running, what type of packet filters/firewalls are in use, and dozens of other characteristics. It was designed to rapidly scan large networks, but works fine against single hosts. Nmap runs on all major computer operating systems, and both console and graphical versions are available.
%prep
%setup -q
%build
./configure --prefix=%{_prefix} --without-zenmap --without-nping --without-ncat --with-localdirs 
make %{?_smp_mflags} DESTDIR=$RPM_BUILD_ROOT
%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
%clean
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%doc LICENSE
%doc docs/README
%doc docs/nmap.usage.txt
%doc %{_prefix}/share/man/man1/nmap.1
%doc %{_prefix}/share/man/*/man1/nmap.1
%{_bindir}/nmap
%{_datadir}/nmap

%changelog

编译nmap RPM包

上传nmap源码文件到SOURCES/nmap-7.91.tar.bz2,执行下面的命令编译RPM包,过程如果没有错的话,会生成以下RPM文件:

$ ll RPMS/aarch64/
total 5676
-rw-rw-r--. 1 liuyl liuyl 5759680 Jan 27 17:44 nmap-7.91-1.el7.aarch64.rpm
-rw-rw-r--. 1 liuyl liuyl   47988 Jan 27 17:44 nmap-debuginfo-7.91-1.el7.aarch64.rpm

rpmbuild -ba SPECS/ultra-nmap.spec

-ba 既生成src.rpm又生成二进制rpm 
-bs 只生成src的rpm 
-bb 只生二进制的rpm 
-bp 执行到pre 
-bc 执行到 build段 
-bi 执行install段 
-bl 检测有文件没包含 

验证RPM可用性

nmap-7.91-1.el7.aarch64.rpm包上传到另外一台CentOS7机器上,执行如下命令进行安装:

# rpm -ivh nmap-7.91-1.el7.aarch64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:nmap-7.91-1.el7            ################################# [100%]

安装成功,执行nmap命令进行端口扫描验证:

# nmap -n -Pn -T4 -sV -p22 10.10.17.143 
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.4 (protocol 2.0)

你可能感兴趣的:(操作系统,aarch64,kunpeng)