CentOS7制作rpm包升级OpenSSL

前段时间生产环境安全通报openssl安全漏洞需要升级整改,CentOS7官方最新版本也只到openssl 1.0.2k,考虑自己下载较新压缩包制作rpm包进行升级整改,以openssl 1.1.1w版本为基础测试,更多也是对openssl打包rpm学习,对网上分享经验的交流。

系统环境

系统:CentOS7 x86_64
OpenSSL版本:OpenSSL 1.0.2k-fips 26 Jan 2017

前期准备

安装依赖

yum install rpm-build rpmlint rpmdevtools
yum install gcc gcc-c++ make perl perl-WWW-Curl

创建编译目录

mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
  • BUILD: 用于存放编译过程中生成的文件
  • BUILDROOT:用于存放编译后的根文件系统
  • RPMS:用于存放编译后的 RPM 包
  • SOURCES:用于存放源代码包
  • SPECS:用于存放 RPM 规范文件
  • SRPMS:用于存放源 RPM 包

下载需要文件跟压缩包至~/rpmbuild/SOURCES目录

https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz
https://git.centos.org/rpms/openssl/releases

ls -lh ~/rpmbuild/SOURCES/
total 9.6M
-rw-r--r-- 1 root root  23K Jul  8 14:35 ec_curve.c
-rw-r--r-- 1 root root  64K Jul  8 14:35 ectest.c
-rw-r--r-- 1 root root 1.2K Jul  8 14:35 hobble-openssl
-rw-r--r-- 1 root root  639 Jul  8 14:35 make-dummy-cert
-rw-r--r-- 1 root root 2.6K Jul  8 14:35 Makefile.certificate
-rw-r--r-- 1 root root 9.5M Jul  8 14:35 openssl-1.1.1w.tar.gz
-rw-r--r-- 1 root root 1.6K Jul  8 14:35 opensslconf-new.h
-rw-r--r-- 1 root root  266 Jul  8 14:35 opensslconf-new-warning.h
-rw-r--r-- 1 root root 9.8K Jul  8 11:22 openssl-thread-test.c
-rw-r--r-- 1 root root 2.7K Jul  8 14:35 README.FIPS
-rw-r--r-- 1 root root 2.0K Jul  8 11:15 README.legacy-settings
-rw-r--r-- 1 root root  772 Jul  8 14:35 renew-dummy-cert

编写修改 SPEC 文件

可以根据https://git.centos.org/rpms/openssl/releases下载编写
vim ~/rpmbuild/SPECS/openssl.spec

# For the curious:
# 0.9.5a soversion = 0
# 0.9.6  soversion = 1
# 0.9.6a soversion = 2
# 0.9.6c soversion = 3
# 0.9.7a soversion = 4
# 0.9.7ef soversion = 5
# 0.9.8ab soversion = 6
# 0.9.8g soversion = 7
# 0.9.8jk + EAP-FAST soversion = 8
# 1.0.0 soversion = 10
# 1.1.0 soversion = 1.1 (same as upstream although presence of some symbols
#                        depends on build configuration options)
%define soversion 1.1

# Arches on which we need to prevent arch conflicts on opensslconf.h, must
# also be handled in opensslconf-new.h.
%define multilib_arches %{ix86} ia64 %{mips} ppc ppc64 s390 s390x sparcv9 sparc64 x86_64

%global _performance_build 1

Summary: Utilities from the general purpose cryptography library with TLS implementation
Name: openssl
Version: 1.1.1w
Release: 1%{?dist}
Epoch: 1
# We have to remove certain patented algorithms from the openssl source
# tarball with the hobble-openssl script which is included below.
# The original openssl upstream tarball cannot be shipped in the .src.rpm.
Source: https://www.openssl.org/source/%{name}-%{version}.tar.gz
#Source1: hobble-openssl
Source2: Makefile.certificate
Source6: make-dummy-cert
Source7: renew-dummy-cert
Source9: opensslconf-new.h
Source10: opensslconf-new-warning.h
Source11: README.FIPS
Source12: ec_curve.c
Source13: ectest.c

License: OpenSSL and ASL 2.0
Group: System Environment/Libraries
URL: http://www.openssl.org/
BuildRequires: gcc
BuildRequires: coreutils, perl-interpreter, sed, zlib-devel, /usr/bin/cmp
BuildRequires: lksctp-tools-devel
BuildRequires: /usr/bin/rename
BuildRequires: /usr/bin/pod2man
BuildRequires: /usr/sbin/sysctl
BuildRequires: perl(Test::Harness), perl(Test::More), perl(Math::BigInt)
BuildRequires: perl(Module::Load::Conditional), perl(File::Temp)
BuildRequires: perl(Time::HiRes)
BuildRequires: perl(FindBin), perl(lib), perl(File::Compare), perl(File::Copy)
Requires: coreutils
Requires: %{name}-libs%{?_isa} = %{epoch}:%{version}-%{release}

%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 libs
Summary: A general purpose cryptography library with TLS implementation
Group: System Environment/Libraries
Requires: ca-certificates >= 2008-5
#Requires: crypto-policies >= 20180730
#Recommends: openssl-pkcs11%{?_isa}
# Needed obsoletes due to the base/lib subpackage split
Obsoletes: openssl < 1:1.0.1-0.3.beta3
Obsoletes: openssl-libs < 1:1.0.1e-28
Provides: openssl-libs = %{epoch}:%{version}-%{release}

%description libs
OpenSSL is a toolkit for supporting cryptography. The openssl-libs
package contains the libraries that are used by various applications which
support cryptographic algorithms and protocols.

%package devel
Summary: Files for development of applications which will use OpenSSL
Group: Development/Libraries
Requires: %{name}-libs%{?_isa} = %{epoch}:%{version}-%{release}
Requires: krb5-devel%{?_isa}, zlib-devel%{?_isa}
Requires: pkgconfig

%description devel
OpenSSL is a toolkit for supporting cryptography. The openssl-devel
package contains include files needed to develop applications which
support various cryptographic algorithms and protocols.

%package static
Summary:  Libraries for static linking of applications which will use OpenSSL
Group: Development/Libraries
Requires: %{name}-devel%{?_isa} = %{epoch}:%{version}-%{release}

%description static
OpenSSL is a toolkit for supporting cryptography. The openssl-static
package contains static libraries needed for static linking of
applications which support various cryptographic algorithms and
protocols.

%package perl
Summary: Perl scripts provided with OpenSSL
Group: Applications/Internet
Requires: perl-interpreter
Requires: %{name}%{?_isa} = %{epoch}:%{version}-%{release}

%description perl
OpenSSL is a toolkit for supporting cryptography. The openssl-perl
package provides Perl scripts for converting certificates and keys
from other formats to the formats used by the OpenSSL toolkit.

%prep
%setup -q -n %{name}-%{version}

# The hobble_openssl is called here redundantly, just to be sure.
# The tarball has already the sources removed.

%build
# Figure out which flags we want to use.
# default
sslarch=%{_os}-%{_target_cpu}
%ifarch %ix86
sslarch=linux-elf
if ! echo %{_target} | grep -q i686 ; then
        sslflags="no-asm 386"
fi
%endif
%ifarch x86_64
sslflags=enable-ec_nistp_64_gcc_128
%endif
%ifarch sparcv9
sslarch=linux-sparcv9
sslflags=no-asm
%endif
%ifarch sparc64
sslarch=linux64-sparcv9
sslflags=no-asm
%endif
%ifarch alpha alphaev56 alphaev6 alphaev67
sslarch=linux-alpha-gcc
%endif
%ifarch s390 sh3eb sh4eb
sslarch="linux-generic32 -DB_ENDIAN"
%endif
%ifarch s390x
sslarch="linux64-s390x"
%endif
%ifarch %{arm}
sslarch=linux-armv4
%endif
%ifarch aarch64
sslarch=linux-aarch64
sslflags=enable-ec_nistp_64_gcc_128
%endif
%ifarch sh3 sh4
sslarch=linux-generic32
%endif
%ifarch ppc64 ppc64p7
sslarch=linux-ppc64
%endif
%ifarch ppc64le
sslarch="linux-ppc64le"
sslflags=enable-ec_nistp_64_gcc_128
%endif
%ifarch mips mipsel
sslarch="linux-mips32 -mips32r2"
%endif
%ifarch mips64 mips64el
sslarch="linux64-mips64 -mips64r2"
%endif
%ifarch mips64el
sslflags=enable-ec_nistp_64_gcc_128
%endif
%ifarch riscv64
sslarch=linux-generic64
%endif

# Add -Wa,--noexecstack here so that libcrypto's assembler modules will be
# marked as not requiring an executable stack.
# Also add -DPURIFY to make using valgrind with openssl easier as we do not
# want to depend on the uninitialized memory as a source of entropy anyway.
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -Wa,--noexecstack -Wa,--generate-missing-build-notes=yes -DPURIFY $RPM_LD_FLAGS"

export HASHBANGPERL=/usr/bin/perl

# ia64, x86_64, ppc are OK by default
# Configure the build tree.  Override OpenSSL defaults with known-good defaults
# usable on all platforms.  The Configure script already knows to use -fPIC and
# RPM_OPT_FLAGS, so we can skip specifiying them here.
./config --prefix=%{_prefix} --openssldir=%{_sysconfdir}/pki/tls ${sslflags} --shared zlib

# Do not run this in a production package the FIPS symbols must be patched-in
#util/mkdef.pl crypto update

make all

# Overwrite FIPS README
cp -f %{SOURCE11} .

# Clean up the .pc files
for i in libcrypto.pc libssl.pc openssl.pc ; do
  sed -i '/^Libs.private:/{s/-L[^ ]* //;s/-Wl[^ ]* //}' $i
done

%check
# Verify that what was compiled actually works.

# Hack - either enable SCTP AUTH chunks in kernel or disable sctp for check
(sysctl net.sctp.addip_enable=1 && sysctl net.sctp.auth_enable=1) || \
(echo 'Failed to enable SCTP AUTH chunks, disabling SCTP for tests...' &&
 sed '/"zlib-dynamic" => "default",/a\ \ "sctp" => "default",' configdata.pm > configdata.pm.new && \
 touch -r configdata.pm configdata.pm.new && \
 mv -f configdata.pm.new configdata.pm)

LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export LD_LIBRARY_PATH
ln -s .libcrypto.so.%{soversion}.hmac .libcrypto.so.hmac
ln -s .libssl.so.%{soversion}.hmac .libssl.so.hmac
OPENSSL_ENABLE_MD5_VERIFY=
export OPENSSL_ENABLE_MD5_VERIFY
OPENSSL_SYSTEM_CIPHERS_OVERRIDE=xyz_nonexistent_file
export OPENSSL_SYSTEM_CIPHERS_OVERRIDE
make test

# Add generation of HMAC checksum of the final stripped library
%define __spec_install_post \
    %{?__debug_package:%{__debug_install_post}} \
    %{__arch_install_post} \
    %{__os_install_post} \
    ln -sf .libcrypto.so.%{version}.hmac $RPM_BUILD_ROOT%{_libdir}/.libcrypto.so.%{soversion}.hmac \
    ln -sf .libssl.so.%{version}.hmac $RPM_BUILD_ROOT%{_libdir}/.libssl.so.%{soversion}.hmac \
%{nil}

%define __provides_exclude_from %{_libdir}/openssl

%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
# Install OpenSSL.
install -d $RPM_BUILD_ROOT{%{_bindir},%{_includedir},%{_libdir},%{_mandir},%{_libdir}/openssl,%{_pkgdocdir}}
make DESTDIR=$RPM_BUILD_ROOT install
rename so.%{soversion} so.%{version} $RPM_BUILD_ROOT%{_libdir}/*.so.%{soversion}
for lib in $RPM_BUILD_ROOT%{_libdir}/*.so.%{version} ; do
        chmod 755 ${lib}
        ln -s -f `basename ${lib}` $RPM_BUILD_ROOT%{_libdir}/`basename ${lib} .%{version}`
        ln -s -f `basename ${lib}` $RPM_BUILD_ROOT%{_libdir}/`basename ${lib} .%{version}`.%{soversion}
done

# Install a makefile for generating keys and self-signed certs, and a script
# for generating them on the fly.
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/pki/tls/certs
install -m644 %{SOURCE2} $RPM_BUILD_ROOT%{_pkgdocdir}/Makefile.certificate
install -m755 %{SOURCE6} $RPM_BUILD_ROOT%{_bindir}/make-dummy-cert
install -m755 %{SOURCE7} $RPM_BUILD_ROOT%{_bindir}/renew-dummy-cert

# Move runable perl scripts to bindir
mv $RPM_BUILD_ROOT%{_sysconfdir}/pki/tls/misc/*.pl $RPM_BUILD_ROOT%{_bindir}
mv $RPM_BUILD_ROOT%{_sysconfdir}/pki/tls/misc/tsget $RPM_BUILD_ROOT%{_bindir}

# Drop the SSLv3 methods from includes
sed -i '/ifndef OPENSSL_NO_SSL3_METHOD/,+4d' $RPM_BUILD_ROOT%{_includedir}/openssl/ssl.h

# Rename man pages so that they don't conflict with other system man pages.
pushd $RPM_BUILD_ROOT%{_mandir}
ln -s -f config.5 man5/openssl.cnf.5
for manpage in man*/* ; do
         if [ -L ${manpage} ]; then
                TARGET=`ls -l ${manpage} | awk '{ print $NF }'`
                ln -snf ${TARGET}ssl ${manpage}ssl
                rm -f ${manpage}
        else
                mv ${manpage} ${manpage}ssl
        fi
done
for conflict in passwd rand ; do
        rename ${conflict} ssl${conflict} man*/${conflict}*
# Fix dangling symlinks
        manpage=man1/openssl-${conflict}.*
        if [ -L ${manpage} ] ; then
                ln -snf ssl${conflict}.1ssl ${manpage}
        fi
done
popd

mkdir -m755 $RPM_BUILD_ROOT%{_sysconfdir}/pki/CA
mkdir -m700 $RPM_BUILD_ROOT%{_sysconfdir}/pki/CA/private
mkdir -m755 $RPM_BUILD_ROOT%{_sysconfdir}/pki/CA/certs
mkdir -m755 $RPM_BUILD_ROOT%{_sysconfdir}/pki/CA/crl
mkdir -m755 $RPM_BUILD_ROOT%{_sysconfdir}/pki/CA/newcerts

# Ensure the config file timestamps are identical across builds to avoid
# mulitlib conflicts and unnecessary renames on upgrade
touch -r %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/pki/tls/openssl.cnf
touch -r %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/pki/tls/ct_log_list.cnf

rm -f $RPM_BUILD_ROOT%{_sysconfdir}/pki/tls/openssl.cnf.dist
rm -f $RPM_BUILD_ROOT%{_sysconfdir}/pki/tls/ct_log_list.cnf.dist

# Determine which arch opensslconf.h is going to try to #include.
basearch=%{_arch}
%ifarch %{ix86}
basearch=i386
%endif
%ifarch sparcv9
basearch=sparc
%endif
%ifarch sparc64
basearch=sparc64
%endif

%ifarch %{multilib_arches}
# Do an opensslconf.h switcheroo to avoid file conflicts on systems where you
# can have both a 32- and 64-bit version of the library, and they each need
# their own correct-but-different versions of opensslconf.h to be usable.
install -m644 %{SOURCE10} \
        $RPM_BUILD_ROOT/%{_prefix}/include/openssl/opensslconf-${basearch}.h
cat $RPM_BUILD_ROOT/%{_prefix}/include/openssl/opensslconf.h >> \
        $RPM_BUILD_ROOT/%{_prefix}/include/openssl/opensslconf-${basearch}.h
install -m644 %{SOURCE9} \
        $RPM_BUILD_ROOT/%{_prefix}/include/openssl/opensslconf.h
%endif
LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export LD_LIBRARY_PATH

%files
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc FAQ NEWS README README.FIPS
%{_bindir}/make-dummy-cert
%{_bindir}/renew-dummy-cert
%{_bindir}/openssl
%{_mandir}/man1*/*
%{_mandir}/man5*/*
%{_mandir}/man7*/*
%{_pkgdocdir}/Makefile.certificate
%exclude %{_mandir}/man1*/*.pl*
%exclude %{_mandir}/man1*/c_rehash*
%exclude %{_mandir}/man1*/tsget*
%exclude %{_mandir}/man1*/openssl-tsget*

%files libs
%{!?_licensedir:%global license %%doc}
%license LICENSE
%dir %{_sysconfdir}/pki/tls
%dir %{_sysconfdir}/pki/tls/certs
%dir %{_sysconfdir}/pki/tls/misc
%dir %{_sysconfdir}/pki/tls/private
%config(noreplace) %{_sysconfdir}/pki/tls/openssl.cnf
%config(noreplace) %{_sysconfdir}/pki/tls/ct_log_list.cnf
%attr(0755,root,root) %{_libdir}/libcrypto.so.%{version}
%attr(0755,root,root) %{_libdir}/libcrypto.so.%{soversion}
%attr(0755,root,root) %{_libdir}/libssl.so.%{version}
%attr(0755,root,root) %{_libdir}/libssl.so.%{soversion}
%attr(0644,root,root) %{_libdir}/.libcrypto.so.*.hmac
%attr(0644,root,root) %{_libdir}/.libssl.so.*.hmac
%attr(0755,root,root) %{_libdir}/engines-%{soversion}

%files devel
%doc CHANGES doc/dir-locals.example.el doc/openssl-c-indent.el
%{_prefix}/include/openssl
%{_libdir}/*.so
%{_mandir}/man3*/*
%{_libdir}/pkgconfig/*.pc

%files static
%{_libdir}/*.a

%files perl
%{_bindir}/c_rehash
%{_bindir}/*.pl
%{_bindir}/tsget
%{_mandir}/man1*/*.pl*
%{_mandir}/man1*/c_rehash*
%{_mandir}/man1*/tsget*
%{_mandir}/man1*/openssl-tsget*
%dir %{_sysconfdir}/pki/CA
%dir %{_sysconfdir}/pki/CA/private
%dir %{_sysconfdir}/pki/CA/certs
%dir %{_sysconfdir}/pki/CA/crl
%dir %{_sysconfdir}/pki/CA/newcerts

%post libs -p /sbin/ldconfig

%postun libs -p /sbin/ldconfig

%changelog
* Fri Jul 12 2024 xuxl <[email protected]> - 1:1.1.1w-1
- Build for CentOS7.9
  • SPECS附件

openssl.spec

验证SPECS文件

rpmlint ~/rpmbuild/SPECS/openssl.spec

构建rpm包

rpmbuild -D "version 1.1.1w" -ba ~/rpmbuild/SPECS/openssl.spec

参数解释:

  • ba 构建源代码rpm包和二进制rpm包
  • bb 只构建二进制rpm包
  • bs 只构建源代码rpm包
  • bp 执行至%prep阶段(解压源并应用补丁)
  • bc 执行至%build阶段(%prep,然后编译)
  • bi 执行至%install阶段(%prep,%build,然后安装)
  • bl 验证%files部分,查看文件是否存在

报错1

+ rename 'so.%{soversion}' so.1.1.1w '/root/rpmbuild/BUILDROOT/openssl-1.1.1w-1.el7.x86_64/usr/lib64/*.so.%{soversion}'
rename: /root/rpmbuild/BUILDROOT/openssl-1.1.1w-1.el7.x86_64/usr/lib64/*.so.%{soversion}: rename to /root/rpmbuild/BUILDROOT/openssl-1.1.1w-1.el7.x86_64/usr/lib64/*.so.1.1.1w failed: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.gUqD8g (%install)


RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.gUqD8g (%install)

缺少宏soversion参数

报错2

Checking for unpackaged file(s): /usr/lib/rpm/check-files /root/rpmbuild/BUILDROOT/openssl-1.1.1w-1.el7.x86_64
error: Installed (but unpackaged) file(s) found:
   /usr/share/doc/openssl/html/man1/CA.pl.html
   /usr/share/doc/openssl/html/man1/asn1parse.html
   /usr/share/doc/openssl/html/man1/c_rehash.html
  • 参考https://blog.csdn.net/u014007037/article/details/78727526
    修改文件/usr/lib/rpm/macros,注释以下行
    # %__check_files %{_rpmconfigdir}/check-files %{buildroot}

看到如下没有报错的信息说明rpm包成功构建完成

Wrote: /root/rpmbuild/SRPMS/openssl-1.1.1w-1.el7.src.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/openssl-1.1.1w-1.el7.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/openssl-libs-1.1.1w-1.el7.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/openssl-devel-1.1.1w-1.el7.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/openssl-static-1.1.1w-1.el7.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/openssl-perl-1.1.1w-1.el7.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/openssl-debuginfo-1.1.1w-1.el7.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.C4xMQn
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd openssl-1.1.1w
+ /usr/bin/rm -rf /root/rpmbuild/BUILDROOT/openssl-1.1.1w-1.el7.x86_64
+ exit 0

查看构建完成的rpm包

tree /root/rpmbuild/RPMS/
/root/rpmbuild/RPMS/
└── x86_64
    ├── openssl-1.1.1w-1.el7.x86_64.rpm
    ├── openssl-debuginfo-1.1.1w-1.el7.x86_64.rpm
    ├── openssl-devel-1.1.1w-1.el7.x86_64.rpm
    ├── openssl-libs-1.1.1w-1.el7.x86_64.rpm
    ├── openssl-perl-1.1.1w-1.el7.x86_64.rpm
    └── openssl-static-1.1.1w-1.el7.x86_64.rpm

1 directory, 6 files

申明:

  • 该rpm文件仅作学习参考使用,生产环境谨慎使用
  • 该rpm包仅在CentOS 7 x86_64位操作系统升级测试通过,其余系统未经测试;
  • 系统一些组件对原始lib库存在依赖关系,跨大版本升级(1.0.2—>1.1.1)时保留原始lib库可解决;
  • 该rpm包未包含独立FIPS
  • 升级前做好测试跟现有环境版本备份。

升级安装

# 查看当前openssl版本,对需要的包进行升级
openssl version
OpenSSL 1.0.2k-fips  26 Jan 2017

rpm -qa | grep openssl
openssl-libs-1.0.2k-26.el7_9.x86_64
openssl-devel-1.0.2k-26.el7_9.x86_64
openssl-pkcs11-0.4.10-1.el7.x86_64
openssl-1.0.2k-26.el7_9.x86_64

# 强制安装lib文件
rpm -ivh --force openssl-libs-1.1.1w-1.el7.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:openssl-libs-1:1.1.1w-1.el7      ################################# [100%]

rpm -qa | grep openssl
openssl-libs-1.0.2k-26.el7_9.x86_64
openssl-libs-1.1.1w-1.el7.x86_64
openssl-devel-1.0.2k-26.el7_9.x86_64
openssl-pkcs11-0.4.10-1.el7.x86_64
openssl-1.0.2k-26.el7_9.x86_64

# 升级openssl包
rpm -Uvh openssl-1.1.1w-1.el7.x86_64.rpm openssl-devel-1.1.1w-1.el7.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:openssl-devel-1:1.1.1w-1.el7     ################################# [ 25%]
   2:openssl-1:1.1.1w-1.el7           ################################# [ 50%]
Cleaning up / removing...
   3:openssl-devel-1:1.0.2k-26.el7_9  ################################# [ 75%]
   4:openssl-1:1.0.2k-26.el7_9        ################################# [100%]

# 验证升级版本
rpm -qa | grep openssl
openssl-libs-1.0.2k-26.el7_9.x86_64
openssl-libs-1.1.1w-1.el7.x86_64
openssl-devel-1.1.1w-1.el7.x86_64
openssl-1.1.1w-1.el7.x86_64
openssl-pkcs11-0.4.10-1.el7.x86_64

openssl version -a
OpenSSL 1.1.1w  11 Sep 2023
built on: Sat Dec  7 14:11:22 2024 UTC
platform: linux-x86_64
options:  bn(64,64) rc4(16x,int) des(int) idea(int) blowfish(ptr)
compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DZLIB -DNDEBUG
OPENSSLDIR: "/etc/pki/tls"
ENGINESDIR: "/usr/lib64/engines-1.1"
Seeding source: os-specific

总结

到此openssl的rpm打包升级顺利完成,打包过程中也遇到很多问题,网上搜了很多资料参考,总结关键步骤是SPECS文件编写跟打包文件准备,找了CentOS的specs文件为模板进行编写修改。在%check检查这步总是报错,最后直接注释才通过,有更好方法解决的朋友可以交流下。

参考文档

https://git.centos.org/rpms/openssl/releases
https://blog.mdzz.wang/2024/03/07/081.openssl_rpm_build/
https://www.wanhebin.com/linux_basic/1029.html
https://docs.fedoraproject.org/en-US/package-maintainers/CommonRpmlintIssues/

https://docs.redhat.com/zh_hans/documentation/red_hat_enterprise_linux/8/html/packaging_and_distributing_software/building-rpms_packaging-software
http://ftp.rpm.org/max-rpm/ch-rpm-b-command.html
https://www.cnblogs.com/yipianchuyun/p/15442896.html
https://www.cnblogs.com/yuhaohao/p/12894875.html

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据