Difference between revisions of "Funtoo:Metro/pt-br"

From Funtoo
Jump to navigation Jump to search
m (Drobbins moved page Pt-br/Metro to Metro/pt-br)
(Updating to match new version of source page)
Line 1: Line 1:
{{#layout:doc}}{{#widget:AddThis}}[[Metro]] é o build system para os stages Funtoo Linux e [[Pt-br/Gentoo_Linux|Gentoo Linux]]. Ele automatiza o processo de bootstrap.
<languages/>
{{#layout:doc}}{{#widget:AddThis}}[[Metro]] is the build system for Funtoo Linux and [[Gentoo Linux]] stages. It automates the bootstrapping process.


Esse tutorial te guiará através da instalação, configuração e execução do [[Metro]].
This tutorial will take you through installing, setting up and running [[Metro]].


Esses outros documentos do Metro também estão disponíveis:
Other [[:Category:Metro|Metro Documentation]] is available.
 
{{#ask: [[Category:Metro]]
|format=ul
}}


= Preface =  
= Preface =  


== Como o Metro Funciona ==  
== How Metro Works ==  


Metro é um sistema de construção automática do Funtoo, e é utilizado para construir  os tarballs do Linux stage tarballs.
Metro is the Funtoo Linux automated build system, and is used to build Funtoo Linux stage tarballs.


[[Metro]] Não pode gerar um stage tarball vazio. Para gerar um novo stage tarball, o [[Pt-br/Metro|Metro]] precisa utilizar um stage tarball antigo existente chamado de um "seed" stage. Esse seed stage tipicamente é utilizando como o ''ambiente build'' para a criação do stage que queremos.
[[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.


O [[Metro]] pode utilizar dois tipos de seed stages. Tradicionalmente, o [[Pt-br/Metro|Metro]] tem utilizando um stage3 como um seed stage. Esse stage3 é então utilizado para construir um novo stage1, que por sua vez é utilizado para construir um novo stage2, e depois um novo stage3. Esse é geralmente o mais confiável meio de construir [[Gentoo Linux]] ou Funtoo Linux, assim ele é a aproximação recomendada.
[[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|'''Depois de carregar o metro builds no Funtoo profile, Gentoo stages não são mais fornecidos'''!}}
{{fancyimportant|'''After switching metro builds to Funtoo profile, Gentoo stages are no longer provided'''!}}


== Seeds e Build Isolation ==
== Seeds and Build Isolation ==


um outro conceito importante a mencionar aqui é algo chamado de ''build isolation''. Porque o [[Pt-br/Metro|Metro]] gera um ambiente build isolado, e o ambiente build é explicitamente definido utilizando entidades tangíveis existentes -- um seed stage e um portage snapshot -- você obterá resultados repetíveis, consistentes. Em outras palavras, A mesma seed stage, portage snapshot e instruções de build gerarão um resultado essencialmente idêntico, mesmo se você desempenhar o build um mês depois na workstation de outra pessoa.
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.


== Build Local ==  
== Local Build ==  


Digamos que você quisesse construir um novo stage3 tarball <tt>pentium4</tt>. O método recomendado de se fazer isso seria agarrar um stage3 tarball <tt>pentium4</tt> existente para utilizar como seu seed stage. Será dito ao [[Metro]] que utilizr esse stage3 <tt>pentium4</tt> existente para construir um novo stage1 para o mesmo <tt>pentium4</tt>. Para esse processo, o stage3 <tt>pentium4</tt> genérico forneceria o ''build environment'' para a criação de nosso novo stage1. Depois, o novo stage1 serviria como o build environment para a criação de novo stage2 <tt>pentium4</tt>. E o novo stage2 <tt>pentium4</tt> serviria como build environment para a criação do novo stage3 <tt>pentium4</tt>.
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.


Na terminologia [[Metro]] isso é chamado de um '''local build''', que significa que um stage3 de uma dada arquitetura é utilizada para semear (seed) um build novinho da mesma arquitetura. Incidentalmente esse será o primeiro exercício  que vamos realizar nesse tutorial.
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.


Uma semana depois, você pode querer construir um stage34 tarball <tt>pentium4</tt> novo. Ao invés de iniciar a partir do stage3 <tt>pentium4</tt> original novamente, provavelmente você configuraria o [[Metro]] para utilizar o stage3 <tt>pentium4</tt> mais recentemente construído como a seed. [[Metro]] possui funcionalidade built-in para tornar isso fácil, permitindo facilmente encontrar e rastrear a stage3 seed mais recente disponível.
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.


== Build Remoto ==  
== Remote Build ==  


[[Metro]] pode também desempenhar '''remote build''', onde um stage3 de uma arquitetura diferente, mas binariamente compatível, é utilizada como uma seed para construir um stage3 de arquitetura diferente. Consequentemente o segundo exercício que vamos realizar nesse tutorial será construir um stage3 tarball <tt>core2 32bit</tt> a partir do stage3 tarball do <tt>pentium4</tt> que acabamos de construir.
[[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.


TODO: adicione ressalvas a respeito de qual archs podem ser semeadas e qual não pode (talvez uma tabela?)
TODO: add caveats about what archs can be seeded and what can be not (maybe a table?)


== Build Adaptado ==  
== Tailored Build ==  


Por ultimo, de nada também vale a pena que ambos <tt>local</tt> e <tt>remote builds</tt>, [[Metro]] pode ser configurado para adicionar e/ou remover pacotes individuais ao tarball final.
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.
Vamos dizer que você não possa viver sem <tt>app-misc/screen</tt>, no final desse tutorial, nós mostraremos como ter seu stage3 adaptado para incluí-lo.
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.


== Instalando o Metro ==
== Installing Metro ==


'''O método recomendado e que possui suporte''' é utilizar o Git repository do [[Metro]].   
'''The recommended and supported method''' is to use the Git repository of [[Metro]].   


Certifique-se de que o {{Package|dev-vcs/git}} e o {{Package|dev-python/boto}} (opcional; necessário para suporte EC2) estejam instalados no seu sistema:
Ensure that {{Package|dev-vcs/git}} and {{Package|dev-python/boto}} (optional; required for EC2 support) are installed on your system:


<console>
<console>
Line 54: Line 51:
</console>
</console>


Depois, clone o master git repository como a seguir:
Next, clone the master git repository as follows:


<console>
<console>
Line 62: Line 59:
</console>
</console>


Você agora terá um diretório chamado <tt>/root/metro</tt> que contem todo o código fonte do [[Metro]].
You will now have a directory called <tt>/root/metro</tt> that contains all the [[Metro]] source code.


O Metro está agora instalado. É hora de personalizá-lo para seu sistema local.
Metro is now installed. It's time to customize it for your local system.


= Configurando o Metro =
= Configuring Metro =


{{Note|Metro não é atualmente capaz de construir Gentoo stages. Veja {{Bug|FL-901}}.}}
{{Note|Metro is not currently able to build Gentoo stages. See {{Bug|FL-901}}.}}


[[User:Drobbins|Daniel Robbins]] mantem [[Metro]], então ele vem pre-configurado para com sucesso construir releases (lançamentos) do Funtoo Linux. Antes de ler mais adiantes, você pode querer personalizar algumas configurações básicas como o número de serviços atuais para encaixar suas compatibilidades de hardware ou o diretório  se utilizar para produzir arquivos stage. Isso This is realizado ao editar <tt>~/.metro</tt> que é o o arquivo de configuração mestre do [[Metro]].
[[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.


Note que <code>path/install</code> deve apontar para aonde o metro foi instalado. Aponte <code>path/distfiles</code> para aonde seus distfiles residem. Também defina <code>path/mirror/owner</code> e <code>path/mirror/group</code> ao proprietário e grupo de todos os arquivos que serão escritos ao diretório do repositório build, que por padrão (como pelo arquivo de configuração) está em <code>/home/mirror/funtoo</code>. O diretório cache normalmente reside dentro do diretório temp -- Isso pode ser modificado como desejado. O diretório cache pode acabar mantendo muitos pacotes .tbz2 em cache, e consumir um monte do storage. Você pode querer alocar o diretório temp em mais rápidos, para obter tempos de compilação mais rápido, e alocar o diretório cache en storage mais lento, porém mais abundante.
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.


{{file|name=.metro|desc=Metro configuration|body=
{{file|name=.metro|desc=Metro configuration|body=
Line 103: Line 100:
}}
}}


== Arch e Subarch ==
== Arch and Subarch ==


No exemplo a seguir, estamos gerando um stage3 pentium4 compilado para compatibilidade binária x86-32bit. Pentium4 é uma subarch da arquitetura x86-32bit. Uma vez que você tenha metro instalado você pode encontrar uma lista completa de cada subarch em seu diretório <tt>/root/metro/subarch</tt>; cada subarch terá a extensão de arquivo .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:
<console>
<console>
Line 124: Line 121:
</console>
</console>


= Primeiras contruções de stages (local build) =
= First stages build (local build) =


Para começar tudo isso, precisamos inicializar o processo ao baixar uma semente stage3 inicial para utilizar para a construção e alocá-la em seu local apropriado em <tt>/home/mirror/funtoo</tt>, então assim [[Metro]] pode encontrá-la. Também precisaremos criar alguns &quot;controles&quot especiais; arquivos em <tt>/home/mirror/funtoo</tt>, que permitirão ao [[Metro]] entender como ele deve se proceder.
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.


== Primeiro Passo: Definir repositório pentium4 (build local) ==
== Step 1: Set up pentium4 repository (local build) ==


Assumindo que estamos segundo os passos básicos esboçados na seção anterior, e construindo um funtoo instável (<tt>funtoo-current</tt>) construído para o <tt>pentium4</tt>, utilizando um stage3 <tt>pentium4</tt> genérico como uma semente stage, então aqui o primeiro conjunto de passos que desempenharemos:
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:


<console>
<console>
Line 147: Line 144:
</console>
</console>


OK, vamos rever os passos acima. Primeiro, criamos o diretório <tt>/home/mirror/funtoo/funtoo-current/x86-32bit/pentium4</tt>, ao qual é aonde Metro esperará encontrar builds pentium4  instáveis <tt>funtoo-current</tt> -- ele é configurado para procurar aqui por padrão. depois criamos um diretório especialmente nomeado para abrigar nossa semente x86 stage3. De novo, por padrão, Metro espera que o diretório seja nomeado desse jeito. Entramos nesse diretório, e baixamos nossa semente x86 stage3 a partir do funtoo.org. Note que o selo da versão <tt>2010-12-24</tt> corresponde. Certifique-se de que o nome do seu diretório corresponde com o nome do stage3 também. Tudo tem sido configurado para corresponder com o layout de sistema de arquivo padrão do Metro.
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.


Depois, voltamos ao dirtório<tt>/home/mirror/metro/funtoo-current/x86-32bit/pentium4</tt>, e dentro dele, geramos um diretório <tt>.control</tt>. Esse diretório e seus subdiretórios contem arquivos especiais que o Metro refere para determinar certo aspectos de seu comportamento. O arquivo <tt>.control/version/stage3</tt> é utilizado pelo Metro para rastrear o stage3 construído mais recentemente para essa build e subarch particular. Metro automaticamente atualizará esse arquivo com um novo selo de versão depois que ele constrói com sucesso um novo stage3. Mas por rasão que Metro não ''construiu'' na verdade esse stage3, precisamos definir o arquivo <tt>.control/version/stage3</tt> manualmente. Isso permite ao Metro encontrar nosso stage3 baixado quando definimos nosso build pentium4 build a se utilizar como uma seed. Note também que o Metro gerará um arquivo <tt>.control/version/stage1</tt> similar depois que ele construir com sucesso um stage1 funtoo-current para pentium4.
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.


Definimos também os arquivos <tt>.control/strategy/build</tt> e <tt>.control/strategy/seed</tt> com valores de <tt>local</tt> e <tt>stage3</tt> respectivamente. Esses arquivos definem a estratégia de construção que Metro utilizará quando nós construirmos stages funtoo-current para pentium4. Com uma estratégia de construção de <tt>local</tt>, Metro gerará raíz de sia seed stage a partir do funtoo-current pentium4, o diretório atual. E com uma estratégia de seed de <tt>stage3</tt>, Metro utilizará um stage3 como uma seed, e utilizará essa seed para construir um novo stage1, stage2 e stage3.
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.


== Segundo Passo: Construindo os stages para pentium4 ==
== Step 2: Building the pentium4 stages ==


Incidentalmente, se tudo o que você queria fazer nesse ponto era construir um novo stage1/2/3 do funtoo-current para pentium4 (mais o openvz e vserver templates). Você começaria o processo ao digitar:
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>
<console>
Line 162: Line 159:
</console>
</console>


Se tiver uma máquina lenta, isso poderia levar várias horas para ser completada por que vários componentes "pesados" como gcc ou glibc tem que ser compilados em cada stage. Uma vêz que um stage tem sido completado com sucesso, ele é alocado no subdiretório <tt>"${METRO_MIRROR}/funtoo-current/x32-bit/pentium4/YYYY-MM-DD"</tt>, onde <tt>YYYY-MM-DD</tt> é a data de hoje no horário que o script <tt>ezbuild.sh</tt> foi iniciado ou a data que você inseriu na linha de comando ezscript.sh.
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.


= Construir para outra arquitetura compatível binária (remote build) =
= Building for another binary compatible architecture (remote build) =


Como escrito acima, [[Metro]] é capaz de desenvolver '''remote build''' construindo stage3 para arquitetura disferente a partir de uma seeding stage3 binária compatível (ex. utilizando um stage3 para pentium4 para semear um stage3 para <tt>Intel Core2 32bits</tt>).  
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).  


Na terminologia Metro Isso é chamado de uma '''remote build''' (um stage 3 de uma arquitetura diferente, mas binariamente compatível, é utilizada como uma semente).  
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).  
Qual não é compatível? Você não pode utilizar uma arquitetura <tt>Sparc</tt> para gerar um stage baseado em <tt>x86</tt> ou <tt>ARM</tt> e vice-versa. Se você utilizar um stage para 32bit então você não quer semear uma build 64bit a partir dessa. Certifique-se de que você está utilizando um stage a partir da mesma arquitetura que você está tentando semear. Verifique [http://ftp.osuosl.org/pub/funtoo/funtoo-current/ Funtoo-current FTP Mirror] para um stage que é da mesma Arquitetura que você estará construindo.   
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|Com frequência, uma build (ex. funtoo-current) pode ser utilizada como uma seed (semente) para outra build como funtoo-stable. No entanto, hardened builds requerem hardened stages como seeds a fim de que a build finalize com sucesso.}}
{{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.}}


== Primeiro Passo: Definir o repositório Core_2 32bit ==
== Step 1: Set up Core_2 32bit repository ==


Nesse exemplo, vamos utilizar esse stage3 funtoo-current para pentium4 para semear um novo stage3 funtoo-current build para Core_2 32bit. Para conseguir fazer isso, precisamos definir o diretório pentium4 build como a seguir:
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:


<console>
<console>
Line 190: Line 187:
</console>
</console>


Os passos que seguimos são similares aqueles que realizamos para um ''local build'' para definir nosso diretório pentium4 directory para 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. Também não geramos os arquivos <tt>.control/version/stage{1,3}</tt> por que o Metro os gerará para nós depois que ele construir com sucesso um novo stage1 e stage3. Ainda estamos utilizando uma seed strategy <tt>stage3</tt>, mas definimos a build strategy para <tt>remote</tt>, que significa que vamos utilizar uma seed stage que não é desse subdiretório particular. de onde vamos conseguir obtê-lo? O diretório <tt>.control/remote</tt> contem essa informação, e deixa o Metro saber que ele deve procurar seu seed stage3 dentro do diretório <tt>/home/mirror/funtoo/funtoo-current/x86-32bit/pentium4</tt>. Qual ele obterá? Você imaginou isso -- o ''stage3'' mais recente construído (desde nossa seed strategy foi definido <tt>stage3</tt>) que contem a version stamp de <tt>2010-12-24</tt>, como gravado em <tt>/home/mirror/funtoo-current/x86-32bit/pentium4/.control/version/stage</tt>. Agora você oide você como todas esses arquivos de controle se juntam para direcionar o Metro a fazer a coisa correta.
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> deve ser definido para uma das: <code>x86-32bit</code>, <code>x86-64bit</code> ou <code>pure64</code> para sistemas compatíveis com PC. Você deve utilizar uma build de 32-bit como uma seed para outras builds de 32-bit, e uma build de 64-bit como uma seed para outras buidls de 64-bit.}}
{{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.}}


== Segundo Passo: Construir os stages para Core_2 32bit stages ==
== Step 2: Building the Core_2 32bit stages ==


Agora, você poderia começar a construir seunovo stage1/2/3 para Core_2 32bit stage1/2/3 (incluindo openvz e vserver templates) ao digitar o seguinte:
Now, you could start building your new Core_2 32bit stage1/2/3 (plus openvz and vserver templates) by typing the following:


<console>
<console>
Line 202: Line 199:
</console>
</console>


Nesse caso, os stages gerados no subdiretório <tt>/home/mirror/funtoo/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.


== Terceiro Passo: O Próximo Build ==
== Step 3: The Next Build ==


nesse ponto, você tem agora um novo stage3 para Core_2 32bit stage3, construído utilizando um stage3 "remote" para pentium4. Uma vez que o remote build é finalizado com sucesso, Metro automaticamente alterará <code>.control/strategy/build</code> para ser <code>local</code> ao invés de <code>remote</code>, assim ele passará a utilizar o stage3 para Core_32bit construído mais recentemente como um seed para quaisquer builds Core_2 32bit a partir de agora.
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.


= Construa seu próprio stage3 adaptado =
= Build your own tailored stage3 =


Metro pode ser facilmente configurado para construir stages3 personalizado ao incluir pacotes adicionais. Edite o seguinte arquivo de configuração <tt>/root/metro/etc/builds/funtoo-current/build.conf</tt>:
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>:
{{file|name=funtoo-current/build.conf|body=
{{file|name=funtoo-current/build.conf|body=
[collect ../../fslayouts/funtoo/layout.conf]
[collect ../../fslayouts/funtoo/layout.conf]
Line 287: Line 284:
}}
}}


= Construindo stages do Gentoo =
= Building Gentoo stages =


Metro pode também ser construir os stages do Gentoo. Depois de migrar para o profile do Funtoo, veja http://www.funtoo.org/Pt-br/Funtoo_Profiles o Metro requisita passos adicionais para isso. Possuímos um open bug para isso -- isso é simplesmente devido ao fato de que focamos em asegurar que o Funtoo Linux construa e construir Gentoo é prioridade mais baixa. Nota historica: Funtoo Linux originalmente iniciou como um fork do Gentoo Linux, assim o metro podia confiavelmente construir os stages do Gentoo.
Metro can also build Gentoo stages. After switching to Funtoo profile, see http://www.funtoo.org/Funtoo_Profiles metro require additional steps for this. 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.
http://www.funtoo.org/Pt-br/Funtoo_Profiles
http://www.funtoo.org/Funtoo_Profiles


= Recursos Avançados =
= Advanced Features =


Metro também inclui um número de recursos avançados que pode ser utilizados automatizar builds e configurar distributed build servers. Esses recursos exigem que você {{c|emerge sqlalchemy}}, como SQLite é utilizado como uma dependência.
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.


== Gerenciamento de Repositório ==
== Repository Management ==


Metro inclui um script no diretório {{c|scripts}} chamado {{c|buildrepo}}. Buildrepo serve como o coração dos recursos avançados do gerenciamento de repositório do Metro.
Metro includes a script in the {{c|scripts}} directory called {{c|buildrepo}}. Buildrepo serves as the heart of Metro's advanced repository management features.


=== Configuração Inicial ===
=== Initial Setup ===


Para utilizar {{c|buildrepo}}, você primeiro precisará gerar um arquivo de configuração {{f|.buildbot}}. Aqui está o arquivo que eu utilizo no meu AMD Jaguar build server:
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:


{{file|name=/root/.buildbot|lang=python|body=
{{file|name=/root/.buildbot|lang=python|body=
Line 330: Line 327:
}}
}}


Esse arquivo é na verdade um arquivo de código fonte python que define os tuples {{c|builds}}, {{c|arches}} e {{c|subarches}}. Essas variáveis dizem ao {{c|buildrepo}} quais builds, arches e subarches ele deve gerenciar. Uma função {{c|map_build()}} é também definida a qual {{c|buildbot}} utiliza para determinar que tipo de build realizar. Os argumentos passado para a função são baseadas na ultimo build bem sucedido. A função pode ler esses argumentos e retornar uma string para definir o tipo da próxima build. No exemplo acima, a função {{c|map_build()}} causará a próxima build depois de uma build novinha ser uma build completa, e a próxima build depois de uma build completa se tornar uma nova build, assim a build alternará entre full (completa) e nova (freshen).
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.


== Builds Automatizadas ==
== Automated Builds ==


Uma vêz que o arquivo {{c|.buildbot}} tem sido gerado, as ferramentas {{c|buildrepo}} e {{c|buildbot.sh}} estão prontas para uso. Aqui está como elas funcionam. Essas ferramentas são desenvolvidas para manter seu repositório ({{c|path/mirror}} em {{f|/root/.metro}} atualizados ao inspecionar seu repositório e procurar por stages que estão desatualizados.  
Once the {{c|.buildbot}} file has been created, the {{c|buildrepo}} and {{c|buildbot.sh}} tools are ready to use. Here's how they work. These tools are designed to keep your repository ({{c|path/mirror}} in {{f|/root/.metro}} up-to-date by inspecting your repository and looking for stages that are out-of-date.  


Para listar a próxima que serão desenvolvidas, faço isso -- Esse vem do meu ARM build server:
To list the next build that will be performed, do this -- this is from my ARM build server:


{{console|body=
{{console|body=
Line 350: Line 347:
}}
}}


Se nenhuma saída for exibida, então todos as suas builds estão atualizadas.
If no output is displayed, then all your builds are up-to-date.


Para na verdade executar a próxima build, execute {{c|buildbot.sh}}:
To actually run the next build, run {{c|buildbot.sh}}:


{{console|body=
{{console|body=
Line 358: Line 355:
}}
}}


Se você está pensando que {{c|buildbot.sh}} seria uma boa candidata para um cron job, você teve a ideia certa!
If you're thinking that {{c|buildbot.sh}} would be a good candidate for a cron job, you've got the right idea!


=== Listar Builds ===
=== List Builds ===


Para dar uma rápida olhada em nosso repositório, vamos executar o comando {{c|buildrepo fails}}:
To get a quick look at our repository, let's run the {{c|buildrepo fails}} command:


{{console|body=
{{console|body=
Line 374: Line 371:
}}
}}


Em meu AMD Jaguar build server, em 20 de Fevereiro de 2015, Isso lista todos os builds que {{c|buildrepo}} foi configurado para gerenciar. O primeiro número em cada linha é uma '''failcount''', a qual é o numero de números consecutivos que a build falhou. Um valor zero indica que tudo está okay. A failcount é um recurso importante dos recursos avançados de gerenciamento de repositório (advanced repository management features). Aqui estão um número de comportamentos que são implementados baseado na failcount:
On my AMD Jaguar build server, on Feb 20, 2015, this lists all the builds that {{c|buildrepo}} has been configured to manage. The first number on each line is a '''failcount''', which is the number of consecutive times that the build has failed. A zero value indicates that everything's okay. The failcount is an important feature of the advanced repository management features. Here are a number of behaviors that are implemented based on failcount:


* If {{c|buildbot.sh}} tenta construir um stage e a build falha, a failcount é incrementada.
* If {{c|buildbot.sh}} tries to build a stage and the build fails, the failcount is incremented.
* Se a build obtiver êxito para uma build particular, a failcount e redefinida para zero.
* If the build succeeds for a particular build, the failcount is reset to zero.
* Constrói com a failcount mais baixa são priorizadas por {{buildrepo}} para construir a próxima, para orientar as builds que são mais provavelmente completas com sucesso.
* Builds with the lowest failcount are prioritized by {{buildrepo}} to build next, to steer towards builds that are more likely to complete successfully.
* Uma vez que a failcount alcança 3 para uma build particular, ele é removido da build rotation.
* Once the failcount reaches 3 for a particular build, it is removed from the build rotation.


=== Resetting Failcount ===
=== Resetting Failcount ===
Line 392: Line 389:
}}
}}


== Manutenção (Maintenance) do Repositório ==
== Repository Maintenance ==


Uma dupla de ferramentas de manutenção do repositório são fornecidas:
A couple of repository maintenance tools are provided:


* {{c|buildrepo digestgen}} gerará arquivos hash para os arquivos em seu repositório, e limpará os hashes velhos.  
* {{c|buildrepo digestgen}} will generate hash files for the archives in your repository, and clean up stale hashes.  
* {{c|buildrepo index.xml}} gerará um arquivo index.xml no root do seu repositório, listando todos os builds disponíveis.
* {{c|buildrepo index.xml}} will create an index.xml file at the root of your repository, listing all builds available.
* {{c|buildrepo clean}} exibirá a saída shell script que removerá stages antigos. Nada mais que os três stage builds mais recentes para cada build/arch/subarch são mantidos.
* {{c|buildrepo clean}} will output a shell script that will remove old stages. No more than the three most recent stage builds for each build/arch/subarch are kept.


== Repositórios Distribuídos ==
== Distributed Repositories ==


Em muitas situações, você terá um número de build servers, e cada um construirá um sub-conjunto de seu master repository, e depois realizará upload builds para o master repository. Essa é uma área do Metro que está sendo ativamente desenvolvida. Por hora, funcionalidade automatizada de upload não está habilitada, mas é esperada ser implementada em um futuro relativamente próximo. No entanto, é possível ter seu master repository diferenciado entre subarches que são localmente construídos, e assim devem ser parte daquela build rotation {{c|buildbot}} do sistema, e aquelas que são armazenadas localmente e construídas remotamente. Esses builds devem ser limpos quando {{c|buildrepo clean}} for executados, mas não deve entrar na rotação build local (local build rotation). Para configurar isso, modifique {{f|/root/.buildbot}} e utilize as variáveis {{c|subarches}} e {{c|all_subarches}}:
In many situation, you will have a number of build servers, and each will build a subset of your master repository, and then upload builds to the master repository. This is an area of Metro that is being actively developed. For now, automated upload functionality is not enabled, but is expected to be implemented in the relatively near future. However, it is possible to have your master repository differentiate between subarches that are built locally, and thus should be part of that system's {{c|buildbot}} build rotation, and those that are stored locally and built remotely. These builds should be cleaned when {{c|buildrepo clean}} is run, but should not enter the local build rotation. To set this up, modify {{f|/root/.buildbot}} and use the {{c|subarches}} and {{c|all_subarches}} variables:


{{file|name=/root/.metro|desc=Excerpt of .metro config for master repository|body=
{{file|name=/root/.metro|desc=Excerpt of .metro config for master repository|body=
Line 450: Line 447:
[[Category:HOWTO]]
[[Category:HOWTO]]
[[Category:Metro]]
[[Category:Metro]]
[[Category:pt_BR]]
__TOC__
__TOC__

Revision as of 17:30, July 12, 2015

Other languages:
English • ‎Türkçe • ‎português do Brasil • ‎日本語

{{#layout:doc}}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.

Other Metro Documentation is available.

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 dev-vcs/git and No results (optional; required for EC2 support) 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 # 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:

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 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 /home/mirror/funtoo/funtoo-current/x86-32bit/pentium4
root # install -d /home/mirror/funtoo/funtoo-current/snapshots
root # cd /home/metro/mirror/funtoo/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 /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:

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.

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 /home/mirror/funtoo/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, 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

Metro can also build Gentoo stages. After switching to Funtoo profile, see http://www.funtoo.org/Funtoo_Profiles metro require additional steps for this. 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. http://www.funtoo.org/Funtoo_Profiles

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.

Automated Builds

Once the .buildbot file has been created, the buildrepo and buildbot.sh tools are ready to use. Here's how they work. These tools are designed to keep your repository (path/mirror in /root/.metro up-to-date by inspecting your repository and looking for stages that are out-of-date.

To list the next build that will be performed, do this -- this is from my ARM build server:

root # ./buildrepo nextbuild
build=funtoo-current
arch_desc=arm-32bit
subarch=armv7a_hardfp
fulldate=2015-02-08
nextdate=2015-02-20
failcount=0
target=full
extras=''

If no output is displayed, then all your builds are up-to-date.

To actually run the next build, run buildbot.sh:

root # ./buildbot.sh

If you're thinking that buildbot.sh would be a good candidate for a cron job, you've got the right idea!

List Builds

To get a quick look at our repository, let's run the buildrepo fails command:

root # ./buildrepo fails
   0   2015-02-18 /home/mirror/funtoo/funtoo-current/x86-64bit/amd64-jaguar
   0   2015-02-18 /home/mirror/funtoo/funtoo-current/pure64/amd64-jaguar-pure64
   0   2015-02-18 /home/mirror/funtoo/funtoo-current-hardened/x86-64bit/amd64-jaguar
   0   2015-02-18 /home/mirror/funtoo/funtoo-current-hardened/pure64/amd64-jaguar-pure64
   0   2015-02-18 /home/mirror/funtoo/funtoo-stable/x86-64bit/amd64-jaguar
   0   2015-02-18 /home/mirror/funtoo/funtoo-stable/pure64/amd64-jaguar-pure64

On my AMD Jaguar build server, on Feb 20, 2015, this lists all the builds that buildrepo has been configured to manage. The first number on each line is a failcount, which is the number of consecutive times that the build has failed. A zero value indicates that everything's okay. The failcount is an important feature of the advanced repository management features. Here are a number of behaviors that are implemented based on failcount:

  • If buildbot.sh tries to build a stage and the build fails, the failcount is incremented.
  • If the build succeeds for a particular build, the failcount is reset to zero.
  • Builds with the lowest failcount are prioritized by Template:Buildrepo to build next, to steer towards builds that are more likely to complete successfully.
  • Once the failcount reaches 3 for a particular build, it is removed from the build rotation.

Resetting Failcount

If a build has issues, the failcount for a build will reach 3, at which point it will be pulled out of build rotation. To clear failcount, so that these builds are attempted again -- possibly fixed by new updates to the Portage tree -- use buildrepo zap:

root # /root/metro/scripts/buildrepo zap
Removing /mnt/data/funtoo/funtoo-current/arm-32bit/armv7a_hardfp/.control/.failcount...
Removing /mnt/data/funtoo/funtoo-current/arm-32bit/armv6j_hardfp/.control/.failcount...
Removing /mnt/data/funtoo/funtoo-current/arm-32bit/armv5te/.control/.failcount...

Repository Maintenance

A couple of repository maintenance tools are provided:

  • buildrepo digestgen will generate hash files for the archives in your repository, and clean up stale hashes.
  • buildrepo index.xml will create an index.xml file at the root of your repository, listing all builds available.
  • buildrepo clean will output a shell script that will remove old stages. No more than the three most recent stage builds for each build/arch/subarch are kept.

Distributed Repositories

In many situation, you will have a number of build servers, and each will build a subset of your master repository, and then upload builds to the master repository. This is an area of Metro that is being actively developed. For now, automated upload functionality is not enabled, but is expected to be implemented in the relatively near future. However, it is possible to have your master repository differentiate between subarches that are built locally, and thus should be part of that system's buildbot build rotation, and those that are stored locally and built remotely. These builds should be cleaned when buildrepo clean is run, but should not enter the local build rotation. To set this up, modify /root/.buildbot and use the subarches and all_subarches variables:

   /root/.metro - Excerpt of .metro config for master repository
# subarches we are building locally:

subarches = ( 
        "pentium4",
        "athlon-xp",
        "corei7",
        "corei7-pure64",
        "generic_32", 
        "i686", 
        "amd64-k8",
        "amd64-k8-pure64",
        "core2_64",
        "core2_64-pure64",
        "generic_64",
        "generic_64-pure64",
) 
  
# Things we need to clean, even if we may not be building:
  
all_subarches = subarches + (
        "atom_32",
        "atom_64",
        "atom_64-pure64",
        "amd64-k10",
        "amd64-k10-pure64",
        "amd64-bulldozer",
        "amd64-bulldozer-pure64",
        "amd64-steamroller",
        "amd64-steamroller-pure64",
        "amd64-piledriver",
        "amd64-piledriver-pure64",
        "amd64-jaguar",
        "amd64-jaguar-pure64",
        "intel64-haswell",
        "intel64-haswell-pure64",
        "intel64-ivybridge-pure64",
        "intel64-ivybridge",
        "armv7a_hardfp",
        "armv6j_hardfp",
        "armv5te"
)