The method of building rpm with mock in CentOS system _linux

Source: Internet
Author: User
Tags centos rpmbuild

Objective

When executed under CentOS rpmbuild -ba package.spec , the system is usually required to install the corresponding dependency pack, which will cause the system to load a lot of useless software packages, occupy space. So I searched and found that we could mock solve the problem by command.

Build method

The first is the installation mock , because mock it is in the epel warehouse, so we need to install the epel warehouse first

Yum-y Install epel-release
yum-y install mock

Typically, rpmbuild a new user is opened, for example builder , so that the system environment is not contaminated. We need to builder add users to the mock user group

Usermod-a-G mock Builder

mockThe use of the rebuild src.rpm file is required, so if only the. spec file, you need Mr. SRC.RPM file

Rpmbuild-bs Package.spec

This will generate a src.rpm file in the srpm directory, and then you can use the mock command to rebuild rpm file

First you need to initialize the mock environment, under the/etc/mock folder has various environment configuration files, such as CentOS 6 is epel-6-x86_64, initialization command is:

Mock-r epel-6-x86_64--init

Once the initialization is complete, you can start building

Mock-r epel-6-x86_64 Rebuild package-1.1-1.src.rpm

The rpm files will be stored in the/var/lib/mock/epel-6-x86_64/result directory when the build is complete. Of course, we can –resultdir specify rpm the file generation directory by parameter.

Mock-r epel-6-x86_64 rebuild package-1.1-1.src.rpm--resultdir=/home/builder/rpms

Last clean command cleanup environment

Mock-r epel-6-x86_64--clean

Summarize

The above is about CentOS use mock to build all the content of RPM, hope this article content to everyone's study or work can bring certain help, if there is doubt you can message exchange.

Related Article

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.