{"id":405,"date":"2013-03-04T12:23:42","date_gmt":"2013-03-04T11:23:42","guid":{"rendered":"http:\/\/blog.rabahi.net\/?page_id=405"},"modified":"2014-08-04T17:36:52","modified_gmt":"2014-08-04T15:36:52","slug":"mock-server","status":"publish","type":"page","link":"https:\/\/blog.rabahi.net\/?page_id=405","title":{"rendered":"Mock"},"content":{"rendered":"<blockquote><p>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.<\/p><\/blockquote>\n<p style=\"text-align: right;\">Fedora projects<\/p>\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">Contents<\/p><ul class=\"toc_list\"><li><a href=\"#Objectives\"><span class=\"toc_number toc_depth_1\">1<\/span> Objectives<\/a><\/li><li><a href=\"#Prerequiste\"><span class=\"toc_number toc_depth_1\">2<\/span> Prerequiste<\/a><\/li><li><a href=\"#Installation\"><span class=\"toc_number toc_depth_1\">3<\/span> Installation<\/a><\/li><li><a href=\"#How_to_use_it\"><span class=\"toc_number toc_depth_1\">4<\/span> How to use it?<\/a><\/li><\/ul><\/div>\n<h1><span id=\"Objectives\">Objectives<\/span><\/h1>\n<ul>\n<li>Mock installation<\/li>\n<li>init<\/li>\n<li>chroot<\/li>\n<li>shell<\/li>\n<\/ul>\n<h1><span id=\"Prerequiste\">Prerequiste<\/span><\/h1>\n<p>I assume that you have a Centos installation.<\/p>\n<h1><span id=\"Installation\">Installation<\/span><\/h1>\n<p>You can copy\/paste this script and use it to configure automatically your server.<\/p>\n<pre class=\"bash\" style=\"font-family:monospace;\"><ol><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\"><span style=\"color: #666666; font-style: italic;\">#!\/bin\/bash<\/span><\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\">&nbsp;<\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\"><span style=\"color: #7a0874; font-weight: bold;\">echo<\/span> <span style=\"color: #ff0000;\">&quot;install mock&quot;<\/span><\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\">dnf <span style=\"color: #660033;\">-y<\/span> <span style=\"color: #c20cb9; font-weight: bold;\">install<\/span> mock<\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\">&nbsp;<\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\"><span style=\"color: #7a0874; font-weight: bold;\">echo<\/span> <span style=\"color: #ff0000;\">&quot;only user who belongs to the group 'mock' can use mock. We add the user 'builder' to the mock group&quot;<\/span><\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\"><span style=\"color: #7a0874; font-weight: bold;\">echo<\/span> <span style=\"color: #ff0000;\">&quot; 1. create user builder&quot;<\/span><\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\">useradd builder<\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\"><span style=\"color: #7a0874; font-weight: bold;\">echo<\/span> <span style=\"color: #ff0000;\">&quot; 2. unlock builder account (that will create \/home\/builder directory).&quot;<\/span><\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\"><span style=\"color: #7a0874; font-weight: bold;\">echo<\/span> <span style=\"color: #ff0000;\">&quot;set login\/passwd : builder\/builder&quot;<\/span><\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\"><span style=\"color: #7a0874; font-weight: bold;\">echo<\/span> builder <span style=\"color: #000000; font-weight: bold;\">|<\/span> <span style=\"color: #c20cb9; font-weight: bold;\">passwd<\/span> builder <span style=\"color: #660033;\">--stdin<\/span><\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\"><span style=\"color: #7a0874; font-weight: bold;\">echo<\/span> <span style=\"color: #ff0000;\">&quot; 3. Add builder to the group 'mock'&quot;<\/span><\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\">usermod <span style=\"color: #660033;\">-G<\/span> mock <span style=\"color: #660033;\">-a<\/span> builder<\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\">&nbsp;<\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\"><span style=\"color: #7a0874; font-weight: bold;\">echo<\/span> <span style=\"color: #ff0000;\">&quot;Now create mock for epel 6 (64 bits)&quot;<\/span><\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\">runuser <span style=\"color: #660033;\">-l<\/span> builder <span style=\"color: #660033;\">-c<\/span> <span style=\"color: #ff0000;\">'mock -r epel-6-x86_64 --init'<\/span><\/div><\/li><li style=\"background: #fcfcfc;\"><div style=\"font-size: 12px;\">runuser <span style=\"color: #660033;\">-l<\/span> builder <span style=\"color: #660033;\">-c<\/span> <span style=\"color: #ff0000;\">'mock -r epel-6-x86_64 chroot &quot;cat \/etc\/issue&quot;'<\/span><\/div><\/li><li style=\"background: #f0f0f0;\"><div style=\"font-size: 12px;\">&nbsp;<\/div><\/li><\/ol><\/pre>\n<h1><span id=\"How_to_use_it\">How to use it?<\/span><\/h1>\n<p>First have a look to \/etc\/mock\/. You will see all version you can use.<br \/>\nImportant! You must login as &#8216;builder&#8217; (or any user that belongs to &#8216;mock&#8217; group).<br \/>\nThen type:<\/p>\n<pre lang=\"bash\">\/usr\/bin\/mock -r my-version --init<\/pre>\n<p>Environment is here : \/var\/lib\/mock\/my-version<\/p>\n<p>You can open a shell for the environment:<\/p>\n<pre lang=\"bash\">\/usr\/bin\/mock -r my-version --shell<\/pre>\n<p>If you want to install package:<\/p>\n<pre lang=\"bash\">\/usr\/bin\/mock -r my-version install yum<\/pre>\n<p>If you want to execute a command:<\/p>\n<pre lang=\"bash\">\/usr\/bin\/mock -r my-version chroot \"commands\"<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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. Fedora projects Contents1 Objectives2 Prerequiste3 Installation4 How to use it? Objectives Mock installation init chroot shell Prerequiste I assume that you have a Centos installation. Installation You can copy\/paste [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":403,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-405","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/405","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=405"}],"version-history":[{"count":26,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/405\/revisions"}],"predecessor-version":[{"id":1026,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/405\/revisions\/1026"}],"up":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/403"}],"wp:attachment":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}