Difference between pages "Funtoo Linux First Steps" and "Metro Quick Start Tutorial/pt-br"

From Funtoo
(Difference between pages)
Jump to navigation Jump to search
 
 
Line 1: Line 1:
If you are brand new to Gentoo Linux or Funtoo Linux, this page will help you to get familiar with your new system, and how it works.
= Prefácio =


== Intro to Emerge: Installing an Editor ==
== Como o Metro Funciona ==  


By default, Funtoo Linux has the <tt>nano</tt> and <tt>vi</tt> editors installed. <tt>nano</tt> is the default editor.
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 &quot;seed&quot; stage. Essa semente &quot;semente&quot; stage tipicamente é utilizado com o ''ambiente build'' para a criação do stage que queremos.


If you are new to Funtoo Linux, you have probably heard about <tt>[[emerge]]</tt>, the Funtoo and Gentoo Linux command for installing packages from the Portage tree. Funtoo Linux has a git-based Portage tree, which is located at <tt>/usr/portage</tt> by default. It contains scripts called ''ebuilds'' that describe how to build and install packages from source. <tt>emerge</tt> is used to run these scripts and install packages, as follows:
[[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>
<console>
# ##i##emerge vim
# ##i##emerge dev-vcs/git
# ##i##emerge dev-python/boto
</console>
</console>


You can also see what packages ''would'' be installed, but not actually install them, by using the <tt>-p</tt>, or <tt>--pretend</tt> option:
Depois, clone o master git repository como a seguir:


<console>
<console>
# ##i##emerge -p vim
# ##i##cd /root
# ##i##git clone git://github.com/funtoo/metro.git
# ##i##cp /root/metro/metro.conf ~/.metro
</console>
</console>


Another equally handy option is the <tt>-a</tt>, or <tt>--ask</tt> option, which will display the packages to be merged, and then ask for confirmation from you before continuing:
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 =


<console>
{{Note|Metro não é atualmente capaz de construir stages do Gentoo. Veja {{Bug|FL-901}}.}}
# ##i##emerge -a emacs


These are the packages that would be merged, in order:
[[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.


Calculating dependencies... done!
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, 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.
[ebuild N    ] app-admin/eselect-emacs-1.13
[ebuild  N    ] net-libs/liblockfile-1.09
[ebuild  N    ] app-emacs/emacs-common-gentoo-1.3-r1  USE="-X -emacs22icons"
[ebuild  N    ] app-editors/emacs-23.4-r1  USE="alsa gif gpm jpeg png tiff xpm -X -Xaw3d (-aqua) -athena -dbus -gconf -gtk -gzip-el -hesiod -kerberos -livecd -m17n-lib -motif -sound -source -svg -toolkit-scroll-bars -xft"
[ebuild  N    ] virtual/emacs-23


Would you like to merge these packages? [Yes/No]  ##i##y
{{file|name=.metro|desc=Metro configuration|body=
</console>
# Main metro configuration file - these settings need to be tailored to your install:


In the above <tt>emerge</tt> output, you can see some text beginning with <tt>USE=</tt> on the <tt>app-editors/emacs</tt> line. This means that this package has a number of optional build-time features which can be controlled using Portage USE variables. These USE variables can be set globally by adding a line such as this to <tt>/etc/make.conf</tt>:
[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]


<pre>
[section path/mirror]
USE="gif jpeg png tiff xpm"
</pre>


If you go ahead and make these changes, and then run <tt>emerge -a emacs</tt> again, you will notice that several more dependencies will be pulled into the list of packages to be merged. You can control the footprint of your Funtoo Linux system (and avoid bloat) by enabling only the USE variables you need.
: /home/mirror/funtoo
owner: root
group: repomgr
dirmode: 775


Above, we enabled several USE variables globally in <tt>/etc/make.conf</tt>. It is also possible to enable USE variables on a per-package basis, and often times this is the best approach. If you wanted to enable <tt>gtk</tt> for emacs only, you would create the <tt>/etc/portage/package.use</tt> directory, and create an <tt>emacs</tt> file in it that contained the following:
[section portage]


<pre>
MAKEOPTS: auto
app-editors/emacs gtk
</pre>


Note that <tt>package.use</tt> can also be a file if you prefer. However, using an <tt>/etc/portage/package.use</tt> directory is recommended as it keeps things better organized. The filenames you use inside the <tt>package.use</tt> directory do not impact Portage behavior and can be named whatever is convenient for you. You might want to put the settings above in a file called <tt>/etc/portage/package.use/editors</tt> if you have several USE settings that you use for editors.
[section emerge]


See the [[emerge]] page for more information on various emerge command-line options and best practices.
options: --jobs=4 --load-average=4 --keep-going=n


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


Funtoo Linux also has a special meta-command called <tt>eselect</tt>, which can be used to set many default system settings. One of the things it is used for is to set the default editor used by things like <tt>crontab -e</tt>, etc that will automatically start an editor when run. Here is how to use <tt>eselect</tt> to change the default system editor:
== Arch and Subarch ==


In the following example we are creating a pentium4 stage 3 compiled for x86-32bit binary compatibility. Pentium4 is a subarch of the x86-32bit architecture. Once you have metro installed you may find a full list of each subarch in your <tt>/root/metro/subarch</tt> directory each subarch will have the file extension .spec
Example:
<console>
<console>
# ##i##eselect editor list
###i## ls /root/metro/subarch
Available targets for the EDITOR variable:
# ls subarch/
  [1]  /bin/nano
amd64-bulldozer-pure64.spec  armv7a.spec          core-avx-i.spec        i686.spec        pentium.spec
   [2]  /bin/ed
amd64-bulldozer.spec        armv7a_hardfp.spec   core2_32.spec          k6-2.spec        pentium2.spec
  [3]  /usr/bin/ex
amd64-k10-pure64.spec        athlon-4.spec        core2_64-pure64.spec    k6-3.spec        pentium3.spec
  [4]  /usr/bin/vi
amd64-k10.spec              athlon-mp.spec      core2_64.spec          k6.spec          pentium4.spec
   [ ]  (free form)
amd64-k8+sse3.spec          athlon-tbird.spec    corei7-pure64.spec      native_32.spec    pentiumpro.spec
# ##i##eselect editor set 4
amd64-k8+sse3_32.spec        athlon-xp.spec      corei7.spec            native_64.spec    prescott.spec
Setting EDITOR to /usr/bin/vi ...
amd64-k8-pure64.spec        athlon.spec          generic_32.spec        niagara.spec      ultrasparc.spec
Run ". /etc/profile" to update the variable in your shell.
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>
</console>


After logging in again, or typing <tt>source /etc/profile</tt> in the current shell, the new system editor will be active.
= First stages build (local build) =


Note that if you want to use vim instead of a vi through busybox you also need to run:
To get this all started, we need to bootstrap the process by downloading an initial seed stage3 to use for building and place it in its proper location in <tt>/home/mirror/funtoo</tt>, so that [[Metro]] can find it. We will also need to create some special &quot;control&quot; files in <tt>/home/mirror/funtoo</tt>, which will allow [[Metro]] to understand how it is supposed to proceed.
 
== Step 1: Set up pentium4 repository (local build) ==
 
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>
# ##i##eselect vi set vim
# ##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>
</console>


=== Profiles ===
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.
 
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.
 
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.


You may have heard that Funtoo Linux and Gentoo Linux are metadistributions, which means that rather than being a one-size-fits-all kind of Linux, they allow you to customize your system to your liking. We have already taken a look at <tt>USE</tt> variables, and there are also various other settings that can affect the features that are installed when you emerge a package.
== Step 2: Building the pentium4 stages ==


In Funtoo Linux, we have a system of ''profiles'' which can be used to enable various useful settings at once. In fact, a number of profiles are already enabled on your system. For example, on my desktop system, typing <tt>eselect profile show</tt> produces the following output:
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>
# ##i##eselect profile show
# ##i##cd /root/metro
# ##i##scripts/ezbuild.sh funtoo-current pentium4
</console>
 
If you have a slow machine, it could take several hours to be completed because several "heavy" components like gcc or glibc have to be recompiled in each 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.


##g##Currently set profiles:
= Building for another binary compatible architecture (remote build) =
    arch: gentoo:funtoo/1.0/linux-gnu/arch/x86-64bit
  build: gentoo:funtoo/1.0/linux-gnu/build/current
  flavor: gentoo:funtoo/1.0/linux-gnu/flavor/desktop
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/gnome
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/hardened


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


##g##Automatically enabled profiles:
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).
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/print
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.
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/X
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/audio
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/dvd
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/media
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/console-extras
</console>


In case you're curious, these various profile settings live within <tt>/usr/portage/profiles</tt> -- in the listing above, the <tt>gentoo:</tt> prefix refers to this portage profile directory. You can find the profile settings for <tt>gentoo:funtoo/1.0/linux-gnu/mix-ins/X</tt> by looking in <tt>/usr/portage/profiles/funtoo/1.0/linux-gnu/mix-ins/X</tt>, for example.
{{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.}}


Under the list of <tt>Currently set profiles</tt>, you'll see that I have an <tt>x86-64bit</tt> arch profile. In Funtoo Linux, ''all'' systems have a single arch profiled defined, and this is where settings specific to your system architecture are defined. In addition, I have a build profile of ''current''. All Funtoo Linux systems have a single build profile defined, and this tells Portage what masks to apply to the Portage tree -- in other words, what selection of packages you will have available to emerge. If you are using funtoo-stable, your build profile will be ''stable'' and you will have a more limited set of packages that you can merge by default -- the stable set.
== Step 1: Set up Core_2 32bit repository ==


You will also see that I have a ''flavor'' profile. Unlike the ''arch'' and ''build'' profiles, which should not be changed, you can choose another flavor if you want. In fact, we encourage you to do so. The ''flavor'' is used to define the general type of system you are creating. You can only have one flavor profile enabled, and since this command was run on a desktop-type system, I have enabled the ''desktop'' flavor. This enables a variety of settings, primarily USE flags, suitable for desktop systems.
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:


You'll also see that I have a couple of ''mix-ins'' enabled. In Funtoo Linux, you can have zero or more mix-ins enabled -- I have ''gnome'' enabled, which sets various settings that are optimal for the use of the [[GNOME First Steps|GNOME]] desktop environment, and then I am also using the ''hardened'' mix-in, since I have set up a so-called "hardened" system with various protections against malicious attacks.
<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>


{{Tip|1=Take advantage of Funtoo Linux's [[:News:New Media Mix-ins| enhanced Media mix-ins]] to help you easily get the level of media support you want for your system.}}
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.


Then there's a list of automatically-enabled profiles. This shows you any profiles that are pulled in by the main profiles and mix-ins that are already enabled. As you can see, the ''print'', ''X'', ''audio'', ''dvd'', ''media'' and ''console-extras'' have been enabled, likely by the ''desktop'' flavor.
{{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.}}


For now, it is not necessary to get too deep into profiles, but if you are creating a desktop system, I suggest you set the ''desktop'' flavor. To do this, type <tt>eselect profile list</tt> and find the number to the left of <tt>funtoo/1.0/linux-gnu/flavor/desktop</tt>. Then, type the following command as the root user:
== 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:


<console>
<console>
# ##i##eselect profile set-flavor 99
# ##i##/root/metro/scripts/ezbuild.sh funtoo-current core2_32
</console>
</console>


(Replace "99" with the number from the list)
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.


You will now have the ''desktop'' flavor set for your system. Type <tt>eselect profile show</tt> to see your new settings.
== Step 3: The Next Build ==


=== Updating your system ===
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.


Sometimes, you may want to update the packages on your system. Often, this is done after you run <tt>emerge --sync</tt>, which will grab Portage tree updates from the main Funtoo Linux Portage tree:
= Build your own tailored stage3 =


<console>
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>:
# ##i##emerge --sync
{{file|name=funtoo-current/build.conf|body=
[collect ../../fslayouts/funtoo/layout.conf]
 
[section release]


>>> Starting git pull...
author: Daniel Robbins <drobbins@funtoo.org>
remote: Counting objects: 1791, done.       
remote: Compressing objects: 100% (206/206), done.       
remote: Total 980 (delta 811), reused 931 (delta 764)       
Receiving objects: 100% (980/980), 185.04 KiB, done.
Resolving deltas: 100% (811/811), completed with 754 local objects.
From git://github.com/funtoo/experimental-mini-2011
  7a17140..b836bc8  funtoo.org -> origin/funtoo.org
Updating 7a17140..b836bc8
Fast-forward
>>> Git pull in /usr/portage successful


* IMPORTANT: 1 news items need reading for repository 'gentoo'.
[section target]
* Use eselect news to read news items.


#
compression: xz
</console>


You may also want to update your system after you have changed USE flag settings. To take advantage of the USE flags you have just enabled, it's necessary to recompile everything that includes them.
[section portage]


Below, you'll find a recommended <tt>emerge</tt> command for updating your entire system. The <tt>-a</tt> option will cause <tt>emerge</tt> to prompt you for confirmation before starting the merge:
FEATURES:
SYNC: $[snapshot/source/remote]
USE:


<console>
[section profile]
# ##i##emerge -auDN world
</console>


<tt>-u</tt> tells <tt>emerge</tt> to update any already-installed but out-of-date packages that we specify on the command-line. The <tt>-D</tt> option tells <tt>emerge</tt> to perform a ''deep'' dependency tree graph, so it will include sub-dependencies of packages that we have specified on the command line as well. This allows <tt>emerge</tt> to perform as thorough an update of your system as possible.
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:


The <tt>-N</tt> (<tt>--newuse</tt>) option tells Portage to check for any new USE flags that have been enabled or disabled, and rebuild packages so that all USE flags are set as currently defined in <tt>/etc/make.conf</tt> and <tt>/etc/portage/package.use</tt>.
[section version]


<tt>world</tt> is a "meta-package" or "package set" which includes every package that you have manually installed plus all packages in the system set. It's important to note that whenever you ask <tt>emerge</tt> to install anything, such as <tt>metalog</tt> or <tt>vim</tt>, those packages will be automatically added to the world package set. In this way, <tt>emerge</tt> learns what packages you care about and want to keep updated. If you want to see what's in your world package set, take a look at <tt>/var/lib/portage/world</tt>:
python: 2.7


<console>
[section emerge]
# ##i##cat /var/lib/portage/world
app-editors/vim
app-portage/eix
app-portage/gentoolkit
dev-vcs/git
net-misc/bridge-utils
net-misc/dhcpcd
net-misc/keychain
sys-apps/gptfdisk
sys-apps/pciutils
sys-devel/bc
sys-fs/reiserfsprogs
sys-kernel/vanilla-sources
</console>


Also note that some packages may have been added to the world set by Metro when your stage3 tarball was built.


==== Updating a few packages ====
[section snapshot]


If we simply wanted to rebuild a few packages to reflect updated USE flag settings, we could specify it instead of <tt>world</tt>. Be sure to include the <tt>-N</tt> option:
type: live
compression: xz


<console>
[section snapshot/source]
# ##i##emerge -auDN vim emacs
</console>


== Useful applications for daily usage ==
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


Here are some other packages you may want to consider installing via <tt>emerge</tt>:
[section metro]


;<tt>app-misc/screen</tt>: Allows you to have persistent login sessions.
options:  
;<tt>app-misc/tmux</tt>: Similar to <tt>screen</tt> -- some people prefer it.
options/stage: cache/package
;<tt>app-admin/sudo</tt>: Grant root privileges to selected users and command combinations.
target: gentoo
;<tt>sys-process/htop</tt>: Colorful and informative text-based process list.
;<tt>sys-process/glances</tt>: Similar to htop, includes disc I/O and network I/O in display.
;<tt>app-portage/eix</tt>: Quick portage package search
;<tt>app-portage/gentoolkit</tt>: Portage utils
;<tt>app-misc/mc</tt>: GNU Midnight Commander is a text based file manager --- some will recall <tt>MS-DOS XtreeGold</tt>
;<tt>app-text/wgetpaste</tt>: Command-line interface to various pastebins; very useful in providing info along with bugs reports
;<tt>net-irc/irssi</tt>: A modular textUI IRC client with IPv6 support; a powerful tool to get help from Funtoo Community on IRC channel. Nice companion to <tt>app-text/wgetpaste</tt>


<console>
[section baselayout]
# ##i##emerge --jobs app-misc/screen sudo htop eix gentoolkit app-misc/mc wgetpaste net-irc/irssi
</console>


=== Creating a user account ===
services: sshd


It's a good idea to create a normal user account that you can use for general Linux tasks. Before rebooting, create a user account for everyday use. Adjust the groups in the example below to match your needs. Some of them may not exist yet on your system. Replace "<tt><user_name></tt>" with the name you're going to use for your everyday user. The "<tt>-m</tt>" option instructs <tt>useradd</tt> to create a home directory for your user. See <tt>man useradd</tt> for more info.
[section multi]


<console>
snapshot: snapshot
# ##i##useradd -m -g users -G audio,video,cdrom,wheel <user_name>
</console>
Don't forget to set a password for your new user:
<console>
# ##i##passwd <user_name>
</console>


== Installing a graphical environment ==
[section files]


If you intend on using your Funtoo Linux installation for more than system administration, chances are you're going to want to have a GUI (graphical user interface). In the past, setting one up involved wading through text files and man pages. Thanks to modern tools like udev this is no longer the case.
motd/trailer: [


Unlike most operating systems, Funtoo does not ship with a GUI pre-installed. If you've used Windows or Mac OS, you'd also know that their interfaces cannot be replaced easily. With Linux, the opposite is true -- you are free to choose from a huge selection of GUIs. From window managers such as Blackbox, IceWM, and xmonad, to fully-featured desktop environments like GNOME and KDE, the possibilities are vast in number.
>>> Send suggestions, improvements, bug reports relating to...


The first step in setting up a graphical environment is to set up the [[X Window System]]. Then, you will be able to install the graphical environment of your choice. [[GNOME First Steps|GNOME]] is a popular option for new users.
>>> This release:                  $[release/author]
>>> Funtoo Linux (general):        Funtoo Linux (http://www.funtoo.org)
>>> Gentoo Linux (general):        Gentoo Linux (http://www.gentoo.org)
]


[[Category:HOWTO]]
[collect ../../multi-targets/$[multi/mode:zap]]
[[Category:Install]]
}}
[[Category:Featured]]

Revision as of 10:58, 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 dev-vcs/git e No results (opcional; exigido para suporte EC2) sejam estalados no seu sistema:

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

Depois, clone o master git repository como a seguir:

root # cd /root
root # git clone git://github.com/funtoo/metro.git
root # 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, 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]]