Mock creates chroots and builds packages in them. Its only task is to reliably populate a chroot and attempt to build a package in that chroot.
I assume that you have a Centos installation.
You can copy/paste this script and use it to configure automatically your server.
- echo "install mock"
- dnf -y install mock
- echo "only user who belongs to the group 'mock' can use mock. We add the user 'builder' to the mock group"
- echo " 1. create user builder"
- useradd builder
- echo " 2. unlock builder account (that will create /home/builder directory)."
- echo "set login/passwd : builder/builder"
- echo builder | passwd builder --stdin
- echo " 3. Add builder to the group 'mock'"
- usermod -G mock -a builder
- echo "Now create mock for epel 6 (64 bits)"
- runuser -l builder -c 'mock -r epel-6-x86_64 --init'
- runuser -l builder -c 'mock -r epel-6-x86_64 chroot "cat /etc/issue"'
First have a look to /etc/mock/. You will see all version you can use.
Important! You must login as ‘builder’ (or any user that belongs to ‘mock’ group).
/usr/bin/mock -r my-version --init
Environment is here : /var/lib/mock/my-version
You can open a shell for the environment:
/usr/bin/mock -r my-version --shell
If you want to install package:
/usr/bin/mock -r my-version install yum
If you want to execute a command:
/usr/bin/mock -r my-version chroot "commands"
Copyright © 2023 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.