Difference between pages "Help:Funtoo Editing Guidelines" and "Metro"

(Difference between pages)
(The {{console}} template is now preferred over <console> (better maintainability))
 
(Repository Management)
 
Line 1: Line 1:
'''Thanks for your interest in contributing to the the Funtoo wiki!'''
+
{{#layout:doc}}{{#widget:AddThis}}[[Metro]] is the build system for Funtoo Linux and [[Gentoo Linux]] stages. It automates the bootstrapping process.
__NOTOC__
+
=== Types of Edits ===
+
  
Before we get started, let's review what changes are okay to make, and what changes are not okay:
+
This tutorial will take you through installing, setting up and running [[Metro]].
  
{{TableStart}}
+
These other Metro documents are also available:
<tr class="active"><th>Type of Change</th><th>Okay?</th></tr>
+
<tr><td>Grammar/spelling fixes</td><td>Yes</td></tr>
+
<tr><td>New wiki content</td><td>Yes</td></tr>
+
<tr><td>New package information</td><td>Yes</td></tr>
+
<tr><td>Adding to existing article</td><td>Maybe -- see below</td></tr>
+
<tr><td>Adding missing/incomplete information</td><td>Yes</td></tr>
+
<tr><td>Making corrections</td><td>Yes</td></tr>
+
<tr class="danger"><td>Adding work-arounds to problems experienced</td><td>No - open bug first on [http://bugs.funtoo.org bug tracker].</td></tr>
+
{{TableEnd}}
+
  
{{important|Note that if you experience some problem with Funtoo Linux, during installation or otherwise, the proper course of action is to not add a work-around to our documentation, but to ''open a bug on our bug tracker.'' This is important because the problem you experienced may be a legitimate bug and the solution may be to fix the bug rather than add a work-around to our documentation. We may end up fixing a bug, making a documentation fix, or possibly both.}}
+
{{#ask: [[Category:Metro]]
 +
|format=ul
 +
}}
  
=== Basics ===
+
= Preface =  
  
Here is a list of basic wiki information that you will need to know to get started:
+
== How Metro Works ==
  
* First, to perform edits on the wiki, you must {{CreateAccount}} and log in.
+
Metro is the Funtoo Linux automated build system, and is used to build Funtoo Linux stage tarballs.
* You can create a new page by navigating to http://www.funtoo.org/New_Page_Name. Underscores are the equivalent of spaces. Then select "Create" under the "Actions" menu.
+
* Whether creating a new page or editing an existing page by clicking "Edit", you will be presented with Web-based text editor that allows you to modify the ''wikitext'' of the page. The wikitext is rendered to produce the document you see when you view the page normally.
+
* Another fun thing you can do is click on your name under the "Account" menu once you have logged in. This will bring you to your "User" page. Then click "Create with Form" unde the "Actions" menu and enter your geographic and other information. This will allow you to be displayed on our [[Usermap]] and will also allow your full name to be displayed on [[:Category:Ebuilds|Ebuild pages]] for which you are an author. It's generally a good idea to do this.
+
  
{{tip|The following sections document how to use wikitext and Funtoo templates on the Funtoo wiki.}}
+
[[Metro]] cannot create a stage tarball out of thin air. To build a new stage tarball, [[Metro]] must use an existing, older stage tarball called a "seed" stage. This seed stage typically is used as the ''build environment'' for creating the stage we want.
  
=== Paragraphs ===
+
[[Metro]] can use two kinds of seed stages. Traditionally, [[Metro]] has used a stage3 as a seed stage. This stage3 is then used to build a new stage1, which in turn is used to build a new stage2, and then a new stage3. This is generally the most reliable way to build [[Gentoo Linux]] or Funtoo Linux, so it's the recommended approach.
 +
{{fancyimportant|'''After switching metro builds to Funtoo profile, Gentoo stages are no longer provided'''!}}
  
To create a new paragraph, insert a blank line between two lines of text. If a blank line doesn't exist between two lines of wikitext, they will be combined into a single flowing paragraph.
+
== Seeds and Build Isolation ==
  
If you leave leading whitespace at the beginning of a line, MediaWiki will render it as pre-formatted text. Beware of this. Here's an example:
+
Another important concept to mention here is something called ''build isolation''. Because [[Metro]] creates an isolated build environment, and the build environment is explicitly defined using existing, tangible entities -- a seed stage and a portage snapshot -- you will get consistent, repeatable results. In other words, the same seed stage, portage snapshot and build instructions will generate an essentially identical result, even if you perform the build a month later on someone else's workstation.
  
foobar
+
== Local Build ==
  
This can rear its ugly head when specifying template parameters, so you will get this:
+
Say you wanted to build a new <tt>pentium4</tt> stage3 tarball. The recommended method of doing this would be to grab an existing <tt>pentium4</tt> stage3 tarball to use as your seed stage. [[Metro]] will be told to use this existing <tt>pentium4</tt> stage3 to build a new stage1 for the same <tt>pentium4</tt>. For this process, the generic <tt>pentium4</tt> stage3 would provide the ''build environment'' for creating our new stage1. Then, the new stage1 would serve as the build environment for creating the new <tt>pentium4</tt> stage2. And the new <tt>pentium4</tt> stage2 would serve as the build environment for creating the new <tt>pentium4</tt> stage3.
  
{{note| ugh!}}
+
In the [[Metro]] terminology this is called a '''local build''', which means a stage3 of a given architecture is used to seed a brand new build of the same architecture. Incidentally this will be the first exercise we are going to perform in this tutorial.
  
...instead of this:
+
A week later, you may want to build a brand new <tt>pentium4</tt> stage3 tarball. Rather than starting from the original <tt>pentium4</tt> stage3 again, you'd probably configure [[Metro]] to use the most-recently-built <tt>pentium4</tt> stage3 as the seed. [[Metro]] has built-in functionality to make this easy, allowing it to easily find and track the most recent stage3 seed available.
  
{{note|This looks much better!}}
+
== Remote Build ==
  
=== Page and Section Capitalization ===
+
[[Metro]] can also perform '''remote build''', where a stage3 of a different, but binary compatible, architecture is used as a seed to build a different architecture stage3. Consequentiality the second exercise we are going to perform in this tutorial will be to build a <tt>core2 32bit</tt> stage3 tarball from the <tt>pentium4</tt> stage3 tarball we have just built.
  
In general, capitalize all words in page names and section heading except:
+
TODO: add caveats about what archs can be seeded and what can be not (maybe a table?)
* Articles: a, an, the
+
* Coordinating Conjunctions: and, but, or, for, nor, etc.
+
* Prepositions (fewer than five letters): on, at, to, from, by, etc.
+
  
=== Document Hierarchy ===
+
== Tailored Build ==  
  
Use section headings to create a document hierarchy for your page. These will define the table of contents that appears at the top of the wiki page. Create chapters, sections and sub-sections as follows:
+
Last, it's also worthy noting that both in <tt>local</tt> and <tt>remote builds</tt>, [[Metro]] can be configured to add and/or remove individual packages to the final tarball.
 +
Let's say you can't live without <tt>app-misc/screen</tt>, at the end of this tutorial, we will show how to have your tailored stage3 to include it.
  
<pre>= Page Title =
+
== Installing Metro ==
  
== Chapter Title ==
+
'''The recommended and supported method''' is to use the Git repository of [[Metro]]. 
  
=== Section Title ===
+
Ensure that {{Package|dev-vcs/git}} and {{Package|dev-python/boto}} (optional; required for EC2 support) are installed on your system:
  
==== SubSection Title ====
+
<console>
 +
# ##i##emerge dev-vcs/git
 +
# ##i##emerge dev-python/boto
 +
</console>
  
</pre>
+
Next, clone the master git repository as follows:
  
{{Note|By default, Table of Contents is disabled on the Funtoo wiki. If you would like to enable the TOC, you can place a <code><nowiki>__TOC__</nowiki></code> on a blank line where you'd like the Table of Contents to appear, or place <code><nowiki>__FORCETOC__</nowiki></code> on a blank line anywhere in the wikitext to force the TOC to appear at the top of the page.}}
+
<console>
 +
# ##i##cd /root
 +
# ##i##git clone git://github.com/funtoo/metro.git
 +
# ##i##cp /root/metro/metro.conf ~/.metro
 +
</console>
  
In general, when creating new documents, it's best to use level-3 (three "="'s) Section Titles to break up content. Level-2 Section Titles are best used for major sections of larger documents. Use them infrequently. Level-1 Section Titles generally do not need to be used.
+
You will now have a directory called <tt>/root/metro</tt> that contains all the [[Metro]] source code.
  
=== Links ===
+
Metro is now installed. It's time to customize it for your local system.
  
Internal links to other wiki pages can be specified as <tt><nowiki>[[pagename]]</nowiki></tt>. To specify an alternate name for the link, use <tt><nowiki>[[pagename|my link name]]</nowiki></tt>.
+
= Configuring Metro =
  
For external links, use <tt><nowiki>[http://funtoo.org my link]</nowiki></tt> to specify a URL. If you want the URL to appear in the wikitext, you can specify it without brackets: http://forums.funtoo.org.
+
{{Note|Metro is not currently able to build Gentoo stages. See {{Bug|FL-901}}.}}
  
=== Lists ===
+
[[User:Drobbins|Daniel Robbins]] maintains [[Metro]], so it comes pre-configured to successfully build [[Funtoo Linux]] releases. Before reading further, you might want to customize some basic settings like the number of concurrent jobs to fit your hardware's capabilities or the directory to use for produced stage archives. This is accomplished by editing <tt>~/.metro</tt> which is the [[Metro]]'s master configuration file.
  
MediaWiki supports a number of list formats:
+
Please note that <code>path/install</code> must point to where metro was installed. Point <code>path/distfiles</code> to where your distfiles reside. Also set <code>path/mirror/owner</code> and <code>path/mirror/group</code> to the owner and group of all the files that will be written to the build repository directory, which by default (as per the configuration file) is at <code>/home/mirror/funtoo</code>. The cache directory normally resides inside the temp directory -- this can be modified as desired. The cache directory can end up holding many cached .tbz2 packages, and eat up a lot of storage. You may want to place the temp directory on faster storage, for faster compile times, and place the cache directory on slower, but more plentiful storage.
  
* Unordered List
+
{{file|name=.metro|desc=Metro configuration|body=
* Unordered Item 2
+
# Main metro configuration file - these settings need to be tailored to your install:
** Unordered sub-item
+
  
# Ordered List
+
[section path]
# Ordered Item 2
+
install: /root/metro
## Ordered sub-item
+
tmp: /var/tmp/metro
 +
cache: $[path/tmp]/cache
 +
distfiles: /var/src/distfiles
 +
work: $[path/tmp]/work/$[target/build]/$[target/name]
  
;Term: This is called a "definition list". It is used when defining various terms.
+
[section path/mirror]
  
If you need to quote a portion of text from another site, use <tt><nowiki><blockquote></nowiki></tt> as follows:
+
: /home/mirror/funtoo
 +
owner: root
 +
group: repomgr
 +
dirmode: 775
  
<blockquote>
+
[section portage]
Wikipedia (ˌwɪkɨˈpiːdiə/ or wɪkiˈpiːdiə/ wik-i-pee-dee-ə) is a collaboratively edited, multilingual, free-access, free content Internet encyclopedia that is supported and hosted by the non-profit Wikimedia Foundation. Volunteers worldwide collaboratively write Wikipedia's 30 million articles in 287 languages, including over 4.5 million in the English Wikipedia. Anyone who can access the site can edit almost any of its articles, which on the Internet comprise[4] the largest and most popular general reference work.[5][6][7][8][9] In February 2014, The New York Times reported that Wikipedia is ranked fifth globally among all websites stating, "With 18 billion page views and nearly 500 million unique visitors a month..., Wikipedia trails just Yahoo, Facebook, Microsoft and Google, the largest with 1.2 billion unique visitors."[10]
+
</blockquote>
+
  
=== Literal Text and HTML Symbols ===
+
MAKEOPTS: auto
  
Here is wikitext for the section above, which I am displaying by placing the literal wikitext between a &#60;pre&#62; and &#60;/pre&#62; tag. If you want to disable wikitext processing for an inline span of text, use &#60;nowiki&#62; and &#60;/nowiki&#62;. If you want to print out a tag literally, use &amp;#60; and &amp;#62; (In the wikitext, I used &amp;amp;#60; and &amp;amp;#62 to display these!)
+
[section emerge]
  
<pre>
+
options: --jobs=4 --load-average=4 --keep-going=n
* Unordered List
+
* Unordered Item 2
+
** Unordered sub-item
+
  
# Ordered List
+
# This line should not be modified:
# Ordered Item 2
+
[collect $[path/install]/etc/master.conf]
## Ordered sub-item
+
}}
  
;Term: This is called a "definition list". It is used when defining various terms.
+
== Arch and Subarch ==
  
If you need to quote a portion of text from another site, use <tt><nowiki><blockquote></nowiki></tt> as follows:
+
In the following example we are creating a pentium4 stage 3 compiled for x86-32bit binary compatibility. Pentium4 is a subarch of the x86-32bit architecture. Once you have metro installed you may find a full list of each subarch in your <tt>/root/metro/subarch</tt> directory each subarch will have the file extension .spec
 +
Example:
 +
<console>
 +
###i## ls /root/metro/subarch
 +
# ls subarch/
 +
amd64-bulldozer-pure64.spec  armv7a.spec          core-avx-i.spec        i686.spec        pentium.spec
 +
amd64-bulldozer.spec        armv7a_hardfp.spec  core2_32.spec          k6-2.spec        pentium2.spec
 +
amd64-k10-pure64.spec        athlon-4.spec        core2_64-pure64.spec    k6-3.spec        pentium3.spec
 +
amd64-k10.spec              athlon-mp.spec      core2_64.spec          k6.spec          pentium4.spec
 +
amd64-k8+sse3.spec          athlon-tbird.spec    corei7-pure64.spec      native_32.spec    pentiumpro.spec
 +
amd64-k8+sse3_32.spec        athlon-xp.spec      corei7.spec            native_64.spec    prescott.spec
 +
amd64-k8-pure64.spec        athlon.spec          generic_32.spec        niagara.spec      ultrasparc.spec
 +
amd64-k8.spec                atom_32.spec        generic_64-pure64.spec  niagara2.spec    ultrasparc3.spec
 +
amd64-k8_32.spec            atom_64-pure64.spec  generic_64.spec        nocona.spec      xen-pentium4+sse3.spec
 +
armv5te.spec                atom_64.spec        generic_sparcv9.spec    opteron_64.spec  xen-pentium4+sse3_64.spec
 +
armv6j.spec                  btver1.spec          geode.spec              pentium-m.spec
 +
armv6j_hardfp.spec          btver1_64.spec      i486.spec              pentium-mmx.spec
 +
</console>
  
<blockquote>
+
= First stages build (local build) =
Wikipedia (ˌwɪkɨˈpiːdiə/ or wɪkiˈpiːdiə/ wik-i-pee-dee-ə) is a collaboratively edited, multilingual, free-access,
+
free content Internet encyclopedia that is supported and hosted by the non-profit Wikimedia Foundation. Volunteers
+
worldwide collaboratively write Wikipedia's 30 million articles in 287 languages, including over 4.5 million in the
+
English Wikipedia. Anyone who can access the site can edit almost any of its articles, which on the Internet
+
comprise[4] the largest and most popular general reference work.[5][6][7][8][9] In February 2014, The New York
+
Times reported that Wikipedia is ranked fifth globally among all websites stating, "With 18 billion page views
+
and nearly 500 million unique visitors a month..., Wikipedia trails just Yahoo, Facebook, Microsoft and Google,
+
the largest with 1.2 billion unique visitors."[10]
+
</blockquote>
+
</pre>
+
  
=== Linking to Packages ===
+
To get this all started, we need to bootstrap the process by downloading an initial seed stage3 to use for building and place it in its proper location in <tt>/home/mirror/funtoo</tt>, so that [[Metro]] can find it. We will also need to create some special &quot;control&quot; files in <tt>/home/mirror/funtoo</tt>, which will allow [[Metro]] to understand how it is supposed to proceed.
  
To link to a package page, use the <code>Package</code> template:
+
== Step 1: Set up pentium4 repository (local build) ==
  
<pre><nowiki>
+
Assuming we're following the basic steps outlined in the previous section, and building an unstable funtoo (<tt>funtoo-current</tt>) build for the <tt>pentium4</tt>, using a generic <tt>pentium4</tt> stage3 as a seed stage, then here the first set of steps we'd perform:
{{Package|sys-apps/portage}}
+
</nowiki></pre>
+
  
This template will create a link to the official wiki page for sys-apps/portage, and render using the official "English" page name, as follows:
+
<console>
 +
# ##i##install -d /home/mirror/funtoo/funtoo-current/x86-32bit/pentium4
 +
# ##i##install -d /home/mirror/funtoo/funtoo-current/snapshots
 +
# ##i##cd /home/metro/mirror/funtoo/funtoo-current/x86-32bit/pentium4
 +
# ##i##install -d 2011-12-13
 +
# ##i##cd 2011-12-13
 +
# ##i##wget -c http://ftp.osuosl.org/pub/funtoo/funtoo-current/x86-32bit/pentium4/2011-12-13/stage3-pentium4-funtoo-current-2011-12-13.tar.xz
 +
# ##i##cd ..
 +
# ##i##install -d .control/version
 +
# ##i##echo "2011-12-13" > .control/version/stage3
 +
# ##i##install -d .control/strategy
 +
# ##i##echo local >  .control/strategy/build
 +
# ##i##echo stage3 > .control/strategy/seed
 +
</console>
  
{{Package|sys-apps/portage}}
+
OK, let's review the steps above. First, we create the directory <tt>/home/mirror/funtoo/funtoo-current/x86-32bit/pentium4</tt>, which is where Metro will expect to find unstable <tt>funtoo-current</tt> pentium4 builds -- it is configured to look here by default. Then we create a specially-named directory to house our seed x86 stage3. Again, by default, Metro expects the directory to be named this way. We enter this directory, and download our seed x86 stage3 from funtoo.org. Note that the <tt>2010-12-24</tt> version stamp matches. Make sure that your directory name matches the stage3 name too. Everything has been set up to match Metro's default filesystem layout.
  
If you specify a yet-to-be-documented ebuild, it will render like this (which is okay -- it will encourage people to document it):
+
Next, we go back to the <tt>/home/mirror/metro/funtoo-current/x86-32bit/pentium4</tt> directory, and inside it, we create a <tt>.control</tt> directory. This directory and its subdirectories contain special files that Metro references to determine certain aspects of its behavior. The <tt>.control/version/stage3</tt> file is used by Metro to track the most recently-built stage3 for this particular build and subarch. Metro will automatically update this file with a new version stamp after it successfully builds a new stage3. But because Metro didn't actually ''build'' this stage3, we need to set up the <tt>.control/version/stage3</tt> file manually. This will allow Metro to find our downloaded stage3 when we set up our pentium4 build to use it as a seed. Also note that Metro will create a similar <tt>.control/version/stage1</tt> file after it successfully builds an pentium4 funtoo-current stage1.
  
{{Package|sys-foo/undocumented-ebuild}}
+
We also set up <tt>.control/strategy/build</tt> and <tt>.control/strategy/seed</tt> files with values of <tt>local</tt> and <tt>stage3</tt> respectively. These files define the building strategy Metro will use when we build pentium4 funtoo-current stages. With a build strategy of <tt>local</tt>, Metro will source its seed stage from funtoo-current pentium4, the current directory. And with a seed strategy of <tt>stage3</tt>, Metro will use a stage3 as a seed, and use this seed to build a new stage1, stage2 and stage3.
  
=== Tables ===
+
== Step 2: Building the pentium4 stages ==
  
Instead of using traditional MediaWiki table wikitext, use the following format:
+
Incidentally, if all you wanted to do at this point was to build a new pentium4 funtoo-current stage1/2/3 (plus openvz and vserver templates). You would begin the process by typing:
  
<pre>
+
<console>
{{TableStart}}
+
# ##i##cd /root/metro
<tr class="info"><th>Header 1</th><th>Header 2</th></tr>
+
# ##i##scripts/ezbuild.sh funtoo-current pentium4
<tr><td>Value 1</td><td>Value 2</td></tr>
+
</console>
<tr><td>Value 3</td><td>Value 4</td></tr>
+
{{TableEnd}}
+
</pre>
+
  
This wil render as follows:
+
If you have a slow machine, it could take several hours to be completed because several "heavy" components like gcc or glibc have to be recompiled in each stage. Once a stage has been successfully completed, it is placed in the <tt>"${METRO_MIRROR}/funtoo-current/x32-bit/pentium4/YYYY-MM-DD"</tt> subdirectory, where <tt>YYYY-MM-DD</tt> is today's date at the time the <tt>ezbuild.sh</tt> script was started or the date you put on the ezscript.sh command line.
  
{{TableStart}}
+
= Building for another binary compatible architecture (remote build) =
<tr class="info"><th>Header 1</th><th>Header 2</th></tr>
+
<tr><td>Value 1</td><td>Value 2</td></tr>
+
<tr><td>Value 3</td><td>Value 4</td></tr>
+
{{TableEnd}}
+
  
{{tip|This table syntax has an added benefit of creating a responsive table that renders properly on mobile devices.}}
+
As written above, [[Metro]] is able to perform '''remote build''' building different architecture stage3 from a binary compatible seeding stage3 (e.g. using a pentium4 stage3 to seed a <tt>Intel Core2 32bits</tt> stage3).  
  
It is possible to use the following CSS classes with <code>tr</code> (rows) and <code>td/th</code> elements to color them as desired:
+
In the Metro terminology this is called a '''remote build''' (a stage 3 of a different, but binary compatible, architecture is used as a seed).
 +
What's not compatible? You can't use a <tt>Sparc</tt> architecture to generate an <tt>x86</tt> or <tt>ARM</tt> based stage and vice-versa. If you use a 32bit stage then you don't want to seed a 64bit build from it. Be sure that you are using a stage from the same architecture that you are trying to seed. Check [http://ftp.osuosl.org/pub/funtoo/funtoo-current/ Funtoo-current FTP Mirror] for a stage that is from the same Architecture that you will be building. 
  
{{TableStart}}
+
{{Note|Often, one build (ie. funtoo-current) can be used as a seed for another build such as funtoo-stable. However, hardened builds require hardened stages as seeds in order for the build to complete successfully.}}
<tr class="active"><td>Class Name</td></tr>
+
<tr class="success"><td>success</td></tr>
+
<tr class="info"><td>info</td></tr>
+
<tr class="warning"><td>warning</td></tr>
+
<tr class="active"><td>active</td></tr>
+
<tr class="danger"><td>danger</td></tr>
+
{{TableEnd}}
+
  
=== Displaying Source Code ===
+
== Step 1: Set up Core_2 32bit repository ==
  
To display source code, use can use the file template, specifying a <tt>lang=</tt> parameter:
+
In this example, we're going to use this pentium4 funtoo-current stage3 to seed a new Core_2 32bit funtoo-current build. To get that done, we need to set up the pentium4 build directory as follows:
  
<pre>
+
<console>
{{file|name=foobar|lang=python|desc=foobarosity|body=
+
# ##i## cd /home/mirror/funtoo/funtoo-current/x86-32bit
import system
+
# ##i##install -d core2_32
}}
+
# ##i##cd core2_32
</pre>
+
# ##i##install -d .control/strategy
 +
# ##i##echo remote > .control/strategy/build
 +
# ##i##echo stage3 > .control/strategy/seed
 +
# ##i##install -d .control/remote
 +
# ##i##echo funtoo-current > .control/remote/build
 +
# ##i##echo x86-32bit > .control/remote/arch_desc
 +
# ##i##echo pentium4 > .control/remote/subarch
 +
</console>
  
This will produce:
+
The steps we follow are similar to those we performed for a ''local build'' to set up our pentium4 directory for local build. However, note the differences. We didn't download a stage, because we are going to use the pentium4 stage to build a new Core_2 32bit stage. We also didn't create the <tt>.control/version/stage{1,3}</tt> files because Metro will create them for us after it successfully builds a new stage1 and stage3. We are still using a <tt>stage3</tt> seed strategy, but we've set the build strategy to <tt>remote</tt>, which means that we're going to use a seed stage that's not from this particular subdirectory. Where are we going to get it from? The <tt>.control/remote</tt> directory contains this information, and lets Metro know that it should look for its seed stage3 in the <tt>/home/mirror/funtoo/funtoo-current/x86-32bit/pentium4</tt> directory. Which one will it grab? You guessed it -- the most recently built ''stage3'' (since our seed strategy was set to <tt>stage3</tt>) that has the version stamp of <tt>2010-12-24</tt>, as recorded in <tt>/home/mirror/funtoo-current/x86-32bit/pentium4/.control/version/stage</tt>. Now you can see how all those control files come together to direct Metro to do the right thing.
  
{{file|name=foobar|lang=python|desc=foobarosity|body=
+
{{Note|<code>arch_desc</code> should be set to one of: <code>x86-32bit</code>, <code>x86-64bit</code> or <code>pure64</code> for PC-compatible systems. You must use a 32-bit build as a seed for other 32-bit builds, and a 64-bit build as a seed for other 64-bit builds.}}
import system
+
}}
+
  
The parameters {{c|name}} (filename), {{c|lang}} (language for syntax highlighting) and {{c|desc}} (Description, appearing as a caption) are optional. For a list of supported languages, see [http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi#Supported_languages this list].
+
== Step 2: Building the Core_2 32bit stages ==
  
 +
Now, you could start building your new Core_2 32bit stage1/2/3 (plus openvz and vserver templates) by typing the following:
  
{{important|If you need to display the pipe ("{{!}}") character within the body of a file template, replace each "{{!}}" with <nowiki>{{!}}</nowiki> -- otherwise your file contents will not display properly. This is necessary because <nowiki>{{file}}</nowiki> is a template and the "{{!}}" character is used as a delimiter for arguments to the template.}}
+
<console>
 +
# ##i##/root/metro/scripts/ezbuild.sh funtoo-current core2_32
 +
</console>
  
=== Displaying Text File Contents ===
+
In that case, the produced stages are placed in the <tt>/home/mirror/funtoo/funtoo-current/x32-bit/core2_32/YYYY-MM-DD</tt> subdirectory.
  
For displaying the contents of non-programming language text files (like config files), you have two options. You can enclose your lines within <tt>&#60;pre&#62;</tt> tags, or use the new [[Template:File|file template]]. The file template is used like so:
+
== Step 3: The Next Build ==
  
<pre>
+
At this point, you now have a new Core_2 32bit stage3, built using a "remote" pentium4 stage3. Once the first remote build completes successfully, metro will automatically change <code>.control/strategy/build</code> to be <code>local</code> instead of <code>remote</code>, so it will use the most recently-built Core_2 32bit stage3 as a seed for any new Core_2 32bit builds from now on.
{{file|name=/etc/foo.conf|desc=My foo.conf file|body=
+
# /etc/host.conf:
+
# $Header: /var/cvsroot/gentoo/src/patchsets/glibc/extra/etc/host.conf,v 1.1 2006/09/29
+
}}
+
</pre>
+
  
This will produce:
+
= Build your own tailored stage3 =
  
{{file|name=/etc/foo.conf|desc=My foo.conf file|body=
+
Metro can be easily configured for building custom stage3 by including additional packages. Edit the following configuration file <tt>/root/metro/etc/builds/funtoo-current/build.conf</tt>:
# /etc/host.conf:
+
{{file|name=funtoo-current/build.conf|body=
# $Header: /var/cvsroot/gentoo/src/patchsets/glibc/extra/etc/host.conf,v 1.1 2006/09/29
+
[collect ../../fslayouts/funtoo/layout.conf]
}}
+
  
=== Console ===
+
[section release]
To display console output, use the <nowiki>{{console}}</nowiki> template:
+
  
For a root console:
+
author: Daniel Robbins <drobbins@funtoo.org>
<pre>
+
{{console|body=
+
###i## run a command as root
+
}}
+
</pre>
+
Produces:
+
{{console|body=
+
###i## run a command as root
+
}}
+
  
For a non-root console:
+
[section target]
<pre>
+
{{console|body=
+
$ ##i##run a command as user
+
}}
+
</pre>
+
Produces:
+
{{console|body=
+
$ ##i##run a command as user
+
}}
+
  
{{important|1=
+
compression: xz
Note that we use a <tt>#</tt> prompt for <tt>root</tt> and a <tt>$</tt> prompt to denote a non-root user.}}
+
  
{{important|The <tt>##i##</tt> text tags the rest of the line as being ''user input'' ("i" is for "input"). It is then highlighted in a noticeable color so it stands out from text that is not typed in by the user.}}
+
[section portage]
  
If you need to end highlighting of user input prior to the end of a line, use <code>##!i##</code> to mark the end of the highlighted area.
+
FEATURES:
 +
SYNC: $[snapshot/source/remote]
 +
USE:
  
The following special character sequences are also available:
+
[section profile]
* <code>##g##</code> - Green
+
* <code>##y##</code> - Yellow
+
* <code>##bl##</code> - Blue
+
* <code>##r##</code> - Red
+
* <code>##b##</code> - Bold
+
  
Please use the above coloring options sparingly. It is sometimes nice to use them to get wiki console output to match the colors that are displayed on a Linux console. Also note that for every color above, there is a matching <code>##!(colorcode)##</code> option to turn color off prior to end of line.
+
format: new
 +
path: gentoo:funtoo/1.0/linux-gnu
 +
arch: $[:path]/arch/$[target/arch_desc]
 +
build: $[:path]/build/current
 +
flavor: $[:path]/flavor/core
 +
mix-ins:
  
Here is an example of its use:{{console|body=
+
[section version]
# ##i##bluetoothctl
+
[##g##NEW##!g##] Controller 00:02:72:C9:62:65 antec [default]
+
##bl##[bluetooth]##!bl### ##i##power on
+
Changing power on succeeded
+
##bl##[bluetooth]##!bl### ##i##agent on
+
Agent registered
+
##bl##[bluetooth]##!bl### ##i##scan on
+
Discovery started
+
##bl##[bluetooth]##!bl### ##i##devices
+
Device 00:1F:20:3D:1E:75 Logitech K760
+
##bl##[bluetooth]##!bl### ##i##pair 00:1F:20:3D:1E:75
+
Attempting to pair with 00:1F:20:3D:1E:75
+
[##y##CHG##!y##] Device 00:1F:20:3D:1E:75 Connected: yes
+
##r##[agent]##!r## Passkey: 454358
+
##r##[agent]##!r## Passkey: ##i##4##!i##54358
+
##r##[agent]##!r## Passkey: ##i##45##!i##4358
+
##r##[agent]##!r## Passkey: ##i##454##!i##358
+
##r##[agent]##!r## Passkey: ##i##4543##!i##58
+
##r##[agent]##!r## Passkey: ##i##45435##!i##8
+
##r##[agent]##!r## Passkey: ##i##454358##!i##
+
[##y##CHG##!y##] Device 00:1F:20:3D:1E:75 Paired: yes
+
Pairing successful
+
[##y##CHG##!y##] Device 00:1F:20:3D:1E:75 Connected: no
+
##bl##[bluetooth]##!bl### ##i##connect 00:1F:20:3D:1E:75
+
Attempting to connect to 00:1F:20:3D:1E:75
+
[##y##CHG##!y##] Device 00:1F:20:3D:1E:75 Connected: yes
+
Connection successful
+
##bl##[bluetooth]##!bl### ##i##quit
+
[##r##DEL##!r##] Controller 00:02:72:C9:62:65 antec [default]
+
#
+
}}
+
  
=== Informational Messages ===
+
python: 2.7
Notes, warnings, tips, and important templates can be used for informational messages that need to be offset from the regular text flow:
+
  
<pre>{{note|this is a note}}</pre>
+
[section emerge]
{{note|this is a note}}
+
  
<pre>{{important|this is important}}</pre>
 
{{important|this is important}}
 
  
<pre>{{warning|this is a warning}}</pre>
+
[section snapshot]
{{warning|this is a warning}}
+
  
<pre>{{tip|this is a tip}}</pre>
+
type: live
{{tip|this is a tip}}
+
compression: xz
  
Note that these templates used to be called <code>fancynote</code>, <code>fancytip</code>, etc. The "fancy" names have been deprecated but will still be supported for the forseeable future.
+
[section snapshot/source]
  
=== Kernelop ===
+
type: git
To display kernel configuration options, we encourage you to use the <tt>kernelop</tt> template. To use the <tt>kernelop</tt> template, create an entry similar to the following example:  
+
branch: funtoo.org
<pre>
+
# branch to have checked out for tarball:
{{kernelop|title=foo,bar|desc=
+
branch/tar: origin/master
kernel options pasted from "make menuconfig"
+
name: ports-2012
}}
+
remote: git://github.com/funtoo/ports-2012.git
</pre>
+
options: pull
  
{{note|Kernelop is colored blue to slightly resemble the blueish background from <tt>make menuconfig</tt>.}}
+
[section metro]
  
Adding this entry will give you the following output:  
+
options:  
{{kernelop|title=foo,bar|desc=
+
options/stage: cache/package
kernel options
+
target: gentoo
}}
+
  
Here's a more concrete example:
+
[section baselayout]
{{kernelop|title=File systems|desc=
+
<M> Second extended fs support         
+
[ ]   Ext2 extended attributes         
+
[ ]  Ext2 execute in place support   
+
<M> Ext3 journalling file system support
+
}}
+
  
Examples of usage:  
+
services: sshd
* [[Package:AMD Catalyst Video Drivers]]
+
* [[Package:ACPI Daemon]]
+
* [[Microcode]]
+
  
=== Discussion Pages ===
+
[section multi]
  
In MediaWiki, every "regular" wiki page has a corresponding "Talk" or "Discussion" page which has a page name prefixed by "Talk:" -- you can get to this page by going to the "Action" menu, and then choosing the "Discussion" menu item. These talk pages are typically used to discuss the edits that are going on in the "main" wiki page. The problem with talk pages is that they are kind of a pain to use. However, we have a way to fix that. If you want to enable a DISQUS-based mini-forum on a talk page, insert the following wikitext on the Talk page:
+
snapshot: snapshot
  
<pre>
+
[section files]
{{DISQUS}}
+
</pre>
+
  
...and presto! You will now have DISQUS-powered mini-forums to discuss whatever you want about your wiki page.
+
motd/trailer: [
  
== Marking Pages as Needing Updates ==
+
>>> Send suggestions, improvements, bug reports relating to...
  
If you find outdated wiki content, but you don't have the time or ability to update it, add one of the following templates to the wikitext of the page. This will add the page to the [[:Category:Needs Updates|Needs Updates Category]] so we can identify pages that need updating:
+
>>> This release:                  $[release/author]
 +
>>> Funtoo Linux (general):       Funtoo Linux (http://www.funtoo.org)
 +
>>> Gentoo Linux (general):       Gentoo Linux (http://www.gentoo.org)
 +
]
  
<pre>
+
[collect ../../multi-targets/$[multi/mode:zap]]
{{PageNeedsUpdates}}
+
}}
{{SectionNeedsUpdates}}
+
</pre>
+
  
 +
= Building Gentoo stages =
  
Examples of usage:
+
Currently, Gentoo stages cannot be built in Metro. We have an open bug for this -- it is simply due to the fact that we focus on ensuring Funtoo Linux builds and building Gentoo is a lower priority. Historical note: Funtoo Linux originally started as a fork of Gentoo Linux so that metro could reliably build Gentoo stages.
* [[UEFI Install Guide]]
+
* [[Package:MediaWiki]]
+
* [[Clang]]
+
  
=== Inline Code ===
+
= Advanced Features =
  
To emphasize commands, and other technical jargon when they appear inline in a paragraph, use the <nowiki>{{c}}</nowiki> template. When referencing files, use the <nowiki>{{f}}</nowiki> template.
+
Metro also includes a number of advanced features that can be used to automate builds and set up distributed build servers. These features require you to {{c|emerge sqlalchemy}}, as SQLite is used as a dependency.
  
<pre>
+
== Repository Management ==
The {{f|/etc/fstab}} file is an important one. Another important file is {{f|/boot/grub/grub.cfg}}. The {{c|emerge}} command is really nifty.
+
</pre>
+
  
This example produces the following output:
+
Metro includes a script in the {{c|scripts}} directory called {{c|buildrepo}}. Buildrepo serves as the heart of Metro's advanced repository management features.
  
The {{f|/etc/fstab}} file is an important one. Another important file is {{f|/boot/grub/grub.cfg}}. The {{c|emerge}} command is really nifty.
+
=== Initial Setup ===
  
{{important|1=
+
To use {{c|buildrepo}}, you will first need to create a {{f|.buildbot}} configuration file. Here is the file I use on my AMD Jaguar build server:
The &#60;tt&#62; tag has been deprecated for the purpose of tagging inline code, to conform with HTML5, and the previous use of the &#60;code&#62; tag is discouraged. It is more maintainable to use the <nowiki>{{c}}</nowiki> template. }}
+
  
=== Slideshow ===
+
{{file|name=/root/.buildbot|lang=python|body=
 +
builds = (
 +
"funtoo-current",
 +
"funtoo-current-hardened",
 +
"funtoo-stable",
 +
)
  
Any page has the capability of displaying a slideshow. Adding a slideshow to a page involves three steps:
+
arches = (
 +
"x86-64bit",
 +
"pure64"
 +
)
  
# Upload Images
+
subarches = (
# Define Slides
+
"amd64-jaguar",
# Add Slideshow to page
+
"amd64-jaguar-pure64",
 +
)
  
==== Upload Images ====
+
def map_build(build, subarch, full, full_date):
 
+
# arguments refer to last build...
To upload images, head to [[Special:Upload]] and upload a file. It is highly recommended to upload JPEG format images in high resolution -- MediaWiki will handle scaling JPEG automatically, saving bandwidth, but does not do this for PNG. Make sure that all images you upload have the same dimensions. When you upload, make note of the '''Destination Filename''' field -- this is the name that the upload will use when you reference it in your slide. It is recommended that you choose a simple descriptive name ending in ".jpg" for the '''Destination Filename'''.
+
if full == True:
 
+
buildtype = ( "freshen", )
==== Define Slides ====
+
else:
 
+
buildtype = ("full", )
Once images have been uploaded, you must define slides. To define slides on a page, you enter special semantic information about the slide on the page that it will be displayed, in the following format:
+
return buildtype
 
+
}}
<pre><nowiki>
+
{{#subobject:|slideIndex=0|slideCaption=
+
== Wikitext Here ==
+
This is a fantastic slide!
+
|slideImage=File:Fruit.jpg|slideLink=PageName}}
+
</nowiki></pre>
+
 
+
Here are some important instructions regarding defining slides:
+
 
+
* <code>slideIndex</code> must be 0 for the first slide, 1 for the second slide, etc. Numbers must be unique and incrementing from zero, and not doing this will result in slideshow display errors (but can be easily fixed by correcting the wikitext.)
+
* <code>slideCaption=</code> can contain wikitext, such as headings and links. The best way to enter <code>slideCaption</code> is as above -- type a literal <code>slideCaption=</code>, followed by enter, then specify your wikitext, and terminate the caption by a single pipe character on the following line. Pipe characters are used to separate arguments from each other.
+
* Specify your image name in the <code>slideImage</code> field. Your slideImage will have a name of <code>File:myname.jpg</code>, where <code>myname.jpg</code> is the '''Destination Filename''' you used when uploading the image.
+
* An optional parameter called <code>slideLink=</code> can be provided to allow the image to be clickable and link to another wiki page. If it is omitted, then the image will not be clickable.
+
 
+
==== Add Slideshow to Page ====
+
 
+
Once the slides have been added to the page, you can add the following text to your page at the point you'd like the slideshow to appear:
+
<pre>
+
{{Slideshow}}
+
</pre>
+
 
+
=== YouTube Videos (Screencasts, etc.) ===
+
 
+
Screencasting is an easy method to explain complex tasks. Take for instance <code>youtu.be/5KDei5mBfSg</code> and chop off the id and insert it into the following syntax to produce a video example.
+
 
+
<pre>{{#widget:YouTube16x9|id=5KDei5mBfSg}}</pre>
+
{{#widget:YouTube16x9|id=5KDei5mBfSg}}
+
  
{{tip|The sample video above explains how to create your own screencasts under Funtoo Linux.}}
+
This file is actually a python source file that defines the tuples {{c|builds}}, {{c|arches}} and {{c|subarches}}. These variables tell {{c|buildrepo}} which builds, arches and subarches it should manage. A {{c|map_build()}} function is also defined which {{c|buildbot}} uses to determine what kind of build to perform. The arguments passed to the function are based on the last successful build. The function can read these arguments and return a string to define the type of the next build. In the above example, the {{c|map_build()}} function will cause the next build after a freshen build to be a full build, and the next build after a full build to be a freshen build, so that the build will alternate between full and freshen.
  
Most YouTube videos are in 16x9 format and should use the <code>YouTube16x9</code> widget. There is also a <code>YouTube4x3</code> widget for videos with a 4x3 aspect ratio.
 
{{note|These YouTube widgets have been updated to be mobile-friendly.}}
 
  
[[Category:Wiki Development]]
+
[[Category:HOWTO]]
 +
[[Category:Metro]]
 +
__TOC__

Revision as of 19:07, February 20, 2015

Metro is the build system for Funtoo Linux and Gentoo Linux stages. It automates the bootstrapping process.

This tutorial will take you through installing, setting up and running Metro.

These other Metro documents are also available:

{{#ask: |format=ul }}

Preface

How Metro Works

Metro is the Funtoo Linux automated build system, and is used to build Funtoo Linux stage tarballs.

Metro cannot create a stage tarball out of thin air. To build a new stage tarball, Metro must use an existing, older stage tarball called a "seed" stage. This seed stage typically is used as the build environment for creating the stage we want.

Metro can use two kinds of seed stages. Traditionally, Metro has used a stage3 as a seed stage. This stage3 is then used to build a new stage1, which in turn is used to build a new stage2, and then a new stage3. This is generally the most reliable way to build Gentoo Linux or Funtoo Linux, so it's the recommended approach.

Important

After switching metro builds to Funtoo profile, Gentoo stages are no longer provided!

Seeds and Build Isolation

Another important concept to mention here is something called build isolation. Because Metro creates an isolated build environment, and the build environment is explicitly defined using existing, tangible entities -- a seed stage and a portage snapshot -- you will get consistent, repeatable results. In other words, the same seed stage, portage snapshot and build instructions will generate an essentially identical result, even if you perform the build a month later on someone else's workstation.

Local Build

Say you wanted to build a new pentium4 stage3 tarball. The recommended method of doing this would be to grab an existing pentium4 stage3 tarball to use as your seed stage. Metro will be told to use this existing pentium4 stage3 to build a new stage1 for the same pentium4. For this process, the generic pentium4 stage3 would provide the build environment for creating our new stage1. Then, the new stage1 would serve as the build environment for creating the new pentium4 stage2. And the new pentium4 stage2 would serve as the build environment for creating the new pentium4 stage3.

In the Metro terminology this is called a local build, which means a stage3 of a given architecture is used to seed a brand new build of the same architecture. Incidentally this will be the first exercise we are going to perform in this tutorial.

A week later, you may want to build a brand new pentium4 stage3 tarball. Rather than starting from the original pentium4 stage3 again, you'd probably configure Metro to use the most-recently-built pentium4 stage3 as the seed. Metro has built-in functionality to make this easy, allowing it to easily find and track the most recent stage3 seed available.

Remote Build

Metro can also perform remote build, where a stage3 of a different, but binary compatible, architecture is used as a seed to build a different architecture stage3. Consequentiality the second exercise we are going to perform in this tutorial will be to build a core2 32bit stage3 tarball from the pentium4 stage3 tarball we have just built.

TODO: add caveats about what archs can be seeded and what can be not (maybe a table?)

Tailored Build

Last, it's also worthy noting that both in local and remote builds, Metro can be configured to add and/or remove individual packages to the final tarball. Let's say you can't live without app-misc/screen, at the end of this tutorial, we will show how to have your tailored stage3 to include it.

Installing Metro

The recommended and supported method is to use the Git repository of Metro.

Ensure that Package:Git and dev-python/boto (package not on wiki - please add) (optional; required for EC2 support) are installed on your system:

# emerge dev-vcs/git
# emerge dev-python/boto

Next, clone the master git repository as follows:

# cd /root
# git clone git://github.com/funtoo/metro.git
# cp /root/metro/metro.conf ~/.metro

You will now have a directory called /root/metro that contains all the Metro source code.

Metro is now installed. It's time to customize it for your local system.

Configuring Metro

Note

Metro is not currently able to build Gentoo stages. See FL-901.

Daniel Robbins maintains Metro, so it comes pre-configured to successfully build Funtoo Linux releases. Before reading further, you might want to customize some basic settings like the number of concurrent jobs to fit your hardware's capabilities or the directory to use for produced stage archives. This is accomplished by editing ~/.metro which is the Metro's master configuration file.

Please note that path/install must point to where metro was installed. Point path/distfiles to where your distfiles reside. Also set path/mirror/owner and path/mirror/group to the owner and group of all the files that will be written to the build repository directory, which by default (as per the configuration file) is at /home/mirror/funtoo. The cache directory normally resides inside the temp directory -- this can be modified as desired. The cache directory can end up holding many cached .tbz2 packages, and eat up a lot of storage. You may want to place the temp directory on faster storage, for faster compile times, and place the cache directory on slower, but more plentiful storage.

.metro - Metro configuration
# Main metro configuration file - these settings need to be tailored to your install:

[section path]
install: /root/metro
tmp: /var/tmp/metro
cache: $[path/tmp]/cache
distfiles: /var/src/distfiles
work: $[path/tmp]/work/$[target/build]/$[target/name]

[section path/mirror]

: /home/mirror/funtoo
owner: root
group: repomgr
dirmode: 775

[section portage]

MAKEOPTS: auto 

[section emerge]

options: --jobs=4 --load-average=4 --keep-going=n

# This line should not be modified:
[collect $[path/install]/etc/master.conf]

Arch and Subarch

In the following example we are creating a pentium4 stage 3 compiled for x86-32bit binary compatibility. Pentium4 is a subarch of the x86-32bit architecture. Once you have metro installed you may find a full list of each subarch in your /root/metro/subarch directory each subarch will have the file extension .spec Example:

# ls /root/metro/subarch
# ls subarch/
amd64-bulldozer-pure64.spec  armv7a.spec          core-avx-i.spec         i686.spec         pentium.spec
amd64-bulldozer.spec         armv7a_hardfp.spec   core2_32.spec           k6-2.spec         pentium2.spec
amd64-k10-pure64.spec        athlon-4.spec        core2_64-pure64.spec    k6-3.spec         pentium3.spec
amd64-k10.spec               athlon-mp.spec       core2_64.spec           k6.spec           pentium4.spec
amd64-k8+sse3.spec           athlon-tbird.spec    corei7-pure64.spec      native_32.spec    pentiumpro.spec
amd64-k8+sse3_32.spec        athlon-xp.spec       corei7.spec             native_64.spec    prescott.spec
amd64-k8-pure64.spec         athlon.spec          generic_32.spec         niagara.spec      ultrasparc.spec
amd64-k8.spec                atom_32.spec         generic_64-pure64.spec  niagara2.spec     ultrasparc3.spec
amd64-k8_32.spec             atom_64-pure64.spec  generic_64.spec         nocona.spec       xen-pentium4+sse3.spec
armv5te.spec                 atom_64.spec         generic_sparcv9.spec    opteron_64.spec   xen-pentium4+sse3_64.spec
armv6j.spec                  btver1.spec          geode.spec              pentium-m.spec
armv6j_hardfp.spec           btver1_64.spec       i486.spec               pentium-mmx.spec

First stages build (local build)

To get this all started, we need to bootstrap the process by downloading an initial seed stage3 to use for building and place it in its proper location in /home/mirror/funtoo, so that Metro can find it. We will also need to create some special "control" files in /home/mirror/funtoo, which will allow Metro to understand how it is supposed to proceed.

Step 1: Set up pentium4 repository (local build)

Assuming we're following the basic steps outlined in the previous section, and building an unstable funtoo (funtoo-current) build for the pentium4, using a generic pentium4 stage3 as a seed stage, then here the first set of steps we'd perform:

# install -d /home/mirror/funtoo/funtoo-current/x86-32bit/pentium4
# install -d /home/mirror/funtoo/funtoo-current/snapshots
# cd /home/metro/mirror/funtoo/funtoo-current/x86-32bit/pentium4
# install -d 2011-12-13
# cd 2011-12-13
# wget -c http://ftp.osuosl.org/pub/funtoo/funtoo-current/x86-32bit/pentium4/2011-12-13/stage3-pentium4-funtoo-current-2011-12-13.tar.xz
# cd ..
# install -d .control/version
# echo "2011-12-13" > .control/version/stage3
# install -d .control/strategy
# echo local >  .control/strategy/build
# echo stage3 > .control/strategy/seed

OK, let's review the steps above. First, we create the directory /home/mirror/funtoo/funtoo-current/x86-32bit/pentium4, which is where Metro will expect to find unstable funtoo-current pentium4 builds -- it is configured to look here by default. Then we create a specially-named directory to house our seed x86 stage3. Again, by default, Metro expects the directory to be named this way. We enter this directory, and download our seed x86 stage3 from funtoo.org. Note that the 2010-12-24 version stamp matches. Make sure that your directory name matches the stage3 name too. Everything has been set up to match Metro's default filesystem layout.

Next, we go back to the /home/mirror/metro/funtoo-current/x86-32bit/pentium4 directory, and inside it, we create a .control directory. This directory and its subdirectories contain special files that Metro references to determine certain aspects of its behavior. The .control/version/stage3 file is used by Metro to track the most recently-built stage3 for this particular build and subarch. Metro will automatically update this file with a new version stamp after it successfully builds a new stage3. But because Metro didn't actually build this stage3, we need to set up the .control/version/stage3 file manually. This will allow Metro to find our downloaded stage3 when we set up our pentium4 build to use it as a seed. Also note that Metro will create a similar .control/version/stage1 file after it successfully builds an pentium4 funtoo-current stage1.

We also set up .control/strategy/build and .control/strategy/seed files with values of local and stage3 respectively. These files define the building strategy Metro will use when we build pentium4 funtoo-current stages. With a build strategy of local, Metro will source its seed stage from funtoo-current pentium4, the current directory. And with a seed strategy of stage3, Metro will use a stage3 as a seed, and use this seed to build a new stage1, stage2 and stage3.

Step 2: Building the pentium4 stages

Incidentally, if all you wanted to do at this point was to build a new pentium4 funtoo-current stage1/2/3 (plus openvz and vserver templates). You would begin the process by typing:

# cd /root/metro
# scripts/ezbuild.sh funtoo-current pentium4

If you have a slow machine, it could take several hours to be completed because several "heavy" components like gcc or glibc have to be recompiled in each stage. Once a stage has been successfully completed, it is placed in the "${METRO_MIRROR}/funtoo-current/x32-bit/pentium4/YYYY-MM-DD" subdirectory, where YYYY-MM-DD is today's date at the time the ezbuild.sh script was started or the date you put on the ezscript.sh command line.

Building for another binary compatible architecture (remote build)

As written above, Metro is able to perform remote build building different architecture stage3 from a binary compatible seeding stage3 (e.g. using a pentium4 stage3 to seed a Intel Core2 32bits stage3).

In the Metro terminology this is called a remote build (a stage 3 of a different, but binary compatible, architecture is used as a seed). What's not compatible? You can't use a Sparc architecture to generate an x86 or ARM based stage and vice-versa. If you use a 32bit stage then you don't want to seed a 64bit build from it. Be sure that you are using a stage from the same architecture that you are trying to seed. Check Funtoo-current FTP Mirror for a stage that is from the same Architecture that you will be building.

Note

Often, one build (ie. funtoo-current) can be used as a seed for another build such as funtoo-stable. However, hardened builds require hardened stages as seeds in order for the build to complete successfully.

Step 1: Set up Core_2 32bit repository

In this example, we're going to use this pentium4 funtoo-current stage3 to seed a new Core_2 32bit funtoo-current build. To get that done, we need to set up the pentium4 build directory as follows:

#  cd /home/mirror/funtoo/funtoo-current/x86-32bit
# install -d core2_32
# cd core2_32
# install -d .control/strategy
# echo remote > .control/strategy/build
# echo stage3 > .control/strategy/seed
# install -d .control/remote
# echo funtoo-current > .control/remote/build
# echo x86-32bit > .control/remote/arch_desc
# echo pentium4 > .control/remote/subarch

The steps we follow are similar to those we performed for a local build to set up our pentium4 directory for local build. However, note the differences. We didn't download a stage, because we are going to use the pentium4 stage to build a new Core_2 32bit stage. We also didn't create the .control/version/stage{1,3} files because Metro will create them for us after it successfully builds a new stage1 and stage3. We are still using a stage3 seed strategy, but we've set the build strategy to remote, which means that we're going to use a seed stage that's not from this particular subdirectory. Where are we going to get it from? The .control/remote directory contains this information, and lets Metro know that it should look for its seed stage3 in the /home/mirror/funtoo/funtoo-current/x86-32bit/pentium4 directory. Which one will it grab? You guessed it -- the most recently built stage3 (since our seed strategy was set to stage3) that has the version stamp of 2010-12-24, as recorded in /home/mirror/funtoo-current/x86-32bit/pentium4/.control/version/stage. Now you can see how all those control files come together to direct Metro to do the right thing.

Note

arch_desc should be set to one of: x86-32bit, x86-64bit or pure64 for PC-compatible systems. You must use a 32-bit build as a seed for other 32-bit builds, and a 64-bit build as a seed for other 64-bit builds.

Step 2: Building the Core_2 32bit stages

Now, you could start building your new Core_2 32bit stage1/2/3 (plus openvz and vserver templates) by typing the following:

# /root/metro/scripts/ezbuild.sh funtoo-current core2_32

In that case, the produced stages are placed in the /home/mirror/funtoo/funtoo-current/x32-bit/core2_32/YYYY-MM-DD subdirectory.

Step 3: The Next Build

At this point, you now have a new Core_2 32bit stage3, built using a "remote" pentium4 stage3. Once the first remote build completes successfully, metro will automatically change .control/strategy/build to be local instead of remote, so it will use the most recently-built Core_2 32bit stage3 as a seed for any new Core_2 32bit builds from now on.

Build your own tailored stage3

Metro can be easily configured for building custom stage3 by including additional packages. Edit the following configuration file /root/metro/etc/builds/funtoo-current/build.conf:

funtoo-current/build.conf
[collect ../../fslayouts/funtoo/layout.conf]

[section release]

author: Daniel Robbins <drobbins@funtoo.org>

[section target]

compression: xz

[section portage]

FEATURES: 
SYNC: $[snapshot/source/remote]
USE:

[section profile]

format: new
path: gentoo:funtoo/1.0/linux-gnu
arch: $[:path]/arch/$[target/arch_desc]
build: $[:path]/build/current
flavor: $[:path]/flavor/core
mix-ins:

[section version]

python: 2.7

[section emerge]


[section snapshot]

type: live
compression: xz

[section snapshot/source]

type: git
branch: funtoo.org
# branch to have checked out for tarball:
branch/tar: origin/master
name: ports-2012 
remote: git://github.com/funtoo/ports-2012.git
options: pull

[section metro]

options: 
options/stage: cache/package
target: gentoo

[section baselayout]

services: sshd

[section multi]

snapshot: snapshot

[section files]

motd/trailer: [

 >>> Send suggestions, improvements, bug reports relating to...

 >>> This release:                  $[release/author]
 >>> Funtoo Linux (general):        Funtoo Linux (http://www.funtoo.org)
 >>> Gentoo Linux (general):        Gentoo Linux (http://www.gentoo.org)
]

[collect ../../multi-targets/$[multi/mode:zap]]

Building Gentoo stages

Currently, Gentoo stages cannot be built in Metro. We have an open bug for this -- it is simply due to the fact that we focus on ensuring Funtoo Linux builds and building Gentoo is a lower priority. Historical note: Funtoo Linux originally started as a fork of Gentoo Linux so that metro could reliably build Gentoo stages.

Advanced Features

Metro also includes a number of advanced features that can be used to automate builds and set up distributed build servers. These features require you to emerge sqlalchemy, as SQLite is used as a dependency.

Repository Management

Metro includes a script in the scripts directory called buildrepo. Buildrepo serves as the heart of Metro's advanced repository management features.

Initial Setup

To use buildrepo, you will first need to create a .buildbot configuration file. Here is the file I use on my AMD Jaguar build server:
/root/.buildbot (python source code)
builds = (
	"funtoo-current",
	"funtoo-current-hardened",
	"funtoo-stable",
)
 
arches = (
	"x86-64bit",
	"pure64"
)
 
subarches = (
	"amd64-jaguar",
	"amd64-jaguar-pure64",
)
 
def map_build(build, subarch, full, full_date):
	# arguments refer to last build...
	if full == True:
		buildtype =  ( "freshen", )
	else:
		buildtype =  ("full", )
	return buildtype

This file is actually a python source file that defines the tuples builds, arches and subarches. These variables tell buildrepo which builds, arches and subarches it should manage. A map_build() function is also defined which buildbot uses to determine what kind of build to perform. The arguments passed to the function are based on the last successful build. The function can read these arguments and return a string to define the type of the next build. In the above example, the map_build() function will cause the next build after a freshen build to be a full build, and the next build after a full build to be a freshen build, so that the build will alternate between full and freshen.