Building from sources

Getting started

Sugar is made of several modules and it often depends on libraries which has not yet been packaged in linux distributions. To make it easier for developers to build from sources, we developed a set of scripts that automates builds and other common development tasks.

Only a few distributions are supported by the scripts, the most popular and most recent. Unfortunately we can’t support everything, especially older versions, we prefer to focus on making the scripts work really well where supported. You can choose between the 32-bit and 64-bit versions of

First of all clone the sugar-build git repository

git clone git://github.com/sugarlabs/sugar-build.git

Then enter the main directory and build the source code. It may take some time, depending on your distribution, computer and network speed

cd sugar-build
make build

Finally run it with

make run

If anything goes wrong, you can check if there are known problems with the source code, by looking at the buildbot status. If it’s red then something is wrong and hopefully developers will fix it soon. If it’s green then the issue is probably not yet known and you should report it. You can generate useful debug information with

make bug-report

Developing

All the sources are inside the sugar-build/source directory. You can make changes using any text editor. If sugar is already running stop it, then restart it with

make run

Once in a while you will want to update to the latest sugar sources, issuing the command

make pull

Commands reference

You can run the commands as make arguments

make build
make run

Or inside a shell

make shell

[sugar-build $] build
[sugar-build $] run

The following commands are available

Preferences reference

You can set a few options by creating a sugar-build/prefs file. For example

OUTPUT=HDMI1
RESOLUTION=1024x768

The following preferences are available

Adding a new distribution

To add support for other distributions you first need to add a plugin, implementing the PackageManager and DistroInfo interfaces. It helps to take a look at the existing implementations in devbot/plugins.

The next step is to provide distributions specific package names. To do so, edit the config/packages/deps.json file (or the one with your system version). The keys of the dictionary are cross distribution dependency names, which are mapped to a list of dependency specific package names. For example

"evince typelib": {
    "debian": [
        "gir1.2-evince-3.0"
    ], 
    "fedora": [
        "evince-libs"
    ], 
    "ubuntu": [
        "gir1.2-evince-3.0"
    ]
} 

Add the correct package name (or names) for your distribution to each element of the dictionary. If you are not clear on what package you need to add, you can refer to the config/deps directory, which defines, in several files, the cross distribution dependencies. For example

{
    "check": "from gi.repository import EvinceDocument", 
    "checker": "python", 
    "name": "evince typelib"
} 

You can map it to the package by looking at the check_name field. There are different kind of checkers, which takes the check field as input.

You should edit buildbot.json in a similar way (there is only one package there). Finally, you should add to basesystem.json a minimal list of packages necessary for the system work. If just these are installed it should be able to boot, function and install new packages.

That’s it! If all is configured correctly you should now be able to build sugar on the new distribution.