Jump to: navigation, search


15,006 bytes removed, 1 year ago
Update ego upstream location
<languages/>{{Software|name=Metro|authors=[[MetroUser:Drobbins|Daniel Robbins]] |description=Metro is the Funtoo Linux automated build system for [[, and is used to build Funtoo Linuxstage tarballs.|source=[ GitHub]] }}{{Subpages|AutoSetup,Manual Setup,Concepts and [[Gentoo Linux]] stages. It automates the bootstrapping process.Terminology,Configuring Metro,Recipes,Automation,Data Model}}<translate><!--T:1-->== Introduction ==
Metro is the tool used by Funtoo Linux to build new releases of Funtoo Linux. It is also available to the public and can be used to build custom versions of Funtoo Linux, or used by developers to perform build testing. This tutorial will take you through installingpage documents how to install, setting up configure and running [[use Metro]]. Also note that there is various additional supplemental documentation available on sub-pages, with links above.
= Preface = Installation ===== Prerequisites ===
== How Metro Works == <!--T:22-->Ensure that {{Package|dev-vcs/git}}, {{Package|dev-python/requests}}, {{Package|dev-python/sqlalchemy}} and {{Package|dev-python/lxml}} are installed on your system.
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 &quot;seed&quot; stage. This &quot;seed&quot; stage typically is used as the ''build environment'' for creating the stage we want.<!--T:23-->{{console|body=# ##i##emerge dev-vcs/git dev-python/requests dev-python/sqlalchemy dev-python/lxml}}
[[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'''!}}=== Prerequisites for QEMU Support ===
== Seeds Metro now supports building arm-32bit and Build Isolation ==arm-64bit stages on x86-64bit systems, using qemu. To enable this functionality, it isnecessary to emerge {{Package|app-emulation/qemu}} with the following settings.
Another important concept to mention here is something called ''build isolation''. Because [[Metro]] creates an isolated build environmentFirst, and add 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, following to{{f|/etc/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/package.use}}:
{{file|name=/etc/portage/package.use|body= Local Build == app-emulation/qemu static-userdev-libs/glib static-libssys-apps/attr static-libssys-libs/zlib static-libsdev-libs/libpcre static-libs}}
Say you wanted to build a new <tt>pentium4</tt> stage3 tarball. The recommended method of doing this would Next, the following should be added to grab an existing <tt>pentium4<{{f|/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<etc/tt> stage3make.conf}}:
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{{file|name=/etc/make.conf|body=QEMU_USER_TARGETS="aarch64 arm"}}
A week laterThen, 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.emerge qemu:
{{console|body== Remote Build == # ##i##emerge app-emulation/qemu}}
[[From this point forward, support for ARM on x86 systems should work transparently. Metro]] can also perform '''remote build''', where will take care of compiling a stage3 wrapper for qemu and temporarily installing the static version of a different, but binary compatible, architecture is used as a seed to build a different architecture stage3qemu inside the stage chroot so that ARM binaries will run transparently on x86 systems. Consequentiality the second exercise we are going to perform in this tutorial Metro will be to build also automatically register qemu as a <tt>core2 32bit</tt> stage3 tarball from "binary format" with the <tt>pentium4</tt> stage3 tarball we have just builtkernel.
TODO=== Cloning Metro ===<!--T: add caveats about what archs can be seeded 24-->'''The recommended and what can be not (maybe a table?)supported method for installing metro''' is to clone metro's git repository to {{f|/root}}. Clone the master git repository as follows:
<!--T:25-->{{console|body== Tailored Build == # ##i##cd /root# ##i##git clone ##i##cp /root/metro/metro.conf ~/.metro}}
Last, it's also worthy noting that both in <tt>local<{{Tip|The {{f|/tt> and <tt>remote builds<root/tt>.metro}} file contains the system metro configuration, [[Metro]] can and defines where the build repository and other files should be configured to add stored. Defaults are typically fine for most users, and{{f|/or remove individual packages to the final tarball.Let's say you can't live without <tt>app-mischome/screen<mirror/tt>, at funtoo}} will be used as the end of this tutorialbuild repository path. For more information on configuration settings available, we will show how to have your tailored stage3 to include itsee [[Metro/Configuring Metro]].}}
= Installing You will now have a directory called {{c|/root/metro}} that contains all the Metro =source code.
'''recommended and supported method''' === Setting up ego===Now, we will set the {{c|ego}}, administration tool of Funtoo Linux. The way it is used with metro is independent from {{c|app-admin/ego}} installed on your box. This local cloned copy of ego allows metro to potentially use the Git repository a newer version of [[Metro]]ego than what is already installed on your system, or to function under other non-Funtoo distributions like Gentoo or Ubuntu. First ensure Set up as follows:{{console|body=# ##i##cd /root# ##i##git clone}}This way you remove the <tt>dev-utilwill have {{c|/root/ego}} directory with {{c|ego}} binary that is then used by metro</tt> package if you had installed it:.
<console># ##i##emerge -aC dev-util/metro</console>== Build Repository Setup ==
Then ensure that <tt>dev-vcsMetro uses a repository to store built stages and snapshots, which typically resides at {{f|/home/git<mirror/tt> and <tt>devfuntoo}}. There are two methods to set up your build repository --pythonit can be done [[Metro/boto<Manual Setup|manually]] or [[Metro/tt> installed on your system:AutoSetup|with our auto-setup script.]] The auto-setup script is of course faster and easier, while the manual method may give you a deeper understanding of how the build repository internals work.
<console># ##i##emerge dev-vcs/git# ##i##emerge dev-python/boto</console>== First Build ==
NextOnce your build repository has been set up, clone you can start your first build using a command similar to the master git repository as followsone below:
<console># ##i##install -d /root/git# ##i##cd /root/git# ##i##git clone git:// ##i##ln -s /root/git/metro /usr/lib/metro# ##i##ln -s /root/git/metro/metro /usr/bin/metro</{{console> You will now have a directory called <tt>/root/git/metro</tt> that contains all the [[Metro]] source code.Installation complete! = 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: <pre># Mirror Paths - where to find required files and where to put created files [section path/mirror] : /home/mirror/linux</pre> 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. For the purpose of the following steps, set an environment variable: <pre>(~) # export METRO_MIRROR=/home/mirror/linux</pre>  Of course, set the environment variable to whatever location you used in the configuration file. == 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 .specExample:<pre> # ls /usr/lib/metro/subarch/amd64-k10.spec athlon-tbird.spec generic_32.spec native_32.spec pentium-mmx.specamd64-k8_32.spec athlon-xp.spec generic_64.spec native_64.spec pentium-m.specamd64-k8.spec atom_32.spec generic_sparcv9.spec niagara2.spec pentiumpro.specamd64-k8+sse3_32.spec atom_64.spec geode.spec niagara.spec pentium.specamd64-k8+sse3.spec btver1_64.spec i486.spec nocona.spec prescott.specarmv7a.spec btver1.spec i686.spec opteron_64.spec ultrasparc3.specathlon-4.spec core2_32.spec k6-2.spec pentium2.spec ultrasparc.specathlon-mp.spec core2_64.spec k6-3.spec pentium3.spec xen-pentium4+sse3_64.specathlon.spec corei7.spec k6.spec pentium4.spec xen-pentium4+sse3.spec</pre> For an example list of Architectures, take a look at the directory listing on the [ Funtoo-Current Mirror]. = 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. == 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: <pre># cd /usr/portage; git checkout origin/master# install -d /var/tmp/metro/cache/cloned-repositories# cat /root/git/metro/etc/builds/funtoo-current/build.conf | grep namename: portage-mini-2011# cp -a /usr/portage /var/tmp/metro/cache/cloned-repositories/ports-2012# cd /usr/portage; git checkout</pre> == Step 1: Set up pentium4 repository (local build) =bodyAssuming 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>(~) # install -d "${METRO_MIRROR}/funtoo-current/x86-32bit/pentium4"(~) # cd "${METRO_MIRROR}/funtoo-current/x86-32bit/pentium4"(/home/mirror/linux/funtoo-current/x86-32bit/pentium4) # install -d 2011-12-13(/home/mirror/linux/funtoo-current/x86-32bit/pentium4) # cd 2011-12-13(/home/mirror/linux/funtoo-current/x86-32bit/pentium4/2011-12-13) # wget -c # cd ..(/home/mirror/linux/funtoo-current/x86-32bit/pentium4) # install -d .control/version(/home/mirror/linux/funtoo-current/x86-32bit/pentium4) # echo &quot;2011-12-13&quot; &gt; .control/version/stage3(/home/mirror/linux/funtoo-current/x86-32bit/pentium4) # install -d .control/strategy(/home/mirror/linux/funtoo-current/x86-32bit/pentium4) # echo &quot;local&quot; &gt; .control/strategy/build(/home/mirror/linux/funtoo-current/x86-32bit/pentium4) # echo &quot;stage3&quot; &gt; .control/strategy/seed</pre> 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 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. Next, we go back to the <tt>"${METRO_MIRROR}/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. 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. == 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: <console># ##i##cd /root/gitmetro/metro# ##i##scripts/ funtoo-current pentium4</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 stage1. 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></tt> script was started or the date you put on the 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: <pre>(~) # echo &quot;local&quot; &gt; /home/mirror/linux/funtoorelease-current/std x86-32bit/pentium4/.control/strategy/build</pre>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. = 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 <tt>Intel Core2 32bits</tt> 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 <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 [ Funtoo-current FTP Mirror] for a stage that is from the same Architecture that you will be building.  == 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:zen full <pre>(~) # cd "${METRO_MIRROR}/funtoo-current/x86-32bit"(/home/mirror/linux/funtoo-current/x86-32bit) # install -d core2_32(/home/mirror/linux/funtoo-current/x86-32bit) # cd core2_32(/home/mirror/linux/funtoo-current/x86-32bit/core2_32) # install -d .control/strategy(/home/mirror/linux/funtoo-current/x86-32bit/core2_32) # 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(/home/mirror/linux/funtoo-current/x86-32bit/core2_32) # install -d .control/remote(/home/mirror/linux/funtoo-current/x86-32bit/core2_32) # 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</pre> 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. == 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: <pre>(~) # /root/git/metro/scripts/ funtoo-current core2_32</pre> In that case, the produced stages are placed in the <tt>"${METRO_MIRROR}/funtoo-current/x32-bit/core2_32/YYYY-MM-DD"</tt> 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: <pre>(~) # echo &quot;local&quot; &gt; /home/mirror/linux/funtoo-current/x86-32bit/core2_32/.control/strategy/build</pre> 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. = 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>: <pre>[collect ../../fslayouts/funtoo/layout.conf] [section local] author: Daniel Robbins <> [section target] build: funtoo-currentcompression: xz [section portage] stable: ~MAKEOPTS: -j12FEATURES: mini-manifestSYNC: $[snapshot/source/remote]USE:profile: default/linux/$[target/arch:zap]/2008.0 [section emerge] options: --jobs=4 --load-average=3 --keep-going=npackages: [ 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> 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. Distfiles location can be specified in <tt>/root/git/metro/etc/metro.conf</tt> <pre># Main metro configuration file# # Path configuration: [collect ../targets/$[metro/target]/$[target:zap].spec][collect ./builds/$[metro/build]/build.conf][collect ../subarch/$[target/subarch:zap].spec] # General Paths [section path]tmp: /var/tmp/metrodistfiles: /var/portage/distfileswork: $[path/tmp]/work/$[metro/build]/$[target/name] [section path/cache]</pre>= Building Gentoo stages =
[[Category:Official Documentation]]

Navigation menu