In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how the RPM package in linux is made from the source RPM, I believe most people do not know much about it, so share this article for your reference. I hope you will gain a lot after reading this article. Let's learn about it together.
For example, let's take a look at fpaste. You can download the RPM using dnf. This downloads the latest version of fpaste available in the Fedora repository. On Fedora 30, the current version is 0.3.9.2:
$dnf download fpaste... fpaste-0.3.9.2-2.fc30.noarch.rpm
Because this is a build RPM, it contains only the files needed to use fpaste:
$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 source RPM
The next step in this chain is the source RPM. All software in Fedora must be built from its source code. We do not include pre-built binaries. Therefore, to make a RPM file, the RPM (tool) requires:
Give the files that must be installed
For example, if you want to compile these files, tell them how to generate them
Tell where these files must be installed
What other dependencies are required for this particular software to work properly.
The source RPM has all this information. The source RPM is similar to building the RPM, but as the name implies, they do not contain the built binaries, but rather the source files of some software. Let's download the source RPM for fpaste:
$dnf download fpaste--source... fpaste-0.3.9.2-2.fc30.src.rpm
Notice that the file ends with src.rpm. All RPM is built from the source RPM. You can also use dnf to easily check the source RPM of "binary" RPM:
$dnf repoquery-- qf "% {SOURCERPM}" fpastefpaste-0.3.9.2-2.fc30.src.rpm
In addition, because this is the source RPM, it does not contain the built file. Instead, it contains source code and instructions on how to build RPM from:
$rpm-qpl. / fpaste-0.3.9.2-2.fc30.src.rpmfpaste-0.3.9.2.tar.gzfpaste.spec
Here, the first file is just the source code for fpaste. The second is the spec file. The spec file is a recipe that tells RPM (tool) how to create RPM (archive file) using the source code contained in the source RPM-it contains all the information that RPM (tool) needs to build RPM (archive file). In the spec file. When we package maintainers add software to Fedora, we spend most of our time writing and perfecting spec files. When the package needs to be updated, we will go back and adjust the spec file. You can view the spec files of all packages in Fedora in https://src.fedoraproject.org/browse/projects/ 's source code repository.
Note that a source RPM may contain instructions for building multiple RPM. Fpaste is a very simple software that generates a "binary" RPM from a source RPM. Python is more complicated. Although there is only one source RPM, it generates multiple binary RPM:
$sudo dnf repoquery-- qf "% {SOURCERPM}" python3python3-3.7.3-1.fc30.src.rpmpython3-3.7.4-1.fc30.src.rpm $sudo dnf repoquery-- qf "{SOURCERPM}" python3-develpython3-3.7.3-1.fc30.src.rpmpython3-3.7.4-1.fc30.src.rpm $sudo dnf repoquery-- qf "% {SOURCERPM}" python3-libspython3-3.7.3-1.fc30.src.rpmpython3-3.7 .4-1.fc30.src.rpm $sudo dnf repoquery-- qf "% {SOURCERPM}" python3-idlepython3-3.7.3-1.fc30.src.rpmpython3-3.7.4-1.fc30.src.rpm $sudo dnf repoquery-- qf "{SOURCERPM}" python3-tkinterpython3-3.7.3-1.fc30.src.rpmpython3-3.7.4-1.fc30.src.rpm
In RPM jargon, "python3" is the "main package", so the spec file will be called python3.spec. All other software packages are "subpackages". You can download python3's source RPM and view its contents. (hint: patches are also part of the source code):
$dnf download-- source python3python3-3.7.4-1.fc30.src.rpm $rpm- qpl. / python3-3.7.4-1.fc30.src.rpm00001-rpath.patch00102-lib64.patch00111-no-static-lib.patch00155-avoid-ctypes-thunks.patch00170-gc-assertions.patch00178-dont-duplicate-flags-in-sysconfig.patch00189-use-rpm-wheels.patch00205-make-libpl-respect-lib64.patch00251-change-user-install-location.patch00274-fix-arch-names.patch00316 -mark-bdist_wininst-unsupported.patchPython-3.7.4.tar.xzcheck-pyc-timestamps.pyidle3.appdata.xmlidle3.desktoppython3.spec builds RPM from source RPM
Now that we have the source RPM, and what is in it, we can rebuild the RPM from it. However, before we do this, we should set up the system to build RPM. First, we install the necessary tools:
$sudo dnf install fedora-packager
This installs the rpmbuild tool. Rpmbuild needs a default layout so that it knows the location of each required component in the source RPM. Let's see what they are:
Where will the # spec file appear? Where will the $rpm-E% {_ specdir} / home/asinha/rpmbuild/SPECS # source code appear? Where is the $rpm-E% {_ sourcedir} / home/asinha/rpmbuild/SOURCES # temporary build directory? $rpm-E% {_ builddir} / home/asinha/rpmbuild/BUILD # where is the build root directory? $rpm-E% {_ buildrootdir} / home/asinha/rpmbuild/BUILDROOT # where will the source RPM be placed? Where will the RPM built by $rpm-E% {_ srcrpmdir} / home/asinha/rpmbuild/SRPMS # be placed? $rpm-E% {_ rpmdir} / home/asinha/rpmbuild/RPMS
I have set up all these directories on the system:
$cd$ tree-L 1 rpmbuild/rpmbuild/ ├── BUILD ├── BUILDROOT ├── RPMS ├── SOURCES ├── └── SRPMS 6 directories, 0 files
RPM also provides a tool that is set up for all of you:
$rpmdev-setuptree
Then, make sure that all build dependencies for fpaste are installed:
Sudo dnf builddep fpaste-0.3.9.2-3.fc30.src.rpm
For fpaste, all you need is Python, and it must already be installed on your system (dnf also uses Python). You can also give builddep a spec file instead of the source RPM. Learn more in the man page:
$man dnf.plugin.builddep
Now that we have everything we need, building a RPM from the source RPM is 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
Rpmbuild will install the source RPM and build your RPM from it. Now, you can use dnf to install RPM to use it. Of course, as mentioned earlier, if you want to make any changes in RPM, you will have to modify the spec file, which we will introduce in the next article.
The above is all the content of the article "how the RPM package in linux is made from the source RPM". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.