当前位置:网站首页>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 .
边栏推荐
- 数学知识——快速幂的理解及例题
- Realize the function of data uploading
- Comp 250 parsing
- Line by line explanation of yolox source code of anchor free series network (7) -- obj in head_ loss、Cls_ Loss and reg_ Calculation and reverse transmission of loss I
- Splice characters in {{}}
- Preparation for writing SAP ui5 applications using typescript
- Several methods of capturing packets under CS framework
- Common errors of dmrman offline backup
- Practical problem solving ability of steam Education
- [opencv] image binarization
猜你喜欢
Introduction to Luogu 3 [circular structure] problem list solution
Simple and practical accounting software, so that accounts can be checked
将光盘中的cda保存到电脑中
Cannot activate CONDA virtual environment in vscode
正大美欧4的主账户关注什么数据?
List of common bugs in software testing
Mathematical problems (number theory) trial division to judge prime numbers, decompose prime factors, and screen prime numbers
Hcip day 17
Application of intelligent robot in agricultural ecology
LeetCode 1175. 质数排列(质数判断+组合数学)
随机推荐
Feign realizes file uploading and downloading
win10 磁盘管理 压缩卷 无法启动问题
Leetcode merge sort linked list
Mouse events in JS
解析少儿编程中的动手搭建教程
idea自动导包和自动删包设置
Pytest learning ----- pytest Interface Association framework encapsulation of interface automation testing
DJB Hash
Comp 250 parsing
go实现leetcode旋转数组
将光盘中的cda保存到电脑中
Learn BeanShell before you dare to say you know JMeter
oracle 存储过程与job任务设置
Summary of common string processing functions in C language
國產全中文-自動化測試軟件Apifox
Mapping settings in elk (8) es
TypeScript函数详解
Summary of MySQL key challenges (2)
Common errors of dmrman offline backup
Case sharing | intelligent Western Airport