Archive:Https://fedoraproject.org/wiki/Projects/Mock/uk

From FedoraProject

Revision as of 13:14, 2 June 2010 by Egghead (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Mock

Mock створює chroot-оточення і будує в ньому пакунки. Його єдиною задачею є якісне наповнення цієї "пісочниці" і спроба зібрати в ній пакунок.

Статус

На даний момент mock задіяно у побудові всіх пакунків Fedora. Він використовується в Plague (<=FC-6) і Koji (>=F-7) для створення chroot-оточення і пакунків.

Звантаження

https://fedorahosted.org/mock/ містить усі найсвіжіші версії. Для встановлення можна скористатись командою "yum install mock".

Код в поточному стані можна знайти за адресою:

Using Mock inside your CVS sandbox

You only need to type 'make mockbuild' to start a mock build. The used architecture depends on the directory where you start the mock build.


Security Considerations

Build User

It's recommended you use a user account other than your normal user account to do the builds, just to be safe. You wouldn't want the build user to "accidentally" have access to your GPG or SSH keys.

To create the user, and put them into the mock group, run:

   *  adduser -m -G mock build 

Then remember to su - build prior to running mock.

Untrusted Users Using Mock

Beware that adding a user to the mock group means that the user can easily get root access on the machine without providing a password:

$ /usr/bin/mock --init -r fedora-10-i386
$ /usr/bin/mock --shell -r fedora-10-i386
mock-chroot> chmod u+s bin/bash
$ /var/lib/mock/fedora-10-i386/root/bin/bash -p
# cat /etc/shadow

Using

Usage:
usage:
mock [options]  {init|clean}
mock [options]  [rebuild]  /path/to/srpm(s)
mock [options]  {shell|chroot} <cmd>
mock [options]  installdeps {SRPM|RPM}
mock [options]  install PACKAGE
commands:
rebuild     - build the specified SRPM(s) [default command] 
chroot      - run the specified command within the chroot
shell       - run an interactive shell within specified chroot
clean       - clean out the specified chroot
init        - initialize the chroot, do not build anything
installdeps - install build dependencies for a specified SRPM
install     - install packages using yum

Options:
--version             show program's version number and exit
-h, --help            show this help message and exit
-r CHROOT             chroot name/config file name default: default
--no-clean            do not clean chroot before building
--cleanup-after       Clean chroot after building. Use with --resultdir.
Only active for 'rebuild'.
--no-cleanup-after    Dont clean chroot after building. If automatic cleanup
is enabled, use this to disable.
--arch=ARCH           target build arch
--resultdir=RESULTDIR
path for resulting files to be put
--uniqueext=UNIQUEEXT
Arbitrary, unique extension to append to buildroot
directory name
--configdir=CONFIGDIR
Change where config files are found
--rpmbuild_timeout=RPMBUILD_TIMEOUT
Fail build if rpmbuild takes longer than 'timeout'
seconds
--enable-plugin=ENABLED_PLUGINS
Enable plugin. Currently-available plugins: ('ccache',
'yum_cache', 'root_cache', 'bind_mount')
--disable-plugin=DISABLED_PLUGINS
Disable plugin. Currently-available plugins:
('ccache', 'yum_cache', 'root_cache', 'bind_mount')

For example, to rebuild a package for i386 on the development branch of Fedora:

  • mock rebuild -r fedora-devel-i386 /path/to/rpm

See /etc/mock for the available targets. If you have the bash-completion package installed, it will tab complete the targets for you.

Problems

If you encounter a bug running mock, please file it in Bugzilla , product "Fedora Hosted Projects", component mock (Open Bugs).

See Also

Extras/MockTricks has some useful tips for using mock.
Docs/Drafts/MockSetupUsingLocalMirror Setting up a local mirror using Mock.
Legacy/Mock has some useful tips for building packages in mock for older Fedora and Red Hat Linux releases.