当前位置:网站首页>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 .
边栏推荐
- Save the CDA from the disc to the computer
- Summary of main account information of zhengdaliu 4
- idea自动导包和自动删包设置
- Virtual machine installation deepin system
- Basic differences between Oracle and MySQL (entry level)
- Mathematical knowledge -- understanding and examples of fast power
- Change deepin to Alibaba image source
- Video multiple effects production, fade in effect and border background are added at the same time
- 國產全中文-自動化測試軟件Apifox
- Ansible installation and use
猜你喜欢

Cultivate primary and secondary school students' love for educational robots

Idea automatic package import and automatic package deletion settings

Lm09 Fisher inverse transform inversion mesh strategy

Pycharm breakpoint management: temporarily cancel some breakpoints + run directly to a line

How to recover deleted data in disk

Simple and practical accounting software, so that accounts can be checked

TypeScript函数详解

Application d'un robot intelligent dans le domaine de l'agroécologie

Johnson–Lindenstrauss Lemma(2)

正大美欧4的主账户关注什么数据?
随机推荐
Set the default style of scroll bar Google browser
LeetCode 1175. 质数排列(质数判断+组合数学)
How to write a client-side technical solution
What are the rules and trading hours of agricultural futures contracts? How much is the handling fee deposit?
Idea autoguide package and autodelete package Settings
【ClickHouse】How to create index for Map Type Column or one key of it?
農業生態領域智能機器人的應用
Solution: the agent throws an exception error
Ansible installation and use
06 装饰(Decorator)模式
关于Steam 教育的知识整理
Steam教育的实际问题解决能力
数学问题(数论)试除法做质数的判断、分解质因数,筛质数
go实现leetcode旋转数组
数据库问题汇总
fastText文本分类
Future trend of automated testing ----- self healing technology
Rhcsa --- work on the fourth day
培养中小学生对教育机器人的热爱之心
MMAP zero copy knowledge point notes