当前位置:网站首页>How to make an RPM file
How to make an RPM file
2022-07-02 05:03:00 【Teacher Liu Trent】
They are archives containing files and metadata . When installing or uninstalling RPM when , This metadata tells RPM Where to create or delete files . As you will remember in the last article , Metadata also contains information about “ Dependencies ” Information about , It can be “ Runtime ” or “ Build time ” Of information .
for example , Let's see fpaste. You can use dnf Download the RPM. This will download Fedora What's available in the repository fpaste The latest version . stay Fedora 30 On , The current version is 0.3.9.2:
$ dnf download fpaste
...
fpaste-0.3.9.2-2.fc30.noarch.rpm
- 1.
- 2.
- 3.
- 4.
Because this is a build RPM, So it only includes the use of fpaste Documents required :
$ rpm -qpl ./fpaste-0.3.9.2-2.fc30.noarch.rpm
/usr/bin/fpaste
/usr/share/doc/fpaste
/usr/share/doc/fpaste/README.rst
/usr/share/doc/fpaste/TODO
/usr/share/licenses/fpaste
/usr/share/licenses/fpaste/COPYING
/usr/share/man/man1/fpaste.1.gz
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
Source RPM
The next link in this chain is the source RPM.Fedora All software in must be built from its source code . We don't include pre built binaries . therefore , To make a RPM file ,RPM( Tools ) need :
- Give the files that must be installed ,
- for example , If you want to compile these files , Then tell them how to generate these files ,
- Tell where these files must be installed ,
- What other dependencies are needed for this particular software to work properly .
Source RPM Have all this information . Source RPM And build RPM be similar , But as the name suggests , They don't contain built binaries , It's a source file that contains some software . Let's download fpaste Source RPM:
$ dnf download fpaste --source
...
fpaste-0.3.9.2-2.fc30.src.rpm
- 1.
- 2.
- 3.
- 4.
Note that the end of the document is src.rpm. be-all RPM All from the source RPM Built . You can also use dnf Easy inspection “ Binary system ” RPM Source RPM:
$ dnf repoquery --qf "%{SOURCERPM}" fpaste
fpaste-0.3.9.2-2.fc30.src.rpm
- 1.
- 2.
in addition , Because this is the source RPM, So it doesn't contain the built files . contrary , It contains information about how to build RPM Source code and instructions :
$ rpm -qpl ./fpaste-0.3.9.2-2.fc30.src.rpm
fpaste-0.3.9.2.tar.gz
fpaste.spec
- 1.
- 2.
- 3.
here , The first file is just fpaste Source code . The second is spec file .spec The file is a recipe , Can tell RPM( Tools ) How to use the source RPM Source code creation included in RPM( Archives )— It contains RPM( Tools ) structure RPM( Archives ) All the information you need . stay spec In file . When our package maintainers add software to Fedora In the middle of the day , We spend most of our time writing and perfecting spec On the file . When the package needs to be updated , We'll turn around and adjust spec file . You can https://src.fedoraproject.org/browse/projects/ View the source code repository of Fedora Of all packages in spec file .
Please note that , A source RPM It may involve building multiple RPM Explanation .fpaste Is a very simple software , A source RPM Generate a “ Binary system ” RPM. and Python It's more complicated . Although there is only one source RPM, But it will generate multiple binaries RPM:
$ sudo dnf repoquery --qf "%{SOURCERPM}" python3
python3-3.7.3-1.fc30.src.rpm
python3-3.7.4-1.fc30.src.rpm
$ sudo dnf repoquery --qf "%{SOURCERPM}" python3-devel
python3-3.7.3-1.fc30.src.rpm
python3-3.7.4-1.fc30.src.rpm
$ sudo dnf repoquery --qf "%{SOURCERPM}" python3-libs
python3-3.7.3-1.fc30.src.rpm
python3-3.7.4-1.fc30.src.rpm
$ sudo dnf repoquery --qf "%{SOURCERPM}" python3-idle
python3-3.7.3-1.fc30.src.rpm
python3-3.7.4-1.fc30.src.rpm
$ sudo dnf repoquery --qf "%{SOURCERPM}" python3-tkinter
python3-3.7.3-1.fc30.src.rpm
python3-3.7.4-1.fc30.src.rpm
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
use RPM In jargon ,“python3” yes “ Main package ”, So it's time to spec The document will be called python3.spec. All other packages are “ Sub packages ”. You can download python3 Source RPM, And see what's in it .( Tips : Patches are also part of the source code ):
$ dnf download --source python3
python3-3.7.4-1.fc30.src.rpm
$ rpm -qpl ./python3-3.7.4-1.fc30.src.rpm
00001-rpath.patch
00102-lib64.patch
00111-no-static-lib.patch
00155-avoid-ctypes-thunks.patch
00170-gc-assertions.patch
00178-dont-duplicate-flags-in-sysconfig.patch
00189-use-rpm-wheels.patch
00205-make-libpl-respect-lib64.patch
00251-change-user-install-location.patch
00274-fix-arch-names.patch
00316-mark-bdist_wininst-unsupported.patch
Python-3.7.4.tar.xz
check-pyc-timestamps.py
idle3.appdata.xml
idle3.desktop
python3.spec
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
From source RPM structure RPM
Now we have the source RPM, And what's in it , We can rebuild RPM. however , Before doing this , We should set up the system to build RPM. First , We install the necessary tools :
$ sudo dnf install fedora-packager
- 1.
This will install rpmbuild Tools .rpmbuild You need a default layout , So that it knows the source RPM The location of each required component in . Let's see what they are :
$ rpm -E %{_specdir}
/home/asinha/rpmbuild/SPECS
$ rpm -E %{_sourcedir}
/home/asinha/rpmbuild/SOURCES
$ rpm -E %{_builddir}
/home/asinha/rpmbuild/BUILD
$ rpm -E %{_buildrootdir}
/home/asinha/rpmbuild/BUILDROOT
$ rpm -E %{_srcrpmdir}
/home/asinha/rpmbuild/SRPMS
$ rpm -E %{_rpmdir}
/home/asinha/rpmbuild/RPMS
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
I've set up all these directories on the system :
$ cd
$ tree -L 1 rpmbuild/
rpmbuild/
├── BUILD
├── BUILDROOT
├── RPMS
├── SOURCES
├── SPECS
└── SRPMS
6 directories, 0 files
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
RPM It also provides a tool for you to set up all of them :
$ rpmdev-setuptree
- 1.
then , Make sure it is installed fpaste All build dependencies for :
sudo dnf builddep fpaste-0.3.9.2-3.fc30.src.rpm
- 1.
about fpaste, You only need to Python, And it must have been installed on your system (dnf Also used Python). Can also give builddep command One spec file , Not the source RPM. Learn more on the manual page :
$ man dnf.plugin.builddep
- 1.
Now we have everything we need , From source RPM Construct a RPM It's as simple as this :
$ rpmbuild --rebuild fpaste-0.3.9.2-3.fc30.src.rpm
..
..
$ tree ~/rpmbuild/RPMS/noarch/
/home/asinha/rpmbuild/RPMS/noarch/
└── fpaste-0.3.9.2-3.fc30.noarch.rpm
0 directories, 1 file
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
rpmbuild Will install source RPM And build your RPM. Now? , You can use dnf install RPM To use it . Of course , As mentioned earlier , If you want to RPM Make any changes in , You have to modify spec file , We'll introduce... In the next article spec file .
summary
To summarize this article, there are two points :
- We usually install the RPM It contains the build version of the software “ Binary system ” RPM
- structure RPM From source RPM, Source RPM Include for binary generation RPM Required source code and specification files .
边栏推荐
- LM09丨费雪逆变换反转网格策略
- Starting from the classification of database, I understand the map database
- Comp 250 parsing
- How to recover deleted data in disk
- 奠定少儿编程成为基础学科的原理
- How to configure PostgreSQL 12.9 to allow remote connections
- Oracle stored procedure and job task setting
- 6.30年终小结,学生时代结束
- The El cascader echo only selects the questions that are not displayed
- National all Chinese Automatic Test Software apifox
猜你喜欢

2022阿里巴巴全球数学竞赛 第4题 虎虎生威(盲盒问题、集卡问题)解决思路

06 decorator mode

Differential identities (help find mean, variance, and other moments)

Analyze the space occupied by the table according to segments, clusters and pages

Unity particle Foundation

ansible安装与使用

How do I interview for a successful software testing position? If you want to get a high salary, you must see the offer

農業生態領域智能機器人的應用

Here comes the chicken soup! Keep this quick guide for data analysts

C case of communication between server and client based on mqttnet
随机推荐
Here comes the chicken soup! Keep this quick guide for data analysts
Orthogonal test method and function diagram method for test case design
[high speed bus] Introduction to jesd204b
Splice characters in {{}}
Video multiple effects production, fade in effect and border background are added at the same time
Set the default style of scroll bar Google browser
6.30年终小结,学生时代结束
Vmware安装win10报错:operating system not found
函数中使用sizeof(arr) / sizeof(arr[0])求数组长度不正确的原因
Leetcode basic programming: array
農業生態領域智能機器人的應用
Solution: the agent throws an exception error
win10 磁盘管理 压缩卷 无法启动问题
Unity particle Foundation
培养中小学生对教育机器人的热爱之心
正大留4的主账户信息汇总
Mathematical knowledge -- understanding and examples of fast power
Ruby replaces gem Alibaba image
TypeScript类的使用
Acelems Expressway microgrid energy efficiency management platform and intelligent lighting solution intelligent lighting tunnel