One . About srpm package
SRPM Bag is Source RPM For short ,SRPM The package contains the source code , If you want to install SRPM package , Need to be RPM Manage the way to compile , take SRPM Compile it into
RPM file , Then compile the completed RPM The files are installed to Linux In the system .SRPM The biggest advantage is that users can modify the setting parameters by themselves , To match the user himself
Of Linux Environmental Science ;
Two .srpm Bao He rpm The difference between packages
File format | Package name format | Whether it can be directly installed | Contains the type of program | Can I modify the parameters and compile |
---|---|---|---|---|
RPM | xxx.rpm | can | Compiled binaries | must not |
SRPM | xxx.src.rpm | must not | Source code | can |
3、 ... and . incorrect srpm Package changes , Direct installation srpm package
1. When we get one srpm When the package , We're not prepared for srpm Package changes , When you want to install it directly , There are two ways to install :
- Method 1 :rpmbuild --rebuild ***.src.rpm , This order will src.rpm Package progress “ compile ” And “ pack ” produce RPM Installation package , And then we can use it rpm -ivh Installation ;
- Method 2 :rpmbuild --recompile ***.src.rpm, This order will src.rpm Package progress “ compile ”,“ pack ” And installation . After executing this command srpm The package has been installed .
2. Use the first method to install srpm package (rpmbuild --rebuild)
# Prepare one srpm Source package lrzsz
[[email protected] ~]# ll lrzsz-0.12.20-27.1.el6.src.rpm
-rw-r--r-- 1 root root 290240 Oct 25 2018 lrzsz-0.12.20-27.1.el6.src.rpm
[[email protected] ~]# rpm -q lrzsz
lrzsz-0.12.20-36.el7.x86_64
# First, uninstall the installed lrzsz Program
[[email protected] ~]# yum remove lrzsz -y
[[email protected] ~]# rpm -q lrzsz
package lrzsz is not installed
# take src.rpm Package progress “ compile ” And “ pack ” produce RPM Installation package
[[email protected] ~]# rpmbuild --rebuild lrzsz-0.12.20-27.1.el6.src.rpm
-bash: rpmbuild: command not found
# Found no rpmbuild This command , It needs to be installed first
[[email protected] ~]# yum install rpm-build
# take src.rpm Package progress “ compile ” And “ pack ” produce RPM Installation package
[[email protected] ~]# rpmbuild --rebuild lrzsz-0.12.20-27.1.el6.src.rpm
[[email protected] ~]# echo $?
0
[[email protected] ~]# ls rpmbuild/
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
[[email protected] ~]# ls rpmbuild/RPMS/
x86_64
#rpmbuild --rebuild This step produces rpm The installation package is in /root/rpmbuild/RPMS/x86_64/ below
[[email protected] ~]# ls rpmbuild/RPMS/x86_64/
lrzsz-0.12.20-27.1.el7.centos.x86_64.rpm lrzsz-debuginfo-0.12.20-27.1.el7.centos.x86_64.rpm
# install rpm package
[[email protected] ~]# rpm -ivh /root/rpmbuild/RPMS/x86_64/lrzsz-0.12.20-27.1.el7.centos.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:lrzsz-0.12.20-27.1.el7.centos ################################# [100%]
# Since then ,lrzsz Has been re installed
[[email protected] ~]# rpm -q lrzsz
lrzsz-0.12.20-27.1.el7.centos.x86_64
Four . Yes srpm Package source code to modify , Then install srpm package
1.srpm The package contains the source code , There must be configuration files and related directories , Let's start with srpm The role of each directory in the package . decompression srpm After the package , It usually generates a rpmbuild Catalog , We are in /root Generated in the directory , So decompress srpm After the package , The corresponding files are in /root/rpmbuild/ below :
# decompression srpm package
[[email protected] ~]# rpm -ivh ntp-4.2.6p5-19.el7.centos.1.src.rpm
[[email protected] ~]# ls /root/rpmbuild/
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
Directory name | Directory function description |
---|---|
/root/rpmbuild/SPECS | In this directory is the configuration file of the software , For example, the information parameters of this software 、 Set up items and so on are placed here ,SPECS There are usually ***.spec The configuration file ; |
/root/rpmbuild/SOURCES | In this directory are the original files of the software (*.tar.gz The file of ) as well as config This configuration file ; |
/root/rpmbuild/BUILD | During compilation , Some temporary data will be placed in this directory ; |
/root/rpmbuild/RPMS | After compiling , And after the successful compilation , Put the packaged files in this directory . It contains x86_64, noarch…. And so on ; |
/root/rpmbuild/SRPMS | And RPMS Similar within , Here's what's in there SRPM Encapsulated files , Sometimes you want to use your software with SRPM The way to release , Yours SRPM The files will be placed in this directory . |
2. When we get one srpm When the package , We're ready for srpm Package changes , It's usually a modification SPECS In the catalog ***.spec file , And then compile it into rpm Packages or srpm package , There are two compilation instructions :
rpmbuild -ba rpmbuild/SPECS/***.spec # Compile generation RPM File with the SRPM file
rpmbuild -bb rpmbuild/SPECS/***.spec # Only compiled into RPM file
# First download what we need srpm package
[[email protected] ~]# wget http://vault.centos.org/7.1.1503/updates/Source/SPackages/ntp-4.2.6p5-19.el7.centos.1.src.rpm
# decompression srpm package , There's going to be a bunch of warn, But it doesn't affect
[[email protected] ~]# rpm -ivh ntp-4.2.6p5-19.el7.centos.1.src.rpm
# decompression srpm After the package , All documents are in rpmbuild Directory
[[email protected] ~]# ls rpmbuild/
SOURCES SPECS
[[email protected] ~]# ls rpmbuild/SPECS/
ntp.spec
[[email protected] ~]# ls rpmbuild/SOURCES/
ntp-4.2.4p7-getprecision.patch ntp-4.2.6p4-droproot.patch ntp-4.2.6p5-fipsmd5.patch ntp-4.2.6p5-pwcipher.patch ntp.cryptopw ntp.keys ntp.step-tickers
ntp-4.2.6p1-cmsgalign.patch ntp-4.2.6p4-htmldoc.patch ntp-4.2.6p5-hexpw.patch ntp-4.2.6p5-refreshroute.patch ntpdate.service ntpstat-0.2-clksrc.patch ntp-wait.service
ntp-4.2.6p1-linkfastmath.patch ntp-4.2.6p5-cve-2014-9293.patch ntp-4.2.6p5-identlen.patch ntp-4.2.6p5-rootdisp.patch ntpdate.sysconfig ntpstat-0.2-errorbit.patch sntp.service
ntp-4.2.6p1-retcode.patch ntp-4.2.6p5-cve-2014-9294.patch ntp-4.2.6p5-logdefault.patch ntp-4.2.6p5.tar.gz ntpdate.wrapper ntpstat-0.2-maxerror.patch sntp.sysconfig
ntp-4.2.6p1-sleep.patch ntp-4.2.6p5-cve-2014-9295.patch ntp-4.2.6p5-mlock.patch ntp-4.2.6p5-updatebclient.patch ntp.dhclient ntpstat-0.2-multipacket.patch
ntp-4.2.6p3-bcast.patch ntp-4.2.6p5-cve-2014-9296.patch ntp-4.2.6p5-multiopts.patch ntp-4.2.6p5-xleap.patch ntpd.service ntpstat-0.2-sysvars.patch
ntp-4.2.6p3-broadcastdelay.patch ntp-4.2.6p5-delaycalib.patch ntp-4.2.6p5-noservres.patch ntp.conf ntpd.sysconfig ntpstat-0.2.tgz
# Let's assume that we have modified rpmbuild/SPECS/ntp.spec The configuration file , Now compile
[[email protected] ~]# rpmbuild -ba /root/rpmbuild/SPECS/ntp.spec
error: Failed build dependencies:
libedit-devel is needed by ntp-4.2.6p5-19.el7.centos.1.x86_64
perl-HTML-Parser is needed by ntp-4.2.6p5-19.el7.centos.1.x86_64
pps-tools-devel is needed by ntp-4.2.6p5-19.el7.centos.1.x86_64
autogen is needed by ntp-4.2.6p5-19.el7.centos.1.x86_64
autogen-libopts-devel is needed by ntp-4.2.6p5-19.el7.centos.1.x86_64
# The basis for misreporting is known , Lack of dependency packages , Let's install
[[email protected] ~]# yum -y install libedit-devel perl-HTML-Parser pps-tools-devel autogen autogen-libopts-devel
# Let's assume that we have modified rpmbuild/SPECS/ntp.spec The configuration file , Now compile
[[email protected] ~]# rpmbuild -ba /root/rpmbuild/SPECS/ntp.spec
[[email protected] ~]# echo $?
0
[[email protected] ~]# ls /root/rpmbuild/
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
[[email protected] ~]# ls /root/rpmbuild/RPMS/
noarch x86_64
[[email protected] ~]# ls /root/rpmbuild/RPMS/x86_64/
ntp-4.2.6p5-19.el7.centos.1.x86_64.rpm ntpdate-4.2.6p5-19.el7.centos.1.x86_64.rpm ntp-debuginfo-4.2.6p5-19.el7.centos.1.x86_64.rpm sntp-4.2.6p5-19.el7.centos.1.x86_64.rpm
[[email protected] ~]# ls /root/rpmbuild/SRPMS/
ntp-4.2.6p5-19.el7.centos.1.src.rpm
Since then, we have successfully compiled rpm Bao He srpm package , Now you just need to follow “ incorrect srpm Package changes , Direct installation srpm package ” Can be installed .
Reference link :
https://www.bluestep.cc/22-4-srpm- Use -:-rpmbuild-(optional)/