Centos7 制作openssl 1.1.1w rpm包

源码下载地址

https://www.openssl.org/source/

安装编译环境

yum -y install curl  which  make gcc perl  perl-WWW-Curl  rpm-build

mkdir -p /root/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

cp openssl-1.1.1w.tar.gz /root/rpmbuild/SOURCES/

准备openssl.spec文件

openssl.spec文件注意这行,这里为openssl安装路径,后续openssh会使用到

%global openssldir /usr/local/openssl

Name: openssl		
Version: 1.1.1w	
Release: 1%{?dist}
Summary: Utilities from the general purpose cryptography library with TLS implementation	
 
Group: System Environment/Libraries
License: OpenSSL
URL: http://www.openssl.org/
Source0: openssl-%{version}.tar.gz
 
BuildRequires: make, gcc, coreutils, krb5-devel, perl, sed, zlib-devel, perl-WWW-Curl
Requires: coreutils, make
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
%global openssldir /usr/local/openssl
 
%description
The OpenSSL toolkit provides support for secure communications between
machines. OpenSSL includes a certificate management tool and shared
libraries which provide various cryptographic algorithms and
protocols.
 
%package devel
Summary: Development files for programs which will use the openssl library
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
 
%description devel
OpenSSL RPM for version 1.1.1w on Centos (development package)
 
 
%prep
%setup -q
 
 
%build
./config --prefix=%{openssldir} --openssldir=%{openssldir} shared -fPIC
make
 
 
%install
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
%make_install
 
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_libdir}
ln -sf %{openssldir}/lib/libssl.so.1.1 %{buildroot}%{_libdir}
ln -sf %{openssldir}/lib/libcrypto.so.1.1 %{buildroot}%{_libdir}
ln -sf %{openssldir}/bin/openssl %{buildroot}%{_bindir}
 
 
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
 
%files
%{openssldir}
%defattr(-,root,root)
/usr/bin/openssl
/usr/lib64/libcrypto.so.1.1
/usr/lib64/libssl.so.1.1
 
%files devel
%{openssldir}/include/*
%defattr(-,root,root)
 
%post -p /sbin/ldconfig
 
%postun -p /sbin/ldconfig

cd /root/rpmbuild/SPECS
rpmbuild -ba openssl.spec

生成rpm包在

/root/rpmbuild/RPMS/x86_64

安装rpm包

rpm -ivh  openssl-1.1.1w-1.el7.x86_64.rpm openssl-devel-1.1.1w-1.el7.x86_64.rpm --force --nodeps