Construindo o XO: Introduzindo Sugar

From OLPC
Jump to: navigation, search

Este página contém a tradução do artigo Building the XO: Introducing Sugar, de Greg DeKoenigsberg, publicado na Red Hat Magazine em 23 de fevereiro de 2007. Atualmente esta tradução está em andamento.



COPYRIGHT
Red Hat either owns the intellectual property rights in the HTML, text, images audio, video, software or other content that is made available on this website, or has obtained the permission of the owner of the intellectual property. Red Hat strictly prohibits the redistribution or copying of any part of this website or content on this website without written permission from Red Hat. Red Hat authorizes you to display on your computer, download and print pages from this website provided the copyright notice appears on all such printouts and the information will not be altered and the content is only used for personal, educational and non-commercial use and will not redistribute or copy to any other media.
Please verify the status of this content...


A cada dia o Um Laptop Por Criança aproxima-se da realidade - e a cada dia, mais pessoas procuram maneiras de se envolver com o projeto OLPC. Ainda demorará certo tempo antes que os sistemas XO estejam disponíveis para ampla distribuição, mas as pessoas podem ver por elas mesmas sobre tudo o que o XO é baixando o Sugar, o núcleo da Interface Humana do OLPC.

O Sugar, para aqueles que não são familiares com ele, é bastante diferente do ambiente desktop ao qual usuários Linux se acostumaram. O XO foi concebido como uma ferramenta para permitir a crianças aprender interativamente, e o Sugar foi concebido com esse objetivo. A primeira coisa que uma criança vê, consequentemente, não é um disco rígido ou uma lata de lixo - é as outras crianças da "vizinhança". Desenvolvedores do Sugar são encorajados a escrever atividades com os elementos colaborativos que são habilitados por padrão. As Linhas-guia da Interface Humana discutem a filosofia do Sugar em detalhes, mas na realidade não há substituto para a experiência de usar o Sugar diretamente.

Existem algumas maneiras de testar o Sugar. Existem versões Live CD, e também imagens binárias que podem ser executadas em modo de emulação com um ambiente de emulação como o qemu.

A melhor maneira de experimentar o Sugar, no entanto, é construí-lo a partir do código fonte - especialmente se você deseja prosseguir para o próximo passo e desenvolver atividades a serem usadas com o Sugar. Felizmente, construir o Sugar está se tornando mais fácil a cada nova versão. Aqui estão algumas direções a serem seguidas para iniciar.

Informações básicas

A primeira coisa a entender sobre o Sugar é que ele é baseado no futuro Fedora 7 - o que significa que não será possível construir o Sugar sobre qualquer distribuição Linux que você esteja rodando sem fazer alguns ajustes. Isto é parte de ser um desenvolvedor: lidar com ambientes em permanente mudança.

Boas ferramentas ajudam, no entanto. O problema de gerenciar vários componentes construídos de formas diferentes é um problema que os desenvolvedores do GNOME enfrentam todos os dias - e é por isso que os desenvolvedores do Sugar tomaram emprestado o excelente jhbuild criado por James Henstridge do projeto GNOME e adaptaram para uso com o Sugar. Esteja você usando Fedora, Ubuntu, Debian ou Mandriva, você pode facilmente executar o sugar-jhbuild.

Na verdade, o sugar-jhbuild não é tão complicado; essencialmente é um conjunto de scripts que baixam código fonte de vários tipos de repositório, constroem todo o código, e colocam os binários resultantes em um diretório local. O ponto fraco do jhuild é que você essencialmente constrói uma distribuição miniatura - um tipo de mini-Gentoo - e isso requer espaço em disco e tempo. A vantagem, no entanto, é que os mantenedores do projeto fazem todo o trabalho de configurar o sugar-jhbuild e mantê-lo funcionando. Tudo que é necessário fazer é rodar os scripts, talvez corrigir alguns pequenos problemas, e ser paciente. Ah, e tenha certeza que você tem git, CVS e subversion instalados.

Baixando o Sugar Builder

git-clone git://dev.laptop.org/sugar-jhbuild `date +%F`-SUGAR cd `date +%F`-SUGAR

Este é o primeiro passo: pegue o sugar-jhbuild clonando seu repositório git. O diretório criado (no caso do comando acima, contendo a data de criação no nome) será a casa de seu novo ambiente Sugar. Códigos-fonte e binários irão ambos estar nesse diretório, então tenha certeza que você tem bastante espaço em disco alocado para isso. A última versão que eu construí tomou 3 Gigabytes para baixar e construir, então prepare-se.

Iniciando o Sugar Builder

yum -y update yum groupinstall "Development Tools" yum groupinstall "X Software Development"

Para usuários do Fedora Core 6, a sessão precedente é para você. Rode os comandos yum acima como root; isso vai certificar que você tem todos os pacotes de desenvolvimento do Fedora necessários para iniciar o sugar-jhbuild. Se você usa outra distribuição, outros comandos serão necessários; rode ./sugar-jhbuild sanitycheck para descobrir o que você precisa instalar para executar o sugar-jhbuild em sua distribuição preferida.

Baixando o código fonte do Sugar

./sugar-jhbuild update meta-sugar-base ./sugar-jhbuild update

Neste passo, você irá baixar todos os arquivos fonte necessários para construir o Sugar. O primeiro comando pega os arquivos fonte para todas as dependências requeridas para construir o Sugar; o segundo comando pega os arquivos fonte do próprio Sugar.

Note que é inteiramente possível rodar os scripts para construção sem explicitamente baixar todos os arquivos fonte antes. Os scripts de construção sempre atualizam os arquivos fonte de qualquer modo como parte do processo de construção. Então por que rodar essas atualizações antes?

Porque pegar todos os fontes pode demorar, e isso pode ser a parte mais frustrante do processo. Você estará baixando grandes pedaços de código de um monte de sites diferentes. Alguns desses sites podem estar disponíveis; outros não; alguns deles podem estar realmente, realmente devagar. Talvez o subversion exceda o time out, e você terá que matar o sugar-jhbuild, matar o processo do subversion, apagar aquela parte da árvore de fontes e começar novamente. (Como, por exemplo: rm -rf source/libxml2; ./sugar-jhbuild update meta-sugar-base, o que eu fiz meia dúzia de vezes).

Once the source files have all been retrieved, though, the build steps can run largely unattended. Even if some of your source becomes outdated, it will be much easier to download a small source diff than an entire source tree.

Building the Sugar Binaries

./sugar-jhbuild build meta-sugar-base

Now it’s time to build Sugar’s direct dependencies: autoconf, python, pygtk, avahi, mozilla, and many others. These are all covered under the meta-sugar-base dependency established in sugar-jhbuild.

“But wait,” you say, “I already have all of these things installed on my system,” and so you do. But you’ve almost certainly got versions that Sugar isn’t interested in. For instance, I’m running Fedora Core 6, which has Python 2.4.4 running by default — but Sugar needs Python 2.5. Therefore, sugar-jhbuild will build Python 2.5, and other specific application versions required by Sugar, and will install these versions into the bin/ and/or lib/ directories in your Sugar directory.

So kick off that build. You might want to go to dinner now. Or maybe to bed. It’ll finish at some point, but don’t wait up. Mozilla alone can take several hours. But be patient; it’s worth the wait.

./sugar-jhbuild build

At long last, you’re finally ready to build Sugar and all of its activities.

This is actually the quickest part of the build. It’s also the part most likely to break, since the components here are most likely to be in flux at any given time. If your build breaks here, though, you’ve got immediate recourse; the friendly folks on the Sugar mailing list will be happy to help, especially if you’ve found a real bug. Which, at this early stage in Sugar’s life, could be quite likely.

Running Sugar

./sugar-jhbuild run

You’ve built it; now it’s time to run it. To run Sugar, use the sugar-jhbuild run command. This will set all of the necessary environment variables for Sugar. For instance, it will tell Sugar to use the custom-installed Python 2.5 instead of the likely system default of Python 2.4.

It may not be clear to you how Sugar works. That’s okay; it’s a very different environment than most Linux geeks are used to. If you need some hints, be sure to check out the release notes to understand the nuances of the Sugar interface; even though the notes were written for the actual XO itself, they apply to the Sugar software as well.

A few quick commands to get you started:

   * Alt-F makes the frame come and go.
   * Alt-C quits an activity.
   * Alt-0 brings up the developers console.
   * Alt-Q quits Sugar.

Again, if you find bugs, pop on to the Sugar mailing list and say hello. The growing Sugar community will be delighted to help you.

Next up: writing Sugar activities

All done for now; with patience and a bit of luck, your very own instance of Sugar should be installed and running. Have fun playing with Sugar and all of its activities.

Next time, we’ll focus on writing our first activity for the XO.