Difference between pages "Making the Distribution, Part 1" and "Metro Quick Start Tutorial/pt-br"

(Difference between pages)
 
(Configuring Metro)
 
Line 1: Line 1:
{{Article
+
= Prefácio =
|Summary=Each of us has a story to tell about our experiences with Linux. This is Daniel Robbins' Linux story. In this first of three articles, he talks about how he became a Stampede Linux developer, and why he eventually left Stampede to start his own distribution called Enoch.
+
 
|Article Category=General
+
== Como o Metro Funciona ==
|Author=Drobbins
+
 
 +
Você pode estar se perguntando como o [[Metro]] cria seu primeiro stage tarball. Como você pode ter imaginado, [[Metro]] não pode criar um stage tarball. Para construi um novo stage tarball, [[Metro]] deve utilizar um já existente, antigo stage tarball chamado de uma "seed" stage. Essa semente "semente" stage tipicamente é utilizado com o ''ambiente build'' para a criação do stage que queremos.
 +
 
 +
[[Metro]] pode utilizar dois tipos de semente stages. Tradicionalmente, [[Metro]] tem utilizado um stage3 como uma semente stage. Esse stage3 é então utilizado para construir um novo stage1, que em troca é utlilizado para construir um novo stage2, e então um novo stage3. Esse é geralmente o jeito mais confiável de construir [[Gentoo Linux]] ou [[Funtoo Linux]], entao essa é a recomendação recomendada.
 +
{{fancyimportant|'''Depois de portar o metro builds para o perfil do Funtoo, os stages do Gentoo não são mais fornecidos'''!}}
 +
 
 +
== Sementes e Build Isolation ==
 +
 
 +
Um outro conceito importante a mencionar aqui é algo chamando de ''build isolation''. Por que o [[Metro]] cria um ambiente build isolado, e o ambiente build é explicitamente definido utilizando entidades existentes, tangíveis -- uma semente stage e um portage snapshot -- você obterá resultados consistentes, repetíveis. Em outras palavras, a mesma semente stage, portage snapshot e instrções build gerarão resultados identico, mesmo se você desempenhar o um mês mais tarde em algum workstation de outro pessoa.
 +
 
 +
== Local Build ==
 +
 
 +
Digamos que você queira construir um novo tarball stage3 <tt>pentium4</tt>. O módo recomendado de se fazer isso seria apanhar um tarball stage3 <tt>pentium4</tt> existente como sua semente stage3 stage. Será dito ao [[Metro]] utilizar o stage3 <tt>pentium4</tt> existente para construir um novo stage1 para o mesmo <tt>pentium4</tt>. Para esse process, o stage3 para o <tt>pentium4</tt> genérico forneceria o ''ambiente build'' para a criação de nosso novo stage1. Então, o novo stage1 serviria como o ambiente build (build environment) para a criação do novo stage2 <tt>pentium4</tt>. E o novo stage2 para <tt>pentium4</tt> serviria como o ambiente build para a criação do novo stage3 para <tt>pentium4</tt>.
 +
 
 +
Na terminologia [[Metro]] isso é chamado de um '''local build''', que significa que um stage3 de uma dada arquitetura é utilizada para semear um build novo em folha da mesma arquitetura. Incidentalmente esse será o primeiro exercício que vamos realizar nesse tutorial.
 +
 
 +
Uma semana depois, você pode querer construir um tarball stage3 para <tt>pentium4</tt> novo em folha. Ao invés de iniciar a partir do stage3 para <tt>pentium4</tt> original de novo, você provavelmente configuraria o [[Metro]] para utilizar o built stage3 para <tt>pentium4</tt> mais recente construído como a semente. [[Metro]] possui funcionalidade built-in para tornar isso fácil, permitindo facilmente encontrar e rastrear a semente stage3 mais recente disponível.
 +
 
 +
== Build Remoto ==
 +
 
 +
[[Metro]] pode também desempenhar '''build remoto (remote build)''', onde um stage3 de uma arquitetura diferente, mas compatível binariamente, é utilizado como uma semente para construir um stage3 de arquitetura diferente. Consequencialidade, no segundo exercício que vamos realizar nesse tutorial será construir um tarball stage3 para <tt>core2 32bit</tt> a partir do tarball stage3 do <tt>pentium4</tt> que acabamos de construir.
 +
 
 +
TODO: adicione  ressalvas a respeito de quais arquiteturas podem ser semeadas e quais não podem (talvez um table?)
 +
 
 +
== Build Adaptado ==
 +
 
 +
Por ultimo, também é válido tanto <tt>local</tt> e <tt>builds remotos</tt>, [[Metro]] pode ser configurado para adicionar e/ou remover pacotes individuais ao ultimo tarball.
 +
Digamos que você não consiga viver sem <tt>app-misc/screen</tt>, no final desse tutorial, mostraremos como obter o seu stage3 adaptado para incluí-lo.
 +
 
 +
== Instalar o Metro ==
 +
 
 +
'''O método recomendado e que possui suporte''' é utilizar o repositório Git do [[Metro]]. 
 +
 
 +
Asegure-se de que {{Package|dev-vcs/git}} e {{Package|dev-python/boto}} (opcional; exigido para suporte EC2) sejam estalados no seu sistema:
 +
 
 +
<console>
 +
# ##i##emerge dev-vcs/git
 +
# ##i##emerge dev-python/boto
 +
</console>
 +
 
 +
Depois, clone o master git repository como a seguir:
 +
 
 +
<console>
 +
# ##i##cd /root
 +
# ##i##git clone git://github.com/funtoo/metro.git
 +
# ##i##cp /root/metro/metro.conf ~/.metro
 +
</console>
 +
 
 +
Agora você terá o diretório chamado <tt>/root/metro</tt> que contem todo o código fonte do [[Metro]].
 +
 
 +
O Metro agora está instalado. É hora de personalizá-lo para o seu sistema local.
 +
 
 +
= Configuring Metro =
 +
 
 +
{{Note|Metro não é atualmente capaz de construir stages do Gentoo. Veja {{Bug|FL-901}}.}}
 +
 
 +
[[User:Drobbins|Daniel Robbins]] mantem o  [[Metro]], então ele vem pré-configurado para construir com sucesso os lançamentos do [[Funtoo Linux]]. Antes de ler mais adiante, você pode querer personalizar algumas configurações básicas como o o número de de jobs simultâneos para se encaixar as compatibilidades do seu hardware ou o diretório para utilizar arquivos stage produzidos. Isso é excelente ao editar <tt>~/.metro</tt> a qual é o arquivo de configuração [[Metro]]'s master.
 +
 
 +
Por favor, note que o <code>path/install</code> deve apontar para aonde o metro foi instalado. Aponte <code>path/distfiles</code> para aonde seus distfiles residem. Defina também  <code>path/mirror/owner</code> e <code>path/mirror/group</code> para o proprietário e grupo de todos os arquivos que serão escritos para construir o diretório do repositório, que por padrão (como por arquivo de configuração) está em <code>/home/mirror/funtoo</code>. O diretório cache normalmente reside dentro do diretório temporário -- Isso pode ser modificado como desejado. O diretório cache pode terminar contendo muitos pacotes .tbz2 em cache, e comer um monte de armazenamento (storage). Você pode de repente querer colocar o diretório temporário em armazenamento mais rápido, para tempos de compilação mais rápidas, e colocar o diretório cache em armazenamento mais lento, porém mais abundante.
 +
 
 +
{{file|name=.metro|desc=Metro configuration|body=
 +
# 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]
 
}}
 
}}
==  Birth of the Gentoo Linux distribution ==
 
  
=== Linux and me ===
+
== Arch e Subarch ==
  
For every Linux geek there's a time when Linux becomes more than just a name and reveals itself as something more wonderful, powerful, and intriguing than anything a developer has ever encountered. My revelation came while I was working at the University of New Mexico as a sysadmin. Our NT server was running pretty well and I had some extra time on my hands. So I got Debian set up on a Pentium 166 server box and started learning ... and learning and learning and learning. And then I was hooked.
+
No exemplo seguinte estamos gerando um stage 3 para pentium4 compilado para a compatibilidade binária x86-32bit. Pentium4 é uma subarch da arquitetura x86-32bit. Uma vez que você tenha o metro instalado, você pode encontrar uma lista completa de cada subarch em seu diretório <tt>/root/metro/subarch</tt>; cada  arquitetura terá a extensão de arquivo .spec
 +
Example:
 +
<console>
 +
###i## ls /root/metro/subarch
 +
# ls subarch/
 +
amd64-bulldozer-pure64.spec  armv7a.spec          core-avx-i.spec        i686.spec        pentium.spec
 +
amd64-bulldozer.spec        armv7a_hardfp.spec  core2_32.spec          k6-2.spec        pentium2.spec
 +
amd64-k10-pure64.spec        athlon-4.spec        core2_64-pure64.spec    k6-3.spec        pentium3.spec
 +
amd64-k10.spec              athlon-mp.spec      core2_64.spec          k6.spec          pentium4.spec
 +
amd64-k8+sse3.spec          athlon-tbird.spec    corei7-pure64.spec      native_32.spec    pentiumpro.spec
 +
amd64-k8+sse3_32.spec        athlon-xp.spec      corei7.spec            native_64.spec    prescott.spec
 +
amd64-k8-pure64.spec        athlon.spec          generic_32.spec        niagara.spec      ultrasparc.spec
 +
amd64-k8.spec                atom_32.spec        generic_64-pure64.spec  niagara2.spec    ultrasparc3.spec
 +
amd64-k8_32.spec            atom_64-pure64.spec  generic_64.spec        nocona.spec      xen-pentium4+sse3.spec
 +
armv5te.spec                atom_64.spec        generic_sparcv9.spec    opteron_64.spec  xen-pentium4+sse3_64.spec
 +
armv6j.spec                  btver1.spec          geode.spec              pentium-m.spec
 +
armv6j_hardfp.spec          btver1_64.spec      i486.spec              pentium-mmx.spec
 +
</console>
  
First I learned the basic ins and outs of Linux: how to get around, perform backups, get Samba running, etc. Then I set up qmail and Apache and learned python and shell programming. I built a departmental Intranet. I got Linux installed at home and began trying different distributions. Finally I settled with Stampede Linux. You know how the progression goes: first you struggle with grasping Linux basics; then, when you have a decent grip, you customize your Linux, learning as you go. Because Linux has nothing to hide, you can explore the technology and tools that make it tick while you grow in Linux fluency.
+
= First stages build (local build) =
  
=== Linux is about potential  ===
+
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.
  
Linux offered something I had never seen before. If I had to put that magical something into words, I'd call it potential: the potential to change, to improve, to fix things, and yes, even to break things. As I upgraded to new kernel versions I saw Linux improve before my eyes and transform itself almost daily. And I was along for the ride! I was a part of the transformation. It was fun.
+
== Step 1: Set up pentium4 repository (local build) ==
  
If you're anything like me, before you were exposed to Linux and open source you looked to those big companies in Redmond and Cupertino to provide a next-generation operating system that finally worked exactly the way you wanted it to. But alas, that dream never became reality. And while we were waiting, Linux came along. And although it had a lot of rough edges, it provided something for us hacker guys and gals that we could improve upon while we waited for the next big thing. Then one day we awoke to find that Linux had become the next big thing. And smiling all the while, we continued to hack away.
+
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:
  
=== Linux is about people ===
+
<console>
 +
# ##i##install -d /home/mirror/funtoo/funtoo-current/x86-32bit/pentium4
 +
# ##i##install -d /home/mirror/funtoo/funtoo-current/snapshots
 +
# ##i##cd /home/metro/mirror/funtoo/funtoo-current/x86-32bit/pentium4
 +
# ##i##install -d 2011-12-13
 +
# ##i##cd 2011-12-13
 +
# ##i##wget -c http://ftp.osuosl.org/pub/funtoo/funtoo-current/x86-32bit/pentium4/2011-12-13/stage3-pentium4-funtoo-current-2011-12-13.tar.xz
 +
# ##i##cd ..
 +
# ##i##install -d .control/version
 +
# ##i##echo "2011-12-13" > .control/version/stage3
 +
# ##i##install -d .control/strategy
 +
# ##i##echo local >  .control/strategy/build
 +
# ##i##echo stage3 > .control/strategy/seed
 +
</console>
  
The next thing I learned was that Linux is about people. Isn't that refreshing? Linux isn't just a bunch of source code. It's a community. We rely on this community to get our questions answered, and we become part of the community when we start helping others by contributing our time and expertise.
+
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.
  
IRC (Internet relay chat) is a great place to meet people and waste a tremendous amount of time. The #stampede channel on irc.openprojects.net became my official hangout. That's where I'd ask my Linux questions. It's also where I first began to help other people out. #stampede desperately needed experienced Linux users to help out newbies who had just gotten the distribution installed. As is common on IRC, many of the experienced Stampede people had lost their zeal for answering (yet another) newbie question. But I was so excited that I actually knew the answer to newbies' questions, that I couldn't resist helping out! And that's how my involvement with Stampede began. I was just another guy who liked to answer questions. Of course, it wasn't entirely altruistic, because I also helped myself to expert Linux knowledge that the more experienced people on the channel (not to mention the Stampede developers themselves!) had to offer.
+
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.
  
=== Getting involved ===
+
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.
  
When people ask me how to get involved in an open source project, I tell them to find a place where they can be helpful, even if it's just by helping with basic Linux questions. A sincere desire to help others is a great ticket into the Linux community because this sentiment is at the heart of all open source development (including Linux). At least, it should be.
+
== Step 2: Building the pentium4 stages ==
  
Along the way you'll inevitably run into people who know more than you. And you'll learn from them just as newbies continue to learn from you. It's also likely that as you gain more experience you'll come across opportunities to help in new ways. Maybe some of the project developers you come across will suggest something, or they'll ask for help themselves. They may even invite you to become part of the development team. If you're focused on helping others, they'd be foolish to pass you by. If you're helping a lot of people out, you will definitely be noticed in the community. That's sort of how it happened with Stampede and me.
+
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:
  
Gradually I became more and more involved in Stampede development. Before long, I was an official Stampede developer. With the blessing of skibum (Matt Wood, Stampede's head honcho), I began working on a new version of Stampede's primitive .slp packaging format. At the time the .slp package format consisted of a .tar.bz2 archive with a fixed-length footer stuck on the end that contained information about the package author, a description of the contents, the package creator, etc. This approach had two major problems: the fields were a fixed length and the footer really wasn't that big, and there was no extensibility built into the format (there was no way to add any additional fields to the .slp format in the future). Obviously this thing needed a major overhaul.
+
<console>
 +
# ##i##cd /root/metro
 +
# ##i##scripts/ezbuild.sh funtoo-current pentium4
 +
</console>
  
Working with the senior Stampede developers, I wrote up a proposal of how to deal with the problem. Then I started coding the prototype tools in Python. The new format (codenamed slpv6) was somewhat similar to the IFF file format from the Amiga world. This next-generation .slp format allowed for 2 32 fields, 2 32 categories of fields, and a maximum field data length of 2 32 bytes. Not only was the format very extensible, it was also more compact than plain-text and easy to parse. Both text and binary data could be stored in the format, which allowed for a lot of possibilities for the future. The idea was to stick this next-generation dynamic header on the end of the archive file, thereby producing a next-generation .slp format that would serve Stampede users for years to come and at the same time maintain compatibility with standard UNIX archive formats.
+
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.
  
=== People can get ugly ===
+
= Building for another binary compatible architecture (remote build) =
  
slpv6 development was going well and all the senior developers were happy with my progress. But unfortunately, two lower-level Stampede developers wanted to control the slpv6 project. They didn't like the direction I was taking, and they spent most of their time insulting the new slpv6 system. Though I spent hours in heated development discussions defending the proposal against their attacks, we weren't able to resolve anything. Eventually it became clear that they were just naturally argumentative and wouldn't be happy until they had their way. Fortunately for me, my project had the approval of the senior Stampede developers. But these discussions began to wear on me and made Stampede development very unpleasant. Ugh!
+
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).  
  
I couldn't avoid these guys since I had to hang out on #stampede to chat with higher-level developers. And every time I was on the channel they became combative, trying to undermine my work. They'd use devious techniques like calling for development meetings (really just an opportunity to insult my work in front of the senior developers). They'd also try to call for votes, attempting to seize control of Stampede. Of course they'd only call for a vote when they thought they had convinced enough people to agree with them. Throughout all of this I continued my slpv6 development. Needless to say, the senior development loved my work and wanted me to continue (without their support I wouldn't have been able to stick it out).
+
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. 
  
=== Understanding the freak ===
+
{{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.}}
  
These two guys belong to a category of developer I like to call "the freak". But although they made my development work very unpleasant, I also learned a lot from having to deal with them. At this point I'd like to offer you an expos?f the freak developers, a sort of comprehensive overview: the qualities that make a freak, the freak's modus operandi, and how you, the development project leader, can confront and possibly reform the freak without exerting a lot of effort.
+
== Step 1: Set up Core_2 32bit repository ==
  
In order to avoid emotional damage, you'll need one prerequisite: a backbone. If you're unable to confront the freak in a respectful but firm manner, there's no hope. The freak's goal is to control as much of your project as possible so that he or she will feel powerful. The freak will use several techniques to make this happen. First they'll start unfairly criticizing or bitterly complaining about a project and/or the developers working on a project. Then they will refrain from offering any constructive solutions. They will also not be willing to help with the project in any other way unless they are promoted to the role of project manager. Their goal is to convince you to give them as much authority as possible so that they can solve problems that only they, with their finely trained freak eyes, can see.
+
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:
  
If the criticism and complaining aren't effective, they'll request a developer meeting. This will be their opportunity to try and divide your development team into two factions. When they think that they've gotten enough people on their side, they'll request a vote (knowing they will win). If they don't win the vote or they are overruled, they'll push for another developer meeting next week in which they'll again try to divide your development team. They'll repeat this process endlessly.
+
<console>
 +
# ##i## cd /home/mirror/funtoo/funtoo-current/x86-32bit
 +
# ##i##install -d core2_32
 +
# ##i##cd core2_32
 +
# ##i##install -d .control/strategy
 +
# ##i##echo remote > .control/strategy/build
 +
# ##i##echo stage3 > .control/strategy/seed
 +
# ##i##install -d .control/remote
 +
# ##i##echo funtoo-current > .control/remote/build
 +
# ##i##echo x86-32bit > .control/remote/arch_desc
 +
# ##i##echo pentium4 > .control/remote/subarch
 +
</console>
  
If the developer meeting approach doesn't work, freaks will become reformers. By adopting this role they will try to streamline (read: undermine) the oppressive and unfair executive decision-making process by attempting to replace it with something more democratic (read: easily manipulated.) This will often involve convincing you that you should do whatever the majority of your developers want. Freaks love this because then you can't override those developer meeting votes anymore (muhahaha!). If you allow this to happen, you've basically given the freak the keys to your Lexus. You're powerless.
+
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.
  
In another approach, freaks will irritate and drive away your productive developers. Then they'll work your entire team into a frenzy as they forcefully try to reform the project's power structure. If their efforts are finally defeated, they'll try to rally as many defectors together as possible and fork from your project. Ouch!
+
{{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.}}
  
=== Managing the freak ===
+
== Step 2: Building the Core_2 32bit stages ==
  
You can identify these guys pretty easily. They're the ones who aren't writing any code (nor do they have any intention to). Instead they spend their time talking about more important things. You know, those managerial issues. If you're a project leader, it's pretty easy to deal with them. Just tell them that you won't consider any proposal unless they produce working code. Or insist that they constructively help the current project, which includes obeying the current project manager, before giving them the opportunity to offer any (constructive) criticism. If they write some nice code or start being more helpful, great. If not, tell them to go away. They'll either leave the project (if you ignore them long enough), or they'll get their act together and start writing some code and generally become more pleasant.
+
Now, you could start building your new Core_2 32bit stage1/2/3 (plus openvz and vserver templates) by typing the following:
  
Unfortunately the senior Stampede developers didn't take on freak management. In other words, they allowed these two guys to pester me (and others) to no end. While the senior developers were always in favor of my development work, they didn't do much to get these guys under control. So one day I decided that it would be easier to create my own distribution rather than have to put up with the two freaks. I resigned from Stampede development and started making plans to produce my own distro.
+
<console>
 +
# ##i##/root/metro/scripts/ezbuild.sh funtoo-current core2_32
 +
</console>
  
While I felt a bit weird about leaving a project because of two lower-level developers, the fact that they weren't dealt with really indicated that the project had severe managerial problems. If the higher-level developers weren't able or willing to make sure the Stampede development effort was pleasant and rewarding, then I didn't want to be there.
+
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.
  
=== Starting afresh ===
+
== Step 3: The Next Build ==
  
Once I left I breathed a big sigh of relief. Wow! Finally, things were calm and quiet. Now it was time to define what my distribution would be about and what it would contribute to the Linux distribution scene. One of the things that attracted me to Stampede was its raw performance (thanks to its use of the experimental Pentium-optimized pgcc compiler). So I decided to focus first on performance. In addition to minimizing CPU utilization, I also wanted to minimize bloat. Too many distributions (especially those popular shrink-wrapped ones) enable so many daemons by default that you barely have any RAM left after opening an xterm. I wanted my distribution to be lean and mean, and focused on maximizing the performance of the hardware that it ran on. I decided to take a holistic approach and tackle the performance problem from all angles.
+
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.
  
But I had a serious lack of resources, since I was the only developer for my distribution! How could I possibly create something that was comparable to Caldera or RedHat off the ground on my own? The answer was automation. I had to write scripts to automate everything, so that I would have a minimal amount of time-consuming, repetitive labor. After all, that's what computers do best, right?
+
= Build your own tailored stage3 =
  
I quickly saw that writing simple scripts for the kind of automation I needed wasn't going to be enough. I needed to design a complete system for generating a Linux distribution from scratch. I tentatively called it the ebuild system and got to work. The ebuild system would be able to automatically create all the distribution binaries, automating everything from unpacking and patching the sources to compilation, installation and packaging. After getting a basic ebuild prototype working, I started creating ebuild scripts for the key components of a Linux distribution (like gcc, glibc, binutils, util-linux, and friends). My Stampede development box was gradually turning into my own system, as I redesigned the initialization scripts (basing them on the Stampede initialization scripts that I had previously designed) and testing and installing every new package that I created.
+
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=
 +
[collect ../../fslayouts/funtoo/layout.conf]
  
A few months later I had a complete, self-hosted Linux distribution. I named it Enoch and sat back and smiled contentedly. But what became of Enoch, and how did Gentoo Linux evolve? Join me in my next article as I tell the story of how Enoch became Gentoo Linux, and the many new challenges I faced along the way.
+
[section release]
  
=== Resources ===
+
author: Daniel Robbins <drobbins@funtoo.org>
  
* Continue reading my story with "Making the distribution, Part 2 and Part 3".
+
[section target]
* Learn more about the Gentoo Linux ebuild system in Daniel's article, [[Bash by Example, Part 3]].
+
  
{{ArticleFooter}}
+
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]]
 +
}}

Revision as of 11:25, January 15, 2015

Prefácio

Como o Metro Funciona

Você pode estar se perguntando como o Metro cria seu primeiro stage tarball. Como você pode ter imaginado, Metro não pode criar um stage tarball. Para construi um novo stage tarball, Metro deve utilizar um já existente, antigo stage tarball chamado de uma "seed" stage. Essa semente "semente" stage tipicamente é utilizado com o ambiente build para a criação do stage que queremos.

Metro pode utilizar dois tipos de semente stages. Tradicionalmente, Metro tem utilizado um stage3 como uma semente stage. Esse stage3 é então utilizado para construir um novo stage1, que em troca é utlilizado para construir um novo stage2, e então um novo stage3. Esse é geralmente o jeito mais confiável de construir Gentoo Linux ou Funtoo Linux, entao essa é a recomendação recomendada.

Important

Depois de portar o metro builds para o perfil do Funtoo, os stages do Gentoo não são mais fornecidos!

Sementes e Build Isolation

Um outro conceito importante a mencionar aqui é algo chamando de build isolation. Por que o Metro cria um ambiente build isolado, e o ambiente build é explicitamente definido utilizando entidades existentes, tangíveis -- uma semente stage e um portage snapshot -- você obterá resultados consistentes, repetíveis. Em outras palavras, a mesma semente stage, portage snapshot e instrções build gerarão resultados identico, mesmo se você desempenhar o um mês mais tarde em algum workstation de outro pessoa.

Local Build

Digamos que você queira construir um novo tarball stage3 pentium4. O módo recomendado de se fazer isso seria apanhar um tarball stage3 pentium4 existente como sua semente stage3 stage. Será dito ao Metro utilizar o stage3 pentium4 existente para construir um novo stage1 para o mesmo pentium4. Para esse process, o stage3 para o pentium4 genérico forneceria o ambiente build para a criação de nosso novo stage1. Então, o novo stage1 serviria como o ambiente build (build environment) para a criação do novo stage2 pentium4. E o novo stage2 para pentium4 serviria como o ambiente build para a criação do novo stage3 para pentium4.

Na terminologia Metro isso é chamado de um local build, que significa que um stage3 de uma dada arquitetura é utilizada para semear um build novo em folha da mesma arquitetura. Incidentalmente esse será o primeiro exercício que vamos realizar nesse tutorial.

Uma semana depois, você pode querer construir um tarball stage3 para pentium4 novo em folha. Ao invés de iniciar a partir do stage3 para pentium4 original de novo, você provavelmente configuraria o Metro para utilizar o built stage3 para pentium4 mais recente construído como a semente. Metro possui funcionalidade built-in para tornar isso fácil, permitindo facilmente encontrar e rastrear a semente stage3 mais recente disponível.

Build Remoto

Metro pode também desempenhar build remoto (remote build), onde um stage3 de uma arquitetura diferente, mas compatível binariamente, é utilizado como uma semente para construir um stage3 de arquitetura diferente. Consequencialidade, no segundo exercício que vamos realizar nesse tutorial será construir um tarball stage3 para core2 32bit a partir do tarball stage3 do pentium4 que acabamos de construir.

TODO: adicione ressalvas a respeito de quais arquiteturas podem ser semeadas e quais não podem (talvez um table?)

Build Adaptado

Por ultimo, também é válido tanto local e builds remotos, Metro pode ser configurado para adicionar e/ou remover pacotes individuais ao ultimo tarball. Digamos que você não consiga viver sem app-misc/screen, no final desse tutorial, mostraremos como obter o seu stage3 adaptado para incluí-lo.

Instalar o Metro

O método recomendado e que possui suporte é utilizar o repositório Git do Metro.

Asegure-se de que Git e dev-python/boto (package not on wiki - please add) (opcional; exigido para suporte EC2) sejam estalados no seu sistema:

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

Depois, clone o master git repository como a seguir:

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

Agora você terá o diretório chamado /root/metro que contem todo o código fonte do Metro.

O Metro agora está instalado. É hora de personalizá-lo para o seu sistema local.

Configuring Metro

Note

Metro não é atualmente capaz de construir stages do Gentoo. Veja FL-901.

Daniel Robbins mantem o Metro, então ele vem pré-configurado para construir com sucesso os lançamentos do Funtoo Linux. Antes de ler mais adiante, você pode querer personalizar algumas configurações básicas como o o número de de jobs simultâneos para se encaixar as compatibilidades do seu hardware ou o diretório para utilizar arquivos stage produzidos. Isso é excelente ao editar ~/.metro a qual é o arquivo de configuração Metro's master.

Por favor, note que o path/install deve apontar para aonde o metro foi instalado. Aponte path/distfiles para aonde seus distfiles residem. Defina também path/mirror/owner e path/mirror/group para o proprietário e grupo de todos os arquivos que serão escritos para construir o diretório do repositório, que por padrão (como por arquivo de configuração) está em /home/mirror/funtoo. O diretório cache normalmente reside dentro do diretório temporário -- Isso pode ser modificado como desejado. O diretório cache pode terminar contendo muitos pacotes .tbz2 em cache, e comer um monte de armazenamento (storage). Você pode de repente querer colocar o diretório temporário em armazenamento mais rápido, para tempos de compilação mais rápidas, e colocar o diretório cache em armazenamento mais lento, porém mais abundante.

.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 e Subarch

No exemplo seguinte estamos gerando um stage 3 para pentium4 compilado para a compatibilidade binária x86-32bit. Pentium4 é uma subarch da arquitetura x86-32bit. Uma vez que você tenha o metro instalado, você pode encontrar uma lista completa de cada subarch em seu diretório /root/metro/subarch; cada arquitetura terá a extensão de arquivo .spec Example:

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

First stages build (local build)

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

Step 1: Set up pentium4 repository (local build)

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

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

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

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

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

Step 2: Building the pentium4 stages

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

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

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

Building for another binary compatible architecture (remote build)

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

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

Note

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

Step 1: Set up Core_2 32bit repository

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

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

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

Note

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

Step 2: Building the Core_2 32bit stages

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

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

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

Step 3: The Next Build

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

Build your own tailored stage3

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

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

[section release]

author: Daniel Robbins <drobbins@funtoo.org>

[section target]

compression: xz

[section portage]

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

[section profile]

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

[section version]

python: 2.7

[section emerge]


[section snapshot]

type: live
compression: xz

[section snapshot/source]

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

[section metro]

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

[section baselayout]

services: sshd

[section multi]

snapshot: snapshot

[section files]

motd/trailer: [

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

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

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