当前位置:网站首页>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 .
边栏推荐
- [common error] the DDR type of FPGA device is selected incorrectly
- 在{{}}中拼接字符
- Cannot activate CONDA virtual environment in vscode
- Common errors of dmrman offline backup
- 农业生态领域智能机器人的应用
- Splice characters in {{}}
- Starting from the classification of database, I understand the map database
- Application of intelligent robot in agricultural ecology
- Use of typescript classes
- js中的Map(含leetcode例题)
猜你喜欢

面试会问的 Promise.all()

win10 磁盘管理 压缩卷 无法启动问题

Win10 disk management compressed volume cannot be started

What data does the main account of Zhengda Meiou 4 pay attention to?

Record my pytorch installation process and errors

Ansible installation and use

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

数学知识——快速幂的理解及例题

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

Pycharm breakpoint management: temporarily cancel some breakpoints + run directly to a line
随机推荐
Solution: the agent throws an exception error
National all Chinese Automatic Test Software apifox
oracle 存储过程与job任务设置
Analyze the space occupied by the table according to segments, clusters and pages
Super detailed pycharm tutorial
leetcode存在重复元素go实现
Several methods of capturing packets under CS framework
Unity particle Foundation
Rhcsa --- work on the fourth day
将光盘中的cda保存到电脑中
Fasttext text text classification
win10 磁盘管理 压缩卷 无法启动问题
js面试收藏试题1
Orthogonal test method and function diagram method for test case design
Realize the function of data uploading
leetcode两数相加go实现
C case of communication between server and client based on mqttnet
Implementation of leetcode two number addition go
数学问题(数论)试除法做质数的判断、分解质因数,筛质数
VMware installation win10 reports an error: operating system not found