Modify, regenerate, and install the srpm source code package

Source: Internet
Author: User
Tags rpmbuild

Linux releases such as RHEL, CentOS, Fedora, and Suse all use the rpm package as the package format. There is also a related srpm package (Suffix:. src. rpm), which contains the source code and can be used to regenerate the rpm package.

The latest RHEL/CentOS version is 6.x. The latest version is RHEL6.5/CentOS6.5. (CentOS is a free version of RHEL. It is equivalent to the corresponding version of RHEL, except for removing the Redhat LOGO .)

Find the source package of all rpm packages of RHEL6 at the following address: *. src. rpm.

Http://ftp.redhat.com/redhat/linux/enterprise/6Server/en/ OS /SRPMS/

CentOS uses these * src. rpm source code packages to build all RPM packages and generate the CentOS operating system.

* After the src. rpm source code package is decompressed, you can see the source code package and some patch files of the software.

If there is a problem with the rpm package, we can.



Directly install * src. rpm source code package

Sometimes, we do not find the available rpm package, but find its corresponding * src. rpm source package. At this time, we can install this * src. rpm source package. The steps are different from installing the rpm package directly.

The rpm-I/tmp/mypackage-1.0.0-1.src.rpm is not installed yet. Only in ~ Resources of the src. rpm source package are prepared in the/rpmbuild/directory, which can be used to further generate the rpm package. [User @ host ~] $ Cd ~ /Rpmbuild/SPECS [user @ host SPECS] $ rpmbuild-ba mypackage. spec

* The src. rpm source code package is built using the rpmbuild command. Let's take a look at the options of this command.

Rpmbuild-bSTAGE |-tSTAGE [rpmbuild-options] FILE...



The argument used is-B if a spec file is being used to build the packageand-t if rpmbuild shoshould look inside of a (possibly compressed) tar

File for the spec file to use. After the first argument, the nextcharacter (STAGE) specifies the stages of building and packaging tobe done

Andis one:



-Ba Build binary and source packages (after doing the % prep, % build, and % install stages). Build the RPM package and SRPM package.



-Bb Build a binary package (after doing the % prep, % build, and % install stages). Build the RPM package.

-Bp Executes the "% prep" stage from the spec file. Normallythis involves unpacking the sources and applying any patches.

Execute the % prep phase of the spec file. Generally, extract the source code and application source code ~ /Rpmbuild/BUILD/directory.



-Bc Do the "% build" stage from the spec file (after doingthe % prep stage). This generally involves the equivalent of a "make ".

Execute the % build phase of the spec file. Generally, execute make.



-Bi Do the "% install" stage from the spec file (after doingthe % prep and % build stages). This generally involves the equivalentof a "make

Install ".

Execute the % install stage of the spec file. Generally, execute make install.



-Bl Do a "list check". The "% files" section from the spec file is macro expanded, and checks are made to verify that each file exists.

The % files stage of the spec file is generally used to verify whether each file exists.

-Bs Build just the source package.

Only build source code packages.





The above command constructs the rpm package and the src. rpm package. You can ~ /Rpmbuild/RPMS/x86_64/or find the new rpm package in the directory of another architecture.

You can use the sudo rpm-I *. rpm command to install the rpm package.



You can also directly use the following command:

Rpmbuild -- rebuild/tmp/mypackage-1.0.0-1.src.rpm this command step can be in ~ /Rpmbuild/RPMS/directory to regenerate the rpm package.



Modify the code based on * src. rpm source code package and generate and install the rpm package

The rpmbuildcommand is based on the. specfile and source code tar.gz and patch files to generate src. rpm and rpm packages.

Therefore, we only need to modify the. spec file, or the corresponding source code and patch file, and then execute

Rpmbuild-ba mypackage. spec command to generate the updated src. rpm package and rpm package. Rpm package in ~ /Rpmbuild/RPMS directory, the src. rpm package is in ~ /Rpmbuild/SRPMS directory.Note: You need to modify ~ Files in the/rpmbuild/SOURCES/directory: 1, you can repackage ~ The tar.gz source file under/rpmbuild/SOURCES/directory. 2. You can modify the. spec file to add or remove the patch application. 3. We recommend that you modify the. spec Release: 8% {? Dist} macro to add its value. In this way, the rpm package and src. the minor version number of the rpm package is higher than the original rpm package, so you can use sudo rpm-U .. /RPMS/x86_64/bzip2-1.0.5-8.el6.x86_64.rpm command to upgrade the rpm package. If you do not increase the Release number, you must first uninstall the installed rpm package and then reinstall the new rpm package.
 
 
 

How to modify the deb package

Here, by the way, we will introduce the repackaging method of debian package in another popular software package format on Linux.

The dpkg-deb command can decompress the deb package. Yes, the deb package is a compressed file. As in office documents, it is also a compressed file. The Jar package is also a compressed file, and the rpm package is also a compressed file.

Dpkg-deb -- raw-extract X. deb X

Decompress the X. deb package to the X Directory.

You can modify files in the X Directory. Such as replacing resource files, binary files, and modifying configuration files.

Dpkg-deb -- build X [X. deb]

The build directory is the deb package. The second parameter can be omitted, that is, the deb package named in directory name. deb format is generated.


Dpkg-I X. deb

Command to install the deb package.


The DEBIAN/control file in the deb package has a lot of metadata, including:

Architecture:

Sets the CPU architecture applicable to the debian package. I386 and amd64 are commonly used. Use all or any to indicate that the deb package applies to any architecture.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.