centos安装rpm-build
yum install -y rpm-build
从openvpn官网下载源码:我以下载openvpn-2.5.8.tar.gz为例
参考网址:https://openvpn.net/community-resources/installing-openvpn/
openvpn-2.5.8.tar.gz放置在rpmbuild/SOURCES路径下
目录如下:
[root@localhost ~]# tree -L 2 rpmbuild/
rpmbuild/
├── BUILD
│???└── openvpn-2.5.8
├── BUILDROOT
│???└── openvpn-2.5.8-1.x86_64
├── RPMS
├── SOURCES
│???└── openvpn-2.5.8.tar.gz
├── SPECS
└── SRPMS编写spec文件
[root@localhost ~]# cat openvpn.spec?
Name: ? ? ? ? ? openvpn
Version: ? ? ? ?2.5.8
Release: ? ? ? ?1
Summary: ? ? ? ?An easy-to-use, robust, and highly configurable VPN
License: ? ? ? ?GPL
URL: ? ? ? ? ? ?https://openvpn.net/
Source0: ? ? ? ?%{name}-%{version}.tar.gz
BuildRequires: ?openssl-devel
BuildRequires: ?lzo-devel
BuildRequires: ?pam-devel
%description
OpenVPN is an open source software application that implements virtual private network (VPN) techniques for creating secure point-to-point or site-to-site connections in routed or bridged configurations and remote access facilities.
%prep
%setup -q
%build
./configure
make
%install
make install DESTDIR=%{buildroot}
%files
%defattr(-,root,root,-)
%doc
%changelog
* Mon May 31 2021 John Doe <john.doe@example.com> 2.5.8-1
- Initial build
安装依赖:
yum install -y openssl-devel lzo-devel pam-devel
yum install gcc
开始构建rpm:
rpmbuild -bb openvpn.spec?