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
mockThe use of the rebuild src.rpm file is required, so if only the. spec file, you need Mr. SRC.RPM file
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.