Sugar on Gentoo Linux

From OLPC
Revision as of 04:33, 2 August 2007 by Tannewt (talk | contribs) (added new dbus information)
Jump to navigation Jump to search

Introduction

There are two major approaches available to building Sugar on Gentoo Linux. In the first, you use Gentoo's Portage build system to update your Gentoo system to a state which is comparable to the environment on an OLPC laptop. Note that this involves upgrading past the point which Gentoo recommends as a stable configuration for a number of packages.

The second approach, which is not explored in detail here, is closer to that which is done for other Linux operating systems, namely using:

 sugar-jhbuild build-base

to construct a parallel development environment which is used solely for the Sugar system. This builds approximately 180 packages before you begin the Sugar-specific build process. Unfortunately, because of the way jhbuild and sugar-jhbuild work this process will often fail when any one of the projects happens to check in broken code on their HEAD. The process outlined here avoids that problem somewhat by using relatively stable libraries from Gentoo's native portage.

Installation

Sugar can be built on an up-to-date Gentoo system by updating a number of the Gentoo system's libraries. These instructions are being updated on 2007-02-28 to reflect current build practice as successfully completed by the PyCon sprint. Test machine was an up-to-date x86 laptop with minimal ~x86 features added to support the Sugar environment. It requires a considerable period to build the system even on an up-to-date Gentoo machine, as the dependencies include large projects such as the Abiword word-processor and Mozilla's XULRunner.

Prerequisites

You will need to emerge rather a lot of software, with many of the packages being ~x86 or hard-masked. For any package which is hard-masked, you will have to add the package to your /etc/portage/package.unmask file (which you may need to create).

Please keep in mind that unmasking hard-masked files is strongly discouraged by Gentoo, and the project will generally *not* provide support for problems encountered with the software (i.e. ask on the Sugar lists before you ask on the Gentoo lists for hard-masked packages).

To unmask a hard-masked package, add a line such as the following to your /etc/portage/package.unmask file:

 =net-misc/networkmanager-0.6.4_pre20061028-r1
 =dev-libs/libnl-1.0_pre6
 =net-misc/dhcdbd-1.14-r1
 =dev-lang/python-2.5-r1

To unmask an ~x86-masked package, add a line such as the following to your /etc/portage/package.keywords file:

 dev-lang/python ~x86
 dev-python/setuptools ~x86
 net-libs/xulrunner ~x86
 net-misc/networkmanager ~x86
 dev-libs/libnl ~x86
 net-misc/dhcdbd ~x86
 dev-python/dbus-python ~x86

Note that you can use the full format (including comparison operator and version) as specified in the package.unmask file above as well.

You will also need a 1.1.x series dbus available in the Gentopia Overlay. This is easiest done by using layman.

 emerge layman
 layman -a gentopia
 emerge dbus

Note: you may need to specify the ~x86 keyword for sys=apps/dbus in the package.keywords file.

You will also likely need to specify USE flags for a number of packages. These are added to the /etc/portage/package.use file in a format like so:

 dev-util/subversion -apache2
 net-dns/avahi dbus python
 dev-python/gnome-python-extras firefox
 x11-base/xorg-server kdrive
 net-wireless/wpa_supplicant -qt4

Python 2.5 is Required

You will need to upgrade your Gentoo installation to Python 2.5, then upgrade all of the packages dependent on Python (normally Python modules):

 emerge -avDt ">=dev-lang/python-2.5"
 python-updater

DO NOT skip the python-updater stage or you will have build failures later in the process. Packages will attempt to build against the old Python version and then get confused when "python" is the new version.

Note that Python is a core component of Gentoo's portage package management system. As such it is potentially possible that you could damage your system by using an unsupported Python version. Probably not a huge risk, but be careful!

Note that with more recent (2007-07-12) jhbuilds you may need to disable building Python in order to prevent conflicts between the jhbuild-based and platform Python (and GTK+). Create edit the file ~/.olpc.jhbuildrc to add the line:

 skip = ['python','gtk+']

Emerge the prerequisites

Sugar requires a large number of standard Gentoo packages, you will need to emerge all of them in order to build the package:

 emerge -avDt \
   dev-util/git\
   cvs subversion\
   docbook-sgml-utils\
   gtk-doc\
   avahi\
   expat\
   gstreamer\
   xulrunner\
   pycurl\
   networkmanager\
   gnome-python-desktop\
   gnome-python-extras\
   ">=dev-python/dbus-python-0.80.1"\
   boost\
   darcs\
   fribidi

You will also likely need to rebuild the x11-base/xorg-server package to build the "nested X servers" module, (particularly the "Xephyr" server which Sugar uses) this is done by specifying "kdrive" USE flag then rebuilding the server:

 emerge -avDt --newuse xorg-server

You may also need the "dm-crypt" module compiled into your kernel. To check for the presence of the module (one of the dependencies claims it is required in a default Gentoo build):

 modprobe dm-crypt

if this fails, enable the option in your kernel and rebuild the kernel with genkernel (or whatever you prefer for your kernel building pleasure):

   Device Drivers
     Multi-Device Support
       Device mapper support
         [*] Crypt Target Support

(Note that orospakr says that the dm-crypt module is not actually required).

Setup System Services

You will want to ensure that the required services are started at boot time as well. If you want to run sugar without rebooting you will want to start the services using their /etc/init.d/ scripts as well:

 rc-update add avahi-daemon default
 rc-update add NetworkManager default
 rc-update add dbus default
 rc-update add hald default

If you do not have these services running when you attempt to start Sugar you will get access exceptions from dbus as your regular user is not allowed to create these system-wide services.

You will also need to alter you /etc/conf.d/net configuration to specify the use of the NetworkManager compatible dhclient module. This should be the first line in the file:

 modules=("dhclient" "wpa_supplicant")

If you use the default "dhcpcd" module instead your network will connect, then immediately drop off when NetworkManager takes control of it.

Sugar-jhbuild

Use of Sugar-jhbuild is detailed on building Sugar from sources. To summarize those instructions, in order to build the absolute latest version of Sugar:

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

Note, however, that building the very latest version of Sugar is not likely what you want to do unless you want to help in developing Sugar itself. We are fixing a few bugs to allow for building a non-bleeding-edge version of the project. Sugar will check out the source code and build approximately 24 packages using this approach, while this is a much smaller number than in a full build-base, it's still likely that you will see a failure in at least one package.

If you had already checked out sugar-jhbuild previously, make sure your copy is up-to-date before building:

cd sugar-jhbuild
git-pull

The sanity checks are still very basic but better than nothing:

 ./sugar-jhbuild sanitycheck

Testing sugar

When using sugar-jhbuild, you can use:

./sugar-jhbuild run

If you want to run Sugar from the source tree enter in a jhbuild shell:

./sugar-jhbuild shell 

Then from the directory sugar-jhbuild/source/sugar), use:

shell/sugar