Development Team/Jhbuild

english | 日本語 | spanish HowTo [ID# 12494]  +/-  

Template:DevelopmentTeam/Jhbuild-nav Template:ProposedMoveFromOLPC One of the easiest ways to install Sugar is to use jhbuild.

Sugar-jhbuild will automatically download the latest of Sugar's dependencies as well as Sugar itself directly from their source repositories, rather than relying on source packages that may have become stale. Below are generic instructions on how to use jhbuild to get up and running with Sugar.

Compatible Platforms

Jhbuild is quite demanding with regard to the packages and setup for the host Linux distribution. As a result there are only a few Linux Distributions which are known to work with it.

Checkout sugar-jhbuild

In a suitable directory, execute

git-clone git://dev.laptop.org/sugar-jhbuild

Build sugar base system and its dependencies

Change directory and start the build.

cd sugar-jhbuild
git-pull
./sugar-jhbuild update
./sugar-jhbuild build

Dealing with dependencies

At some point during running sugar-jhbuild update or sugar-jhbuild build you may be interrupted by an error listing some dependencies you don't have. The build will pause, and you'll see, among the text on your screen, something like this:

No package '<packagename>' found

Usually this means it's looking for the <packagename>-dev. Install that package. (For instance, to fix a "No package 'libsoup2.2' found" error, you'd install libsoup2.2-dev.

If that doesn't work, here are some further notes:

  • In addition to the dependencies listed, you may want to install the gtk-doc-tools package (this allowed me to build hippocanvas on Ubuntu Hardy). Mchua 22:01, 15 May 2008 (EDT)
  • If you're given a list of packages that aren't installed, simply install them according to your distribution's package manager (yum, apt-get, etc.) and then try re-running the sugar-jhbuild command again.
  • For the base packages, you may be able to use the binary packages from your GNU distribution instead of building them from scratch. Check the Installing or Linux categories for specific distro info.
  • If you run into an error during sugar-jhbuild build that looks something like "aclocal: macro `AM_PATH_PYTHON' required but not defined" try installing or updating your packages for autoconf and automake and running sugar-jhbuild build again. (worked for me on Ubuntu Hardy) Mchua 17:10, 15 May 2008 (EDT)
  • You may have some issues with penguintv on ubuntu, just interrupt the pull with a CTRL+C, open a shell, repeat the command manually, and accept the certificate permanently.
  • One other fix that I had to do was to export GTK2_RC_FILES=~/src/olpc/sugar-jhbuild/build/share/themes/sugar/gtk-2.0/gtkrc

and also symlink build/share/icons/sugar to build/share/icons/hicolor. These two steps may not be necessary, but they made things work on my Ubuntu installation as of March 31, 2008. Blaketh 03:08, 31 March 2008 (EDT)

Run Sugar

This command launches the Sugar emulator:

./sugar-jhbuild run

To exit the emulator, press Alt-Q.

Running multiple instances

To run multiple instances of sugar you can start it in the following way:

SUGAR_PROFILE=2 ./sugar-jhbuild run

This will create a new profile in ~/.sugar/, i.e. ~/.sugar/2/. You will find logs and configuration for this instance here. The default profile is ~/.sugar/default/

Run an individual activity

Within sugar, e.g. in Terminal, this command launches an individual activity for testing:

sugar-launch [bundle name]

You will see debug output appearing in Terminal.

Configure the mode and resolution of Sugar

You can make Sugar run in a window as well as specify a resolution. Within the sugar-jhbuild/install/share/sugar/shell directory, backup, then edit the python program file emulator.py:

cd sugar-jhbuild
cp install/share/sugar/shell/emulator.py install/share/sugar/shell/emulator.py.backup
nano install/share/sugar/shell/emulator.py

Find this piece of code:

    cmd = [ 'Xephyr' ]
    cmd.append(':%d' % display)
    cmd.append('-ac')

     if gtk.gdk.screen_width() < 1200 or gtk.gdk.screen_height() < 900:
         cmd.append('-fullscreen')
     else:
         cmd.append('-screen')
         cmd.append('%dx%d' % (1200, 900))

Comment out the if and else instructions, and specify the screen resolution and mode you want (it's important to delete 4 spaces before the "cmd.append" lines):

    cmd = [ 'Xephyr' ]
    cmd.append(':%d' % display)
    cmd.append('-ac')

#    if gtk.gdk.screen_width() < 1200 or gtk.gdk.screen_height() < 900:
#        cmd.append('-fullscreen')
#    else:
    cmd.append('-screen')
    cmd.append('%dx%d' % (800, 600))

Sugar will now run on a 800x600 window. This file may be replaced next time you update sugar-jhbuild, and you'll have to do this again. Also note that 800x600 is not an optimal resolution for the window, because the activity circle will be vertically off center. 1024x768 is a more useable resolution.

Other commands

JHBuild has several other commands that can be useful for development. You can get an overview with:

./sugar-jhbuild --help-commands

A useful sequence of commands for building Sugar, from the Sugar mailing list: (Note that build will update first anyway, so run update separately if you want to see what changed more easily.)

./sugar-jhbuild update
./sugar-jhbuild build
./sugar-jhbuild run

If update and build don't work

In May 2008 there were some changes that broke updates on sugar-jhbuild. A version from before this date cannot update or build after this date; the symptoms are various, but generally include errors which mention the "build-scripts" directory. You need to rebuild from scratch in a new jhbuild directory. Something like the following:

cd ..
mv sugar-jhbuild sugar-jhbuild.old
git-clone git://dev.laptop.org/sugar-jhbuild

then, to save bandwidth, move the tar files from your old version:

mkdir sugar-jhbuild/source
mv sugar-jhbuild.old/source/*.tar* sugar-jhbuild/source

then build:

cd sugar-jhbuild
./sugar-jhbuild build

You may then also see some new dependencies; see the relevant instructions above.

From within Sugar

Once you have Sugar running, here are some useful commands:

  • Alt+Shift+F makes the frame appear and disappear
  • Ctrl-Q quits an activity
  • Alt+Shift+Q quits Sugar
  • Alt+Shift+O opens the search
  • Alt+Shift+R rotates the screen

Creating an xsession for Sugar-jhbuild

Create the file /usr/share/xsessions/sugar-jhbuild.desktop with the following content:

[Desktop Entry]
Encoding=UTF-8
Name=Sugar jhbuild
GenericName=Sugar
Exec=/usr/bin/sugar-jhbuild
Type=Application

Create the file /usr/bin/sugar-jhbuild with the following content:

#!/bin/sh
export GTK2_RC_FILES=/home/walter/sugar-jhbuild/install/share/sugar/data/sugar-xo.gtkrc
exec /home/walter/sugar-jhbuild/sugar-jhbuild run dbus-launch /home/walter/sugar-jhbuild/install/bin/sugar-shell

where you substitute the path of wherever you installed sugar-jhbuild for "/home/walter"

Customize

To customize the build create a configuration file, named .olpc.jhbuildrc, in your home directory.

Write access to the repositories

If you have write access to the repositories you can add this (if your login name happens to be marco):

repos['gnome.org'] = ':ext:marco@cvs.gnome.org:/cvs/gnome'
repos['mozilla.org'] = ':ext:marco%gnome.org@cvs.mozilla.org:/cvsroot'
repos['dev.laptop.org'] = 'git+ssh://marco@dev.laptop.org/git/'
repos['dev.laptop.org/projects'] = 'git+ssh://marco@dev.laptop.org/git/projects/'

Useful Internal Links

External links