Difference between revisions of "Funtoo:Metro"

From Funtoo
Jump to navigation Jump to search
(28 intermediate revisions by 2 users not shown)
Line 35: Line 35:
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.
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.


= Installing Metro =
== Installing Metro ==


Today the '''recommended and supported method''' is to use the Git repository of [[Metro]].  First ensure you remove the <tt>dev-util/metro</tt> package if you had installed it:
'''The recommended and supported method''' is to use the Git repository of [[Metro]].  First, ensure you remove the {{Package|dev-util/metro}} package if you had installed it:


<pre>
<console>
(~) # emerge -aC dev-util/metro
# ##i##emerge -aC dev-util/metro
</pre>
</console>


Then ensure that <tt>dev-vcs/git</tt> and <tt>dev-python/boto</tt> installed on your system:
Then ensure that {{Package|dev-vcs/git}} and {{Package|dev-python/boto}} are installed on your system:


<pre>
<console>
(~) # emerge dev-vcs/git
# ##i##emerge dev-vcs/git
(~) # emerge dev-python/boto
# ##i##emerge dev-python/boto
</pre>
</console>


Next, clone the master git repository as follows:
Next, clone the master git repository as follows:


<pre>
<console>
(~) # install -d /root/git
# ##i##cd /root
(~) # cd /root/git
# ##i##git clone git://github.com/funtoo/metro.git
(~/git) # git clone git://github.com/funtoo/metro.git
# ##i##ln -s /root/metro/metro /usr/bin/metro
(~/git) # ln -s /root/git/metro /usr/lib/metro
# ##i##cp /root/metro/metro.conf ~/.metro
(~/git) # ln -s /root/git/metro/metro /usr/bin/metro
</console>
</pre>


You will now have a directory called <tt>/root/git/metro</tt> that contains all the [[Metro]] source code.
You will now have a directory called <tt>/root/metro</tt> that contains all the [[Metro]] source code.
Installation complete!
 
Metro is now installed. It's time to customize it for your local system.


= Configuring Metro =
= Configuring Metro =


[[User:Drobbins|Daniel Robbins]] maintains [[Metro]], so it comes pre-configured to successfully build both [[Gentoo Linux]] and [[Funtoo Linux]] releases. Before reading farther, 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>/root/git/metro/etc/metro.conf</tt> which is the [[Metro]]'s master configuration file. The <tt>[path/mirror]</tt> section defines where [[Metro]] will look for things it needs and also dump things it creates. As initially configured, [[Metro]] is set up to build [[Funtoo Linux]] and [[Gentoo Linux]] stage tarballs and place them in the <tt>/home/mirror/linux</tt> directory:
{{Note|Metro is not currently able to build Gentoo stages. See {{Bug|FL-901}}.}}
 
[[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.
 
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>.
 
{{file|name=.metro|desc=Metro configuration|body=
# Main metro configuration file - these settings need to be tailored to your install:


<pre>
[section path]
# Mirror Paths - where to find required files and where to put created files
install: /root/metro
tmp: /var/tmp/metro
distfiles: /var/src/distfiles
work: $[path/tmp]/work/$[target/build]/$[target/name]


[section path/mirror]
[section path/mirror]


: /home/mirror/linux
: /home/mirror/funtoo
</pre>
owner: root
group: repomgr
dirmode: 775


If you want to change the location of your mirror on disk, then edit the <tt>/home/mirror/linux</tt> line (which defines the path/mirror variable) to point to another directory.
[section portage]


For the purpose of the following steps, set an environment variable:
MAKEOPTS: auto


<pre>
[section emerge]
(~) # export METRO_MIRROR=/home/mirror/linux
</pre>


Of course, set the environment variable to whatever location you used in the configuration file.
options: --jobs=4 --load-average=4 --keep-going=n
 
# This line should not be modified:
[collect $[path/install]/etc/master.conf]
}}


== Arch and Subarch ==
== 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 <tt>/usr/lib/metro/subarch</tt> directory each subarch will have the file extension .spec
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:
Example:
<pre>  
<console>
# ls /usr/lib/metro/subarch/
###i## ls /root/metro/subarch
amd64-k10.spec        athlon-tbird.spec generic_32.spec       native_32.spec   pentium-mmx.spec
# ls subarch/
amd64-k8_32.spec       athlon-xp.spec     generic_64.spec       native_64.spec   pentium-m.spec
amd64-bulldozer-pure64.spec  armv7a.spec          core-avx-i.spec        i686.spec        pentium.spec
amd64-k8.spec         atom_32.spec      generic_sparcv9.spec niagara2.spec   pentiumpro.spec
amd64-bulldozer.spec         armv7a_hardfp.spec   core2_32.spec           k6-2.spec        pentium2.spec
amd64-k8+sse3_32.spec atom_64.spec       geode.spec           niagara.spec     pentium.spec
amd64-k10-pure64.spec       athlon-4.spec       core2_64-pure64.spec   k6-3.spec         pentium3.spec
amd64-k8+sse3.spec     btver1_64.spec     i486.spec            nocona.spec     prescott.spec
amd64-k10.spec               athlon-mp.spec      core2_64.spec           k6.spec           pentium4.spec
armv7a.spec           btver1.spec       i686.spec             opteron_64.spec ultrasparc3.spec
amd64-k8+sse3.spec           athlon-tbird.spec   corei7-pure64.spec     native_32.spec   pentiumpro.spec
athlon-4.spec         core2_32.spec     k6-2.spec             pentium2.spec   ultrasparc.spec
amd64-k8+sse3_32.spec       athlon-xp.spec       corei7.spec            native_64.spec   prescott.spec
athlon-mp.spec         core2_64.spec     k6-3.spec             pentium3.spec   xen-pentium4+sse3_64.spec
amd64-k8-pure64.spec         athlon.spec         generic_32.spec         niagara.spec     ultrasparc.spec
athlon.spec           corei7.spec       k6.spec               pentium4.spec   xen-pentium4+sse3.spec
amd64-k8.spec               atom_32.spec         generic_64-pure64.spec niagara2.spec     ultrasparc3.spec
</pre>
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
For an example list of Architectures, take a look at the directory listing on the [http://ftp.osuosl.org/pub/funtoo/funtoo-current/ Funtoo-Current Mirror].
armv6j.spec                  btver1.spec          geode.spec              pentium-m.spec
armv6j_hardfp.spec          btver1_64.spec      i486.spec              pentium-mmx.spec
</console>


= First stages build (local build) =
= 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 <tt>/home/mirror/linux</tt>, so that [[Metro]] can find it. We will also need to create some special &quot;control&quot; files in <tt>/home/mirror/linux</tt>, which will allow [[Metro]] to understand how it is supposed to proceed.
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.


== Step 0: Optional Quick Copy of Portage Tree ==
== Step 0: Optional Quick Copy of Portage Tree ==
Line 112: Line 128:
There is a quick step you can perform to avoid having Metro re-clone the entire Portage tree. Perform this as root:
There is a quick step you can perform to avoid having Metro re-clone the entire Portage tree. Perform this as root:


<pre>
<console>
# cd /usr/portage; git checkout origin/master
# ##i##install -d /var/tmp/metro/cache/cloned-repositories
# install -d /var/tmp/metro/cache/cloned-repositories
# ##i##cat /root/metro/etc/builds/funtoo-current/build.conf  | grep name
# cat /root/git/metro/etc/builds/funtoo-current/build.conf  | grep name
# ##i##name: ports-2012
name: portage-mini-2011
# ##i##cp -a /usr/portage /var/tmp/metro/cache/cloned-repositories/ports-2012
# cp -a /usr/portage /var/tmp/metro/cache/cloned-repositories/ports-2012
# ##i##cd /usr/portage; git checkout funtoo.org
# cd /usr/portage; git checkout funtoo.org
</console>
</pre>


== Step 1: Set up pentium4 repository (local build) ==
== Step 1: Set up pentium4 repository (local build) ==
Line 125: Line 140:
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:
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:


<pre>
<console>
(~) # install -d "${METRO_MIRROR}/funtoo-current/x86-32bit/pentium4"
# ##i##install -d "${METRO_MIRROR}/funtoo-current/x86-32bit/pentium4"
(~) # cd "${METRO_MIRROR}/funtoo-current/x86-32bit/pentium4"
# ##i##cd "${METRO_MIRROR}/funtoo-current/x86-32bit/pentium4"
(/home/mirror/linux/funtoo-current/x86-32bit/pentium4) # install -d 2011-12-13
# ##i##install -d 2011-12-13
(/home/mirror/linux/funtoo-current/x86-32bit/pentium4) # cd 2011-12-13
# ##i##cd 2011-12-13
(/home/mirror/linux/funtoo-current/x86-32bit/pentium4/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
# ##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
(/home/mirror/linux/funtoo-current/x86-32bit/pentium4/2011-12-13) # cd ..
# ##i##cd ..
(/home/mirror/linux/funtoo-current/x86-32bit/pentium4) # install -d .control/version
# ##i##install -d .control/version
(/home/mirror/linux/funtoo-current/x86-32bit/pentium4) # echo &quot;2011-12-13&quot; &gt; .control/version/stage3
# ##i##echo &quot;2011-12-13&quot; &gt; .control/version/stage3
(/home/mirror/linux/funtoo-current/x86-32bit/pentium4) # install -d .control/strategy
# ##i##install -d .control/strategy
(/home/mirror/linux/funtoo-current/x86-32bit/pentium4) # echo &quot;local&quot; &gt; .control/strategy/build
# ##i##echo &quot;local&quot; &gt; .control/strategy/build
(/home/mirror/linux/funtoo-current/x86-32bit/pentium4) # echo &quot;stage3&quot; &gt; .control/strategy/seed
# ##i##echo &quot;stage3&quot; &gt; .control/strategy/seed
</pre>
</console>


OK, let's review the steps above. First, we create the directory <tt>"${METRO_MIRROR}/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.
OK, let's review the steps above. First, we create the directory <tt>"${METRO_MIRROR}/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.
Line 149: Line 164:
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:
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>
# cd /root/git/metro
# ##i##cd /root/metro
# scripts/ezbuild.sh funtoo-current pentium4
# ##i##scripts/ezbuild.sh funtoo-current pentium4
</pre>
</console>


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.
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.
Line 160: Line 175:
At this point, you now have a new pentium4 stage3. If you'd like, you can reconfigure Metro to use the most recently-built pentium4 stage3 as a seed for any pentium4 builds. To do this, simply type:
At this point, you now have a new pentium4 stage3. If you'd like, you can reconfigure Metro to use the most recently-built pentium4 stage3 as a seed for any pentium4 builds. To do this, simply type:


<pre>(~) # echo &quot;local&quot; &gt; /home/mirror/linux/funtoo-current/x86-32bit/pentium4/.control/strategy/build</pre>
<console> # ##i##echo &quot;local&quot; &gt; /home/mirror/funtoo/funtoo-current/x86-32bit/pentium4/.control/strategy/build</console>
Now, Metro will use the most recentpentium4 stage3 as a seed. The <tt>.control/remote</tt> files you created will be ignored by Metro, since it's no longer going to perform a remote build.
Now, Metro will use the most recentpentium4 stage3 as a seed. The <tt>.control/remote</tt> files you created will be ignored by Metro, since it's no longer going to perform a remote build.


Line 169: Line 184:
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).  
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.   
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.   
{{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 ==
== Step 1: Set up Core_2 32bit repository ==
Line 174: Line 191:
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:
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>
(~) # cd "${METRO_MIRROR}/funtoo-current/x86-32bit"
# ##i## cd "${METRO_MIRROR}/funtoo-current/x86-32bit"
(/home/mirror/linux/funtoo-current/x86-32bit) # install -d core2_32
# ##i##install -d core2_32
(/home/mirror/linux/funtoo-current/x86-32bit) # cd core2_32
# ##i##cd core2_32
(/home/mirror/linux/funtoo-current/x86-32bit/core2_32) # install -d .control/strategy
# ##i##install -d .control/strategy
(/home/mirror/linux/funtoo-current/x86-32bit/core2_32) # echo &quot;remote&quot; &gt; .control/strategy/build
# ##i##echo &quot;remote&quot; &gt; .control/strategy/build
(/home/mirror/linux/funtoo-current/x86-32bit/core2_32) # echo &quot;stage3&quot; &gt; .control/strategy/seed
# ##i##echo &quot;stage3&quot; &gt; .control/strategy/seed
(/home/mirror/linux/funtoo-current/x86-32bit/core2_32) # install -d .control/remote
# ##i##install -d .control/remote
(/home/mirror/linux/funtoo-current/x86-32bit/core2_32) # echo &quot;funtoo-current&quot; &gt; .control/remote/build
# ##i##echo &quot;funtoo-current&quot; &gt; .control/remote/build
(/home/mirror/linux/funtoo-current/x86-32bit/core2_32) # echo &quot;pentium4&quot; &gt; .control/remote/subarch
# ##i##echo &quot;x86-32bit&quot; &gt; .control/remote/arch_desc
</pre>
# ##i##echo &quot;pentium4&quot; &gt; .control/remote/subarch
</console>


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>"${METRO_MIRROR}/home/mirror/linux/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>"${METRO_MIRROR}/funtoo-current/x86-32bit/pentium4/.control/version/stage3"</tt>. Now you can see how all those control files come together to direct Metro to do the right thing.
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.
 
{{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.}}


== Step 2: Building the Core_2 32bit stages ==
== Step 2: Building the Core_2 32bit stages ==
Line 192: Line 212:
Now, you could start building your new Core_2 32bit stage1/2/3 (plus openvz and vserver templates) by typing the following:
Now, you could start building your new Core_2 32bit stage1/2/3 (plus openvz and vserver templates) by typing the following:


<pre>
<console>
(~) # /root/git/metro/scripts/ezbuild.sh funtoo-current core2_32
# ##i##/root/metro/scripts/ezbuild.sh funtoo-current core2_32
</pre>
</console>


In that case, the produced stages are placed in the <tt>"${METRO_MIRROR}/funtoo-current/x32-bit/core2_32/YYYY-MM-DD"</tt> subdirectory.
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.


== Step 3: The Next Build ==
== Step 3: The Next Build ==
Line 206: Line 226:
To do this, simply type:
To do this, simply type:


<pre>
<console>
(~) # echo &quot;local&quot; &gt; /home/mirror/linux/funtoo-current/x86-32bit/core2_32/.control/strategy/build
# ##i##echo &quot;local&quot; &gt; /home/mirror/funtoo/funtoo-current/x86-32bit/core2_32/.control/strategy/build
</pre>
</console>


Now, Metro will use the most recent Core_2 32bit stage3 as a seed. The <tt>.control/remote</tt> files you created will be ignored by Metro, since it's no longer going to perform a remote build.
Now, Metro will use the most recent Core_2 32bit stage3 as a seed. The <tt>.control/remote</tt> files you created will be ignored by Metro, since it's no longer going to perform a remote build.
Line 214: Line 234:
= Build your own tailored stage3 =
= Build your own tailored stage3 =


Metro can be easily configured for building custom stage3 by including additional packages. Notice that including packages with heavy dependencies such as gnome, kde, xorg-server is not recommended (not tested so far). Well tested packages are <tt>app-misc/mc</tt>, <tt>app-misc/screen</tt>, <tt>sys-process/htop</tt>, <tt>sys-apps/dstat</tt>. An example for funtoo-current stage. Edit the following configuration file <tt>/root/git/metro/etc/builds/funtoo-current/build.conf</tt>:
Metro can be easily configured for building custom stage3 by including additional packages. Notice that including packages with heavy dependencies such as gnome, kde, xorg-server is not recommended (not tested so far). Well tested packages are <tt>app-misc/mc</tt>, <tt>app-misc/screen</tt>, <tt>sys-process/htop</tt>, <tt>sys-apps/dstat</tt>. An example for funtoo-current stage. Edit the following configuration file <tt>/root/metro/etc/builds/funtoo-current/build.conf</tt>:
 
{{file|name=funtoo-current/build.conf|body=
<pre>
[collect ../../fslayouts/funtoo/layout.conf]
[collect ../../fslayouts/funtoo/layout.conf]


[section local]
[section release]


author: Daniel Robbins <drobbins@funtoo.org>
author: Daniel Robbins <drobbins@funtoo.org>
Line 225: Line 244:
[section target]
[section target]


build: funtoo-current
compression: xz
compression: xz


[section portage]
[section portage]


stable: ~
FEATURES:  
MAKEOPTS: -j12
FEATURES: mini-manifest
SYNC: $[snapshot/source/remote]
SYNC: $[snapshot/source/remote]
USE:
USE:
profile: default/linux/$[target/arch:zap]/2008.0
 
[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 emerge]


options: --jobs=4 --load-average=3 --keep-going=n
packages: [
dev-vcs/git
net-misc/dhcpcd
sys-fs/reiserfsprogs
net-misc/bridge-utils
sys-devel/bc
sys-apps/pciutils
app-portage/gentoolkit
        app-misc/mc
        app-misc/screen
        sys-process/htop
        sys-apps/dstat
           
]


[section snapshot]</pre>
[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


As you can see MAKEOPTS and emerge default options are additional strings to tweak, --keep-going=n is recommended, if something breaking during the stage building process, you can quickly diagnose the problem.
[section multi]


Distfiles location can be specified in <tt>/root/git/metro/etc/metro.conf</tt>
snapshot: snapshot


<pre>
[section files]
# Main metro configuration file
#
# Path configuration:


[collect ../targets/$[metro/target]/$[target:zap].spec]
motd/trailer: [
[collect ./builds/$[metro/build]/build.conf]
[collect ../subarch/$[target/subarch:zap].spec]


# General Paths
>>> Send suggestions, improvements, bug reports relating to...


[section path]
>>> This release:                  $[release/author]
tmp: /var/tmp/metro
>>> Funtoo Linux (general):        Funtoo Linux (http://www.funtoo.org)
distfiles: /var/portage/distfiles
>>> Gentoo Linux (general):        Gentoo Linux (http://www.gentoo.org)
work: $[path/tmp]/work/$[metro/build]/$[target/name]
]
 
[collect ../../multi-targets/$[multi/mode:zap]]
}}


[section path/cache]
</pre>
= Building Gentoo stages =
= Building Gentoo stages =


[[Category:HOWTO]]
[[Category:HOWTO]]
[[Category:Metro]]
[[Category:Metro]]

Revision as of 06:04, November 17, 2014

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.

Preface

How Metro Works

You may be wondering how Metro creates its first stage tarball. As you may have guessed, 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. First, ensure you remove the No results package if you had installed it:

root # emerge -aC dev-util/metro

Then ensure that dev-vcs/git and No results are installed on your system:

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

Next, clone the master git repository as follows:

root # cd /root
root # git clone git://github.com/funtoo/metro.git
root # ln -s /root/metro/metro /usr/bin/metro
root # 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.

   .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
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:

root # ls /root/metro/subarch
root # 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 0: Optional Quick Copy of Portage Tree

There is a quick step you can perform to avoid having Metro re-clone the entire Portage tree. Perform this as root:

root # install -d /var/tmp/metro/cache/cloned-repositories
root # cat /root/metro/etc/builds/funtoo-current/build.conf  | grep name
root # name: ports-2012
root # cp -a /usr/portage /var/tmp/metro/cache/cloned-repositories/ports-2012
root # cd /usr/portage; git checkout funtoo.org

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:

root # install -d "${METRO_MIRROR}/funtoo-current/x86-32bit/pentium4"
root # cd "${METRO_MIRROR}/funtoo-current/x86-32bit/pentium4"
root # install -d 2011-12-13
root # cd 2011-12-13
root # 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
root # cd ..
root # install -d .control/version
root # echo "2011-12-13" > .control/version/stage3
root # install -d .control/strategy
root # echo "local" > .control/strategy/build
root # echo "stage3" > .control/strategy/seed

OK, let's review the steps above. First, we create the directory "${METRO_MIRROR}/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 "${METRO_MIRROR}/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:

root # cd /root/metro
root # 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.

Step 3: The next build

At this point, you now have a new pentium4 stage3. If you'd like, you can reconfigure Metro to use the most recently-built pentium4 stage3 as a seed for any pentium4 builds. To do this, simply type:

 # echo "local" > /home/mirror/funtoo/funtoo-current/x86-32bit/pentium4/.control/strategy/build

Now, Metro will use the most recentpentium4 stage3 as a seed. The .control/remote files you created will be ignored by Metro, since it's no longer going to perform a remote build.

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:

root #  cd "${METRO_MIRROR}/funtoo-current/x86-32bit"
root # install -d core2_32
root # cd core2_32
root # install -d .control/strategy
root # echo "remote" > .control/strategy/build
root # echo "stage3" > .control/strategy/seed
root # install -d .control/remote
root # echo "funtoo-current" > .control/remote/build
root # echo "x86-32bit" > .control/remote/arch_desc
root # 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 # /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. If you'd like, you can reconfigure Metro to use the most recently-built Core_2 32bit stage3 as a seed for any new Core_2 32bit builds.

In the Metro terminology this is called a local build (a stage 3 of a a given architecture is used to seed a brand new build of the same architecture).

To do this, simply type:

root # echo "local" > /home/mirror/funtoo/funtoo-current/x86-32bit/core2_32/.control/strategy/build

Now, Metro will use the most recent Core_2 32bit stage3 as a seed. The .control/remote files you created will be ignored by Metro, since it's no longer going to perform a remote build.

Build your own tailored stage3

Metro can be easily configured for building custom stage3 by including additional packages. Notice that including packages with heavy dependencies such as gnome, kde, xorg-server is not recommended (not tested so far). Well tested packages are app-misc/mc, app-misc/screen, sys-process/htop, sys-apps/dstat. An example for funtoo-current stage. 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