CentOS7下制作openssl1.1.1i RPM包
1、确认当前环境下系统版本及openssl版本
[root@centos ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@centos ~]#
[root@centos ~]# rpm -aq openssl
openssl-1.0.2k-19.el7.x86_64
[root@centos ~]#
[root@centos ~]# rpm -aq | grep openssl
xmlsec1-openssl-1.2.20-7.el7_4.x86_64
openssl-1.0.2k-19.el7.x86_64
openssl098e-0.9.8e-29.el7.centos.3.x86_64
openssl-libs-1.0.2k-19.el7.x86_64
[root@centos ~]#
[root@centos ~]# openssl version
OpenSSL 1.0.2k-fips 26 Jan 2017
[root@centos ~]#
2、制作OpenSSL1.1.1i rpm包
- 自动化脚本如下install-openssl_1.1.1i.sh,并将该脚本拷贝至/opt目录下,并执行以下命令赋予权限755:
chmod 755 install-openssl_1.1.1i.sh
脚本内容如下:
#!/bin/bash
set -e
set -v
mkdir ~/openssl && cd ~/openssl
yum -y install \
curl \
which \
make \
gcc \
perl \
perl-WWW-Curl \
rpm-build
# Get openssl tarball
cp /root/openssl-1.1.1i.tar.gz ./
# SPEC file
cat << 'EOF' > ~/openssl/openssl.spec
Summary: OpenSSL 1.1.1i for Centos
Name: openssl
Version: %{?version}%{!?version:1.1.1i}
Release: 1%{?dist}
Obsoletes: %{name} <= %{version}
Provides: %{name} = %{version}
URL: https://www.openssl.org/
License: GPLv2+
Source: https://www.openssl.org/source/%{name}-%{version}.tar.gz
BuildRequires: make gcc perl perl-WWW-Curl
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
%global openssldir /usr/openssl
%description
OpenSSL RPM for version 1.1.1i on Centos
%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.1i on Centos (development package)
%prep
%setup -q
%build
./config --prefix=%{openssldir} --openssldir=%{openssldir}
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
EOF
mkdir -p /root/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
cp ~/openssl/openssl.spec /root/rpmbuild/SPECS/openssl.spec
mv openssl-1.1.1i.tar.gz /root/rpmbuild/SOURCES
cd /root/rpmbuild/SPECS && \
rpmbuild \
-D "version 1.1.1i" \
-ba openssl.spec
# Before Uninstall Openssl : rpm -qa openssl
# Uninstall Current Openssl Vesion : yum -y remove openssl
# For install: rpm -ivvh /root/rpmbuild/RPMS/x86_64/openssl-1.1.1i-1.el7.x86_64.rpm --nodeps
# Verify install: rpm -qa openssl
# openssl version
- 下载openssl1.1.1i版本源码包,并上传到/root目录
wget https://www.openssl.org/source/openssl-1.1.1i.tar.gz
- 在/opt目录下执行:./install-openssl_1.1.1i.sh进行编译打包
3、rpm升级到openssl1.1.1i
rpm -aq | grep openssl --查询当前openssl版本
yum -y remove openssl --移除当前版本
rpm -ivh /root/rpmbuild/RPMS/x86_64/openssl-1.1.1i-1.el7.x86_64.rpm --nodeps --安装新版openssl
openssl version --确认是否升级成功