If you need to reprint, please indicate the source: http://blog.csdn.net/itas109
QQ technology exchange group: 129518033

Related questions:
1.rpm packing
2.spec packaging script file
3. Extract spec by rpm
4.deb and rpm conversion
5.rpm unpacking


Rpm is the abbreviation of red hat package manager, similar to msi installation package under windows.

The main purpose of rpm repackaging is as follows:

  • Installation package is not fully fit for purpose
  • Quickly generate installation package from the results of source compilation

1. Tools required

The main tools required are as follows:

  • RPM build (packaging)
  • rpmrebuild (unpacking)


sudo yum install rpm-build rpmrebuild

2. unpack

The following is described in redis-5.0.5-1.fc27.x86_.rpm.

2.1 create packing directory

rpmrebuild -p redis-5.0.5-1.fc27.x86_64.rpm

The directory ~ / rpmbuild will be added after execution

2.2 extraction of SPEC documents

rpmrebuild -s redis.spec -p redis-5.0.5-1.fc27.x86_64.rpm

Put the redis.spec file in the ~ / rpmbuild/SPECS directory

cp redis.spec ~/rpmbuild/SPECS

2.3 extract rpm file

  • Create build folder

To view redis.spec:

BuildArch:     x86_64
Name:          redis
Version:       5.0.5
Release:       1.fc27

Create the folder Name-Version-Release.BuildArch in ~ / rpmbuild/BUILDROOT /, i.e. redis-5.0.5-1.fc27.x86_

mkdir ~/rpmbuild/BUILDROOT/redis-5.0.5-1.fc27.x86_64
  • Extract all files of rpm
rpm2cpio redis-5.0.5-1.fc27.x86_64.rpm | cpio -div
  • rpm extract file copy to create folder

Copy the extracted file to ~ / rpmbuild / buildroot / redis-5.0.5-1.fc27.x86_directory

File structure:

$ tree

│   └── redis-5.0.5-1.fc27.x86_64
│       └── usr
│           └── local
│               └── bin
│                   ├── redis-benchmark
│                   ├── redis-check-aof -> redis-server
│                   ├── redis-check-rdb -> redis-server
│                   ├── redis-cli
│                   ├── redis-sentinel -> redis-server
│                   └── redis-server
├── RPMS
│   └── x86_64
│       └── redis-5.0.5-1.fc27.x86_64.rpm
│   └── redis.spec

3. Customize and modify spec file

The main contents of redis.spec are as follows:

# rpmrebuild autogenerated specfile

%define defaultbuildroot /
AutoProv: no
%undefine __find_provides
AutoReq: no
%undefine __find_requires
# Do not try autogenerate prereq/conflicts/obsoletes and check files
%undefine __check_files
%undefine __find_prereq
%undefine __find_conflicts
%undefine __find_obsoletes
# Be sure buildpolicy set to do nothing
%define __spec_install_post %{nil}
# Something that need for rpm-4.1
%define _missing_doc_files_terminate_build 0

#OS:           linux
#SIZE:           3250168
#ARCHIVESIZE:           3251180
#ARCH:         x86_64
BuildArch:     x86_64
Name:          redis
Version:       5.0.5
Release:       1.fc27
License:       BSD 
Group:         Applications/Databases
Summary:       A persistent key-value database

Provides:      bundled(hiredis)  
Provides:      bundled(jemalloc) = 5.1.0
Provides:      bundled(linenoise)  
Provides:      bundled(lua-libs)  
Provides:      bundled(lzf)  
Provides:      config(redis) = 5.0.5-1.fc27
Provides:      redis = 5.0.5-1.fc27
Provides:      redis(modules_abi)(x86-64) = 1
Provides:      redis(x86-64) = 5.0.5-1.fc27
Requires:      /bin/awk  
Requires:      /bin/bash  
Requires:      /bin/sh  
Requires:      config(redis) = 5.0.5-1.fc27
Requires:      ld-linux-x86-64.so.2()(64bit)  
Requires:      ld-linux-x86-64.so.2(GLIBC_2.3)(64bit)  
Requires:      libc.so.6()(64bit)  
Requires:      libc.so.6(GLIBC_2.11)(64bit)  
Requires:      libc.so.6(GLIBC_2.14)(64bit)  
Requires:      libc.so.6(GLIBC_2.17)(64bit)  
Requires:      libc.so.6(GLIBC_2.2.5)(64bit)  
Requires:      libc.so.6(GLIBC_2.3)(64bit)  
Requires:      libc.so.6(GLIBC_2.3.2)(64bit)  
Requires:      libc.so.6(GLIBC_2.3.4)(64bit)  
Requires:      libc.so.6(GLIBC_2.4)(64bit)  
Requires:      libc.so.6(GLIBC_2.6)(64bit)  
Requires:      libc.so.6(GLIBC_2.7)(64bit)  
Requires:      libdl.so.2()(64bit)  
Requires:      libdl.so.2(GLIBC_2.2.5)(64bit)  
Requires:      libm.so.6()(64bit)  
Requires:      libm.so.6(GLIBC_2.2.5)(64bit)  
Requires:      libpthread.so.0()(64bit)  
Requires:      libpthread.so.0(GLIBC_2.12)(64bit)  
Requires:      libpthread.so.0(GLIBC_2.2.5)(64bit)  
Requires:      libpthread.so.0(GLIBC_2.3.2)(64bit)  
Requires:      librt.so.1()(64bit)  
Requires:      librt.so.1(GLIBC_2.2.5)(64bit)  
Requires:      logrotate  
Requires:      rtld(GNU_HASH)  
Requires:      shadow-utils  
Requires:      systemd  
#Requires:      rpmlib(FileDigests) <= 4.6.0-1
#Requires:      rpmlib(PayloadFilesHavePrefix) <= 4.0-1
#Requires:      rpmlib(CompressedFileNames) <= 3.0.4-1
#Requires:      rpmlib(PayloadIsXz) <= 5.2-1


%attr(0755, root, root) "/usr/local/bin/redis-benchmark"
%attr(0777, root, root) "/usr/local/bin/redis-check-aof"
%attr(0777, root, root) "/usr/local/bin/redis-check-rdb"
%attr(0755, root, root) "/usr/local/bin/redis-cli"
%attr(0777, root, root) "/usr/local/bin/redis-sentinel"
%attr(0755, root, root) "/usr/local/bin/redis-server"


Mainly need to be modified

  • Requires
  • %files
  • Script (pre install script% pre install script% post pre uninstall script% preun post uninstall script% post)

4. pack

rpmbuild common parameters:

  • -bb compile only binary rpm packages
  • -bs only compiles source rpm package
  • -ba compiles both binary and source rpm packages
cd ~/rpmbuild/SPECS

rpmbuild -ba redis.spec


sudo rpm -ivh redis-5.0.5-1.fc27.x86_64.rpm

5. other

5.1 conversion of RPM and deb

Install alien


tar xvf alien_8.95.tar.xz
perl Makefile.PL
sudo make instal

rpm to deb

# alien redis-server-5.0.7-2.x86_64.rpm 
redis-server_5.0.7-3_amd64.deb generated


dpkg -i redis-server_5.0.7-3_amd64.deb

deb to rpm

# alien -r redis-server_5.0.7-1_amd64.deb 

Warning: Skipping conversion of scripts in package redis-server: postinst postrm preinst prerm
Warning: Use the --scripts parameter to include the scripts.
redis-server-5.0.7-2.x86_64.rpm generated


rpm -ivh redis-server-5.0.7-2.x86_64.rpm


Q: Can't locate ExtUtils/MakeMaker.pm

A: sudo yum install perl-ExtUtils-MakeMaker


License under CC BY-NC-ND 4.0: signature - non-commercial use - deduction prohibited


225 original articles published, 218 praised, 830000 visitors+
His message board follow

Tags: Redis RPM sudo Linux

Posted on Sat, 08 Feb 2020 06:59:56 -0500 by EvanAgee