The Centos system USES mock to build rpm methods
- 2020-05-15 03:19:37
- OfStack
preface
Execute under centos
rpmbuild -ba package.spec
It is common to require the system to install dependent packages as well, which can result in the system being loaded with useless software packages and taking up space. So we searched 1, and we found that we could pass
mock
Command to solve the problem.
Building methods
The first is installation
mock
Because of
mock
Is in the
epel
It's in the warehouse, so it needs to be loaded first
epel
warehouse
yum -y install epel-release
yum -y install mock
Usually used
rpmbuild
It will open a new user, for example
builder
So as not to pollute the system. We need to put
builder
Users join
mock
User groups
usermod -a -G mock builder
mock
use
rebuild
You need the src.rpm file, so if you only have the.spec file, you need the src.rpm file
rpmbuild -bs package.spec
This will generate an src.rpm file in the SRPM directory, and it will pass through
mock
Command to
rebuild rpm
file
You need to initialize first
mock
Environment. In the /etc/mock folder, there are configuration files for various environments. For example, centos 6 is epel-6-x86_64, and the initialization command is:
mock -r epel-6-x86_64 --init
Once the initialization is complete, the build can begin
mock -r epel-6-x86_64 rebuild package-1.1-1.src.rpm
When the build is complete,
rpm
Files are stored in/var lib mock/epel - 6 - x86_64 / result directory. Of course we can
�resultdir
Parameter to specify
rpm
The generated directory of the file
mock -r epel-6-x86_64 rebuild package-1.1-1.src.rpm --resultdir=/home/builder/rpms
The last execution
clean
Command clean up the environment
mock -r epel-6-x86_64 --clean
conclusion
The above is all about building rpm with mock under Centos. I hope the content of this paper can bring you some help in your study or work. If you have any questions, you can leave a message to communicate.