Customizing the Openmoko Distribution

From Openmoko

Revision as of 19:30, 29 July 2007 by Bryce.Leo (Talk | contribs)

Jump to: navigation, search

Contents

What's the goal?

The goal of this page is to teach you how to take an application that you've coded (or the sample app) and properly get it included in your rootfs. This article is a bit of an aggregate page, it's going to take information from MokoMakefile Using_a_local_overlay Building_a_hello_world_application and Create_a_package_from_existing_sources. So as you can see the goal is for it to be a very thorough introduction, and will take you from "Idea to Inclusion" of your application.


Setting Up the OpenMoko Environment

This part of the tutorial is going to be pretty basic. I absolutely love MokoMakefile, it's fantastic, the creator has done and continues to do a fantastic job with this. I see absolutely no reason not to use it. However I cannot for the life of me understand why they create their working directory in /home/moko, the home directory is for home directories for users of your system, not for a development directory. I put my OpenMoko development directory in /home/bryce/mokodev/ and that works great for me, and also makes more sense so that multiple users on my machine could develop with no attempt to overlap.

To get your environment setup please get it setup according to MokoMakefile however if you do have the build environment setup manually and you're sure you know what you're doing then feel free to go forward with this.

Setting Up a Local Overlay

If you're at the point for setting up a local overlay this means a couple things. First: You've had a brilliant idea for an application that you just need to have on the OpenMoko platform. Second: You realize that this killer app of yours needs to be done properly and you're not going to do anything silly like include it in the actual tree for the OpenMoko distro because it would probably end up just getting overwritten eventually, or you just realize taht it's bad practice!

Thank you to User:CesarB for this part of the wiki.

To create a local overlay:

  • Create a "local" directory and its subdirectories
mkdir local local/conf local/classes local/packages
  • Copy site.conf from the openmoko tree to local/conf
cp oe/conf/site.conf local/conf/site.conf
  • Edit the site.conf you copied to add the new tree as a source for bitbake recipes.

Change the current BBFILES to look like this:

BBFILES := "${OMDIR}/openembedded/packages/*/*.bb ${OMDIR}/oe/packages/*/*.bb ${OMDIR}/local/packages/*/*.bb"

Change your BBFILE_COLLECTIONS line to look like this:

BBFILE_COLLECTIONS = "upstream local overlay"

Add this line:

BBFILE_PATTERN_overlay = "^${OMDIR}/local/"

Add this line:

BBFILE_PRIORITY_overlay = "20"

The BBFILE_PRIORITY should be greater than all the other BBFILE_PRIORITY variables on the same file.

  • Change your BBPATH environment variable to add the new tree before the two others for MokoMakefile, the variable is on the setup-env file.
export BBPATH="${OMDIR}/build:${OMDIR}/local:${OMDIR}/oe:${OMDIR}/openembedded"

Using Your New Local Overlay

Changing files in conf/

To change a file in conf/, just copy the file to the overlay tree (preserving the directory structure) and edit it.

Changing files in classes/

To change a file in classes/, just copy the file to the overlay tree and edit it.

Changing packages

Changing a package's recipe is a bit more complex. You have to copy over (or symlink) not only the .bb file for the package, but also all the files it includes with require, and the FILESDIR directories (all directories referred to by FILESDIR, usually named either package-version or files). If you forget one of them, the build will give an error (either when parsing the recipe in the case of require, or when trying to build in the case of the FILESDIR directories).

Adding a new package

You can add a new package (or a recipe for a new version of a package) to the overlay tree simply by creating it on the overlay tree.

Your First Application

I know that I said I'd have a GDK application in here, however, I'd really like to get this whole course done first and have you guys starting to code instead of just looking at what I've written!

This will be a very simple CLI hello world.

Before We Code

Like a good coder you want to make sure that you're not just doing things, but that you're doing them the right way!

Now change directories into your local/packages directory.The following commands expect you'll be in that directory so don't change unless you know what you're doing!

You'll want to make a directory with the name of your application, and a subdirectory called files.

 mkdir myhelloworld myhelloworld/files

Now you'll want to create two files in the files directory

 touch myhelloworld/files/READEME.txt myhelloworld/files/myhelloworld.c

And finally you'll want to create a bitbake file.

 touch myhelloworld/myhelloworld.bb

Alrighty now all your necessary files are created so lets go over this real quick.

$HOME
 +- $OMDIR (contains the official openmoko tree)
 |  +- local/
 |     +- packages/
 |        +- myhelloworld/
 |           +- myhelloworld.bb
 |           +- files/
 |              +- myhelloworld.c
 |              +- README.txt

That should be your structure, if it's not you should go and fix it up.

Personal tools

What's the goal?

The goal of this page is to teach you how to take an application that you've coded (or the sample app) and properly get it included in your rootfs. This article is a bit of an aggregate page, it's going to take information from MokoMakefile Using_a_local_overlay Building_a_hello_world_application and Create_a_package_from_existing_sources. So as you can see the goal is for it to be a very thorough introduction, and will take you from "Idea to Inclusion" of your application.


Setting Up the OpenMoko Environment

This part of the tutorial is going to be pretty basic. I absolutely love MokoMakefile, it's fantastic, the creator has done and continues to do a fantastic job with this. I see absolutely no reason not to use it. However I cannot for the life of me understand why they create their working directory in /home/moko, the home directory is for home directories for users of your system, not for a development directory. I put my OpenMoko development directory in /home/bryce/mokodev/ and that works great for me, and also makes more sense so that multiple users on my machine could develop with no attempt to overlap.

To get your environment setup please get it setup according to MokoMakefile however if you do have the build environment setup manually and you're sure you know what you're doing then feel free to go forward with this.

Setting Up a Local Overlay

If you're at the point for setting up a local overlay this means a couple things. First: You've had a brilliant idea for an application that you just need to have on the OpenMoko platform. Second: You realize that this killer app of yours needs to be done properly and you're not going to do anything silly like include it in the actual tree for the OpenMoko distro because it would probably end up just getting overwritten eventually, or you just realize taht it's bad practice!

Thank you to User:CesarB for this part of the wiki.

To create a local overlay:

  • Create a "local" directory and its subdirectories
mkdir local local/conf local/classes local/packages
  • Copy site.conf from the openmoko tree to local/conf
cp oe/conf/site.conf local/conf/site.conf
  • Edit the site.conf you copied to add the new tree as a source for bitbake recipes.

Change the current BBFILES to look like this:

BBFILES := "${OMDIR}/openembedded/packages/*/*.bb ${OMDIR}/oe/packages/*/*.bb ${OMDIR}/local/packages/*/*.bb"

Change your BBFILE_COLLECTIONS line to look like this:

BBFILE_COLLECTIONS = "upstream local overlay"

Add this line:

BBFILE_PATTERN_overlay = "^${OMDIR}/local/"

Add this line:

BBFILE_PRIORITY_overlay = "20"

The BBFILE_PRIORITY should be greater than all the other BBFILE_PRIORITY variables on the same file.

  • Change your BBPATH environment variable to add the new tree before the two others for MokoMakefile, the variable is on the setup-env file.
export BBPATH="${OMDIR}/build:${OMDIR}/local:${OMDIR}/oe:${OMDIR}/openembedded"

Using Your New Local Overlay

Changing files in conf/

To change a file in conf/, just copy the file to the overlay tree (preserving the directory structure) and edit it.

Changing files in classes/

To change a file in classes/, just copy the file to the overlay tree and edit it.

Changing packages

Changing a package's recipe is a bit more complex. You have to copy over (or symlink) not only the .bb file for the package, but also all the files it includes with require, and the FILESDIR directories (all directories referred to by FILESDIR, usually named either package-version or files). If you forget one of them, the build will give an error (either when parsing the recipe in the case of require, or when trying to build in the case of the FILESDIR directories).

Adding a new package

You can add a new package (or a recipe for a new version of a package) to the overlay tree simply by creating it on the overlay tree.

Your First Application

I know that I said I'd have a GDK application in here, however, I'd really like to get this whole course done first and have you guys starting to code instead of just looking at what I've written!

This will be a very simple CLI hello world.

Before We Code

Like a good coder you want to make sure that you're not just doing things, but that you're doing them the right way!

Now change directories into your local/packages directory.The following commands expect you'll be in that directory so don't change unless you know what you're doing!

You'll want to make a directory with the name of your application, and a subdirectory called files.

 mkdir myhelloworld myhelloworld/files

Now you'll want to create two files in the files directory

 touch myhelloworld/files/READEME.txt myhelloworld/files/myhelloworld.c

And finally you'll want to create a bitbake file.

 touch myhelloworld/myhelloworld.bb

Alrighty now all your necessary files are created so lets go over this real quick.

$HOME
 +- $OMDIR (contains the official openmoko tree)
 |  +- local/
 |     +- packages/
 |        +- myhelloworld/
 |           +- myhelloworld.bb
 |           +- files/
 |              +- myhelloworld.c
 |              +- README.txt

That should be your structure, if it's not you should go and fix it up.