The use and installation of SRPM source code package in Linux

Philosophy of life 2020-11-10 16:22:36
use installation srpm source code


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
[root@node5 ~]# 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
[root@node5 ~]# rpm -q lrzsz
lrzsz-0.12.20-36.el7.x86_64
# First, uninstall the installed lrzsz Program
[root@node5 ~]# yum remove lrzsz -y
[root@node5 ~]# rpm -q lrzsz
package lrzsz is not installed
# take src.rpm Package progress “ compile ” And “ pack ” produce RPM Installation package
[root@node5 ~]# 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
[root@node5 ~]# yum install rpm-build
# take src.rpm Package progress “ compile ” And “ pack ” produce RPM Installation package
[root@node5 ~]# rpmbuild --rebuild lrzsz-0.12.20-27.1.el6.src.rpm
[root@node5 ~]# echo $?
0
[root@node5 ~]# ls rpmbuild/
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
[root@node5 ~]# ls rpmbuild/RPMS/
x86_64
#rpmbuild --rebuild This step produces rpm The installation package is in /root/rpmbuild/RPMS/x86_64/ below
[root@node5 ~]# 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
[root@node5 ~]# 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
[root@node5 ~]# 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
[root@node5 ~]# rpm -ivh ntp-4.2.6p5-19.el7.centos.1.src.rpm
[root@node5 ~]# 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
[root@node5 ~]# 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
[root@node5 ~]# rpm -ivh ntp-4.2.6p5-19.el7.centos.1.src.rpm
# decompression srpm After the package , All documents are in rpmbuild Directory
[root@node5 ~]# ls rpmbuild/
SOURCES SPECS
[root@node5 ~]# ls rpmbuild/SPECS/
ntp.spec
[root@node5 ~]# 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
[root@node5 ~]# 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
[root@node5 ~]# 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
[root@node5 ~]# rpmbuild -ba /root/rpmbuild/SPECS/ntp.spec
[root@node5 ~]# echo $?
0
[root@node5 ~]# ls /root/rpmbuild/
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
[root@node5 ~]# ls /root/rpmbuild/RPMS/
noarch x86_64
[root@node5 ~]# 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
[root@node5 ~]# 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)/

https://blog.csdn.net/huangdeijia/article/details/88953444

版权声明
本文为[Philosophy of life]所创,转载请带上原文链接,感谢

  1. 【计算机网络 12(1),尚学堂马士兵Java视频教程
  2. 【程序猿历程,史上最全的Java面试题集锦在这里
  3. 【程序猿历程(1),Javaweb视频教程百度云
  4. Notes on MySQL 45 lectures (1-7)
  5. [computer network 12 (1), Shang Xuetang Ma soldier java video tutorial
  6. The most complete collection of Java interview questions in history is here
  7. [process of program ape (1), JavaWeb video tutorial, baidu cloud
  8. Notes on MySQL 45 lectures (1-7)
  9. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  10. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  11. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  12. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  13. 【递归,Java传智播客笔记
  14. [recursion, Java intelligence podcast notes
  15. [adhere to painting for 386 days] the beginning of spring of 24 solar terms
  16. K8S系列第八篇(Service、EndPoints以及高可用kubeadm部署)
  17. K8s Series Part 8 (service, endpoints and high availability kubeadm deployment)
  18. 【重识 HTML (3),350道Java面试真题分享
  19. 【重识 HTML (2),Java并发编程必会的多线程你竟然还不会
  20. 【重识 HTML (1),二本Java小菜鸟4面字节跳动被秒成渣渣
  21. [re recognize HTML (3) and share 350 real Java interview questions
  22. [re recognize HTML (2). Multithreading is a must for Java Concurrent Programming. How dare you not
  23. [re recognize HTML (1), two Java rookies' 4-sided bytes beat and become slag in seconds
  24. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  25. RPC 1: how to develop RPC framework from scratch
  26. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  27. RPC 1: how to develop RPC framework from scratch
  28. 一次性捋清楚吧,对乱糟糟的,Spring事务扩展机制
  29. 一文彻底弄懂如何选择抽象类还是接口,连续四年百度Java岗必问面试题
  30. Redis常用命令
  31. 一双拖鞋引发的血案,狂神说Java系列笔记
  32. 一、mysql基础安装
  33. 一位程序员的独白:尽管我一生坎坷,Java框架面试基础
  34. Clear it all at once. For the messy, spring transaction extension mechanism
  35. A thorough understanding of how to choose abstract classes or interfaces, baidu Java post must ask interview questions for four consecutive years
  36. Redis common commands
  37. A pair of slippers triggered the murder, crazy God said java series notes
  38. 1、 MySQL basic installation
  39. Monologue of a programmer: despite my ups and downs in my life, Java framework is the foundation of interview
  40. 【大厂面试】三面三问Spring循环依赖,请一定要把这篇看完(建议收藏)
  41. 一线互联网企业中,springboot入门项目
  42. 一篇文带你入门SSM框架Spring开发,帮你快速拿Offer
  43. 【面试资料】Java全集、微服务、大数据、数据结构与算法、机器学习知识最全总结,283页pdf
  44. 【leetcode刷题】24.数组中重复的数字——Java版
  45. 【leetcode刷题】23.对称二叉树——Java版
  46. 【leetcode刷题】22.二叉树的中序遍历——Java版
  47. 【leetcode刷题】21.三数之和——Java版
  48. 【leetcode刷题】20.最长回文子串——Java版
  49. 【leetcode刷题】19.回文链表——Java版
  50. 【leetcode刷题】18.反转链表——Java版
  51. 【leetcode刷题】17.相交链表——Java&python版
  52. 【leetcode刷题】16.环形链表——Java版
  53. 【leetcode刷题】15.汉明距离——Java版
  54. 【leetcode刷题】14.找到所有数组中消失的数字——Java版
  55. 【leetcode刷题】13.比特位计数——Java版
  56. oracle控制用户权限命令
  57. 三年Java开发,继阿里,鲁班二期Java架构师
  58. Oracle必须要启动的服务
  59. 万字长文!深入剖析HashMap,Java基础笔试题大全带答案
  60. 一问Kafka就心慌?我却凭着这份,图灵学院vip课程百度云