Mer/Build/Application Building

(Creating Package : WWW)
(wikify slightly)
 
(9 intermediate revisions not shown)
Line 1: Line 1:
 +
{{Mer}}
 +
This page assumes you have [[../Install OBS|installed OBS]] and setup an account.
This page assumes you have [[../Install OBS|installed OBS]] and setup an account.
Line 15: Line 17:
We will use
We will use
* a name of "merpad" (lowercase); this is the ''package'' name
* a name of "merpad" (lowercase); this is the ''package'' name
-
* a title of "MerPad Example"; this is the human title
+
* a title of "MerPad Example"; this is the human readable title
* a description of: "A Mer version of Maemopad. Built on OBS by <yourname>"; this is seen upon installation
* a description of: "A Mer version of Maemopad. Built on OBS by <yourname>"; this is seen upon installation
Line 23: Line 25:
==Configure your Home Project to Build against Mer==
==Configure your Home Project to Build against Mer==
 +
When you upload some source the build-dependencies need to be resolved.  OBS does this by looking at a build target repository; if the dependency isn't there and that repository has its own build target repository then it looks there... and so on.
When you upload some source the build-dependencies need to be resolved.  OBS does this by looking at a build target repository; if the dependency isn't there and that repository has its own build target repository then it looks there... and so on.
Line 37: Line 40:
===Setting up Build Repositories : WWW===
===Setting up Build Repositories : WWW===
 +
* Click on "Home project" in the left navigation bar in the OBS website
* Click on "Home project" in the left navigation bar in the OBS website
* On the right click on "Add Repository"
* On the right click on "Add Repository"
Line 48: Line 52:
===Setting up Build Repositories : CLI===
===Setting up Build Repositories : CLI===
 +
To change the build target repositories (part of the project metadata):
To change the build target repositories (part of the project metadata):
-
   osc meta prj home:lbt -e
+
   osc meta prj home:yourname -e
The XML should look like this (make sure you use your own "name=" value) paying special attention to the <code><repository></code> tags:
The XML should look like this (make sure you use your own "name=" value) paying special attention to the <code><repository></code> tags:
-
<pre>
+
<source lang="xml">
<project name="home:yourname">
<project name="home:yourname">
   <title>yourname's Home Project</title>
   <title>yourname's Home Project</title>
Line 64: Line 69:
   </repository>
   </repository>
</project>
</project>
-
</pre>
+
</source>
Here is a full set of [[/XML_Build_Targets|XML Build targets]] for Ubuntu; they aren't needed unless you're doing something clever.
Here is a full set of [[/XML_Build_Targets|XML Build targets]] for Ubuntu; they aren't needed unless you're doing something clever.
==Creating Package==
==Creating Package==
 +
Each package has its own directory in the project and, by default, is built against any build targets for the project.
Each package has its own directory in the project and, by default, is built against any build targets for the project.
===Creating Package : WWW===
===Creating Package : WWW===
 +
* Click on "Home project" in the left navigation bar in the OBS website
* Click on "Home project" in the left navigation bar in the OBS website
* Click on "Add Package"
* Click on "Add Package"
Line 79: Line 86:
(In the XML the name is also fully qualified with a project and :s )
(In the XML the name is also fully qualified with a project and :s )
-
Fill in the values in the boxes and save changes.
+
Fill in the values in the boxes and save changes; we'll use:
 +
  Name: merpad
 +
  Title : merpad
 +
  Description : A test build of Merpad
===Creating Package : CLI===
===Creating Package : CLI===
 +
Run
Run
  osc meta pkg -e home:<username> <package>
  osc meta pkg -e home:<username> <package>
This will tell the OBS server about the package. It pops up an editor where you can edit the name/description in XML format and then save. The XML appears like this:
This will tell the OBS server about the package. It pops up an editor where you can edit the name/description in XML format and then save. The XML appears like this:
-
<pre>
+
<source lang="xml">
<package name="merpad">
<package name="merpad">
   <title>Title of New Package</title>
   <title>Title of New Package</title>
Line 93: Line 104:
HERE
HERE
   </description>
   </description>
-
   <person role="maintainer" userid="lbt"/>
+
   <person role="maintainer" userid="username"/>
-
   <person role="bugowner" userid="lbt"/>
+
   <person role="bugowner" userid="username"/>
   <url>PUT_UPSTREAM_URL_HERE</url>
   <url>PUT_UPSTREAM_URL_HERE</url>
</package>
</package>
Line 109: Line 120:
   </description>
   </description>
-
   <person role="maintainer" userid="lbt"/>
+
   <person role="maintainer" userid="username"/>
-
   <person role="bugowner" userid="lbt"/>
+
   <person role="bugowner" userid="username"/>
   <url>PUT_UPSTREAM_URL_HERE</url>
   <url>PUT_UPSTREAM_URL_HERE</url>
</package>
</package>
-
</pre>
+
</source>
==Uploading Source==
==Uploading Source==
 +
===Uploading Source : WWW===
===Uploading Source : WWW===
 +
From your Home Project, you should see a "merpad" entry under Packages.
From your Home Project, you should see a "merpad" entry under Packages.
Select merpad to go to the Package page (you may already be there if you just created it).
Select merpad to go to the Package page (you may already be there if you just created it).
Line 159: Line 172:
===Following the build log : WWW ===
===Following the build log : WWW ===
 +
In the package page under the build target is a [Build Log] entry.
In the package page under the build target is a [Build Log] entry.
This takes you to a page showing the build log. There are tickboxes to refresh automatically and to autoscroll.
This takes you to a page showing the build log. There are tickboxes to refresh automatically and to autoscroll.
Line 173: Line 187:
==Downloading the Binaries==
==Downloading the Binaries==
 +
Once OBS has run you can download the binaries and install them by hand.
Once OBS has run you can download the binaries and install them by hand.
Line 194: Line 209:
Then running the application manager should show your MerPad.
Then running the application manager should show your MerPad.
-
=Local Builds=
+
==Local Builds==
OBS lets you run a local build on your desktop.
OBS lets you run a local build on your desktop.
Simply checkout a package:
Simply checkout a package:
-
   osc co home:username/maemopad
+
   osc co home:username/merpad
and run:
and run:
-
   cd home:username/maemopad
+
   cd home:username/merpad
   osc build MerExtrasStable_MerStable_Ubuntu_9.04 armv5el merpad_1.0-1.dsc
   osc build MerExtrasStable_MerStable_Ubuntu_9.04 armv5el merpad_1.0-1.dsc
Line 207: Line 222:
This goes to the server to determine where to get the build-depends (remember the build-target stack) and then downloads them to a local cache. Eventually it installs a bootstrap set to a directory and then does a qemu chroot into it and builds the package.
This goes to the server to determine where to get the build-depends (remember the build-target stack) and then downloads them to a local cache. Eventually it installs a bootstrap set to a directory and then does a qemu chroot into it and builds the package.
 +
 +
Note that the following 2 python modules may be required
 +
apt-get install python-m2crypto
 +
apt-get install python-urlgrabber
Once it is done you should get a line telling you where the deb is:
Once it is done you should get a line telling you where the deb is:
   /scratch3/maemo/Mer/obs/build-MerExtrasStable_MerStable_Ubuntu_9.04-armv5el-merpad/usr/src/packages/DEBS/merpad_1.0-1_armel.deb
   /scratch3/maemo/Mer/obs/build-MerExtrasStable_MerStable_Ubuntu_9.04-armv5el-merpad/usr/src/packages/DEBS/merpad_1.0-1_armel.deb
 +
 +
It will ask for a password at one stage.  You can use your local root password for this.  If you get an error complaining about a lack of /usr/lib/common_functions, then create a folder in your home folder, cd into it, and then follow the instructions [http://gitorious.org/mer/build HERE] .  they should ask you to run the command
 +
 +
  git clone git://gitorious.org/mer/build.git
 +
 +
in that folder.  This will use git to download a newer 'build' tool for you.  See the pageafter it has finished, run ''make install'' to install the tool, and then go back and run the osc build step again.  It should continue from the password prompt step successfully this time.
 +
You can also do:
You can also do:
Line 215: Line 241:
and once there, run arm commands inside the chroot.
and once there, run arm commands inside the chroot.
-
 
+
=== Co-existing with Scratchbox ===
-
== Co-existing with Scratchbox ==
+
If you use the OBS local build facility and the scratchbox-1 local builder then you need to know how to teach the two emulators how to co-exist.
If you use the OBS local build facility and the scratchbox-1 local builder then you need to know how to teach the two emulators how to co-exist.
Line 240: Line 265:
to register qemu to handle arm binaries
to register qemu to handle arm binaries
-
[[Category:Mer]]
+
A typical error signifying you have this issue is
 +
  Exec format error
 +
which means the kernel doesn't understand the binary format of the executable.

Latest revision as of 11:28, 11 February 2011

Image:Mer infobox icon.png
Mer is back : Please visit http://www.merproject.org to learn more about this news.


This page assumes you have installed OBS and setup an account.

The objective is to walk through creating a package on OBS that you can download to your Mer device using the package manager.

We will use MerPad as an example

You can follow either the CLI or www commands; if you mix them up you need to ensure you execute the commands in the right place.

Contents

[edit] To create a new package

These osc commands are done in your own area - use your username after "home:" or make sure you are at your "Home Project" on OBS.

Before you can create projects in your home project, you have to create it.

We will use

  • a name of "merpad" (lowercase); this is the package name
  • a title of "MerPad Example"; this is the human readable title
  • a description of: "A Mer version of Maemopad. Built on OBS by <yourname>"; this is seen upon installation

If you use the CLI interface you can also enter a url.

Obviously, if you have your own source and dsc then amend the details accordingly.

[edit] Configure your Home Project to Build against Mer

When you upload some source the build-dependencies need to be resolved. OBS does this by looking at a build target repository; if the dependency isn't there and that repository has its own build target repository then it looks there... and so on.

So Maemo:Mer:Stable has a build target of Ubuntu_9.04.

However, if you built against :Stable then you'd miss any community libraries in :Extras. So we will setup your home to build against :Extras:Stable

This means that build dependencies will be looked for in:

  1. Maemo:Mer:Extras:Stable
  2. Maemo:Mer:Stable
  3. Ubuntu_9.04

Once this is done, any packages uploaded to this project will build.

[edit] Setting up Build Repositories : WWW

  • Click on "Home project" in the left navigation bar in the OBS website
  • On the right click on "Add Repository"
  • At the bottom, click on "Advanced"
  • Use the name "MerExtrasStable_MerStable_Ubuntu_9.04" (this is important)
  • In the (huge!) "Build Target Selection" scrollbox, select "Maemo:Mer:Extras:Stable/MerStable_Ubuntu_9.04"
  • In the tickboxes, pick "i586" and "armv5el"
  • Click "Save Changes"

If you want to build against Mer:Testing and Mer:Devel aswell then use the XML interface to ensure you get it right.

[edit] Setting up Build Repositories : CLI

To change the build target repositories (part of the project metadata):

 osc meta prj home:yourname -e

The XML should look like this (make sure you use your own "name=" value) paying special attention to the <repository> tags:

<project name="home:yourname">
  <title>yourname's Home Project</title>
  <description>Mer is cool</description>
  <person userid="yourname" role="maintainer"/>
  <person userid="yourname" role="bugowner"/>
  <repository name="MerExtrasStable_MerStable_Ubuntu_9.04">
    <path project="Maemo:Mer:Extras:Stable" repository="MerStable_Ubuntu_9.04"/>
    <arch>armv5el</arch>
    <arch>i586</arch>
  </repository>
</project>

Here is a full set of XML Build targets for Ubuntu; they aren't needed unless you're doing something clever.

[edit] Creating Package

Each package has its own directory in the project and, by default, is built against any build targets for the project.

[edit] Creating Package : WWW

  • Click on "Home project" in the left navigation bar in the OBS website
  • Click on "Add Package"

Note that the 'name' is like a filename (openoffice) whereas 'title' is written out. (Open Office)

(In the XML the name is also fully qualified with a project and :s )

Fill in the values in the boxes and save changes; we'll use:

 Name: merpad
 Title : merpad
 Description : A test build of Merpad

[edit] Creating Package : CLI

Run

osc meta pkg -e home:<username> <package>

This will tell the OBS server about the package. It pops up an editor where you can edit the name/description in XML format and then save. The XML appears like this:

<package name="merpad">
  <title>Title of New Package</title>
  <description>
LONG DESCRIPTION 
GOES 
HERE
  </description>
  <person role="maintainer" userid="username"/>
  <person role="bugowner" userid="username"/>
  <url>PUT_UPSTREAM_URL_HERE</url>
</package>
</pre>
and fill it in:
<pre>
<package name="merpad">
 
  <title>MerPad Example</title>
 
  <description>
A Mer version of Maemopad.
Built on OBS by David.
  </description>
 
  <person role="maintainer" userid="username"/>
  <person role="bugowner" userid="username"/>
  <url>PUT_UPSTREAM_URL_HERE</url>
</package>

[edit] Uploading Source

[edit] Uploading Source : WWW

From your Home Project, you should see a "merpad" entry under Packages. Select merpad to go to the Package page (you may already be there if you just created it).

Now click [Add File] and upload the tar.gz and then do it again for the dsc files.

Use these files:

 http://www.dgreaves.com/pub/merpad_1.0-1.dsc
 http://www.dgreaves.com/pub/merpad_1.0-1.tar.gz

[edit] Uploading Source : CLI

To get a local (empty) copy make sure you're at your obs root (eg ~/maemo/Mer/obs)

Then run

osc co home:<username>/merpad

(If you were already in ~/maemo/Mer/obs then co merpad would work.. beware, nothing stops you checking out a project inside a project!)

This makes a package directory so now you can:

cd home:<username>/<package>

Once there you can copy in the tarball and dsc file from your application... or in this tutorial we'll get them from the web.

wget   http://www.dgreaves.com/pub/merpad_1.0-1.dsc
wget   http://www.dgreaves.com/pub/merpad_1.0-1.tar.gz

Then add them to version control

osc addremove

The addremove command is a shortcut... it removes any files from OBS that are no longer in the directory and then adds any that are there. Typically you just delete old tarballs and dsc files and run osc addremove. If you prefer osc has an explicit add command.

Now they are ready to be uploaded or comitted:

osc commit

This will send the source and dsc to the builder and trigger a build.

[edit] Monitoring the Build

The OBS builder will now schedule and build the application.

Please note that for security reasons the builder is running inside an emulator which is 'killed' when it is finished; so there are alarming messages like Kernel panic - not syncing: Attempted to kill init! and some qemu: Unsupported syscall messages. These can safely be ignored and will be cleaned up one day.

[edit] Following the build log : WWW

In the package page under the build target is a [Build Log] entry. This takes you to a page showing the build log. There are tickboxes to refresh automatically and to autoscroll.

[edit] Following the build log : CLI

To watch what is going on on the cli:

osc buildlog MerExtrasStable_MerStable_Ubuntu_9.04 armv5el

This does something like a "tail -f" of the builder.

Tip: If you can't recall what the names of the targets are then:

 osc repos

will tell you.

[edit] Downloading the Binaries

Once OBS has run you can download the binaries and install them by hand.

[edit] Getting the binaries : WWW

In the build status is a link to the .deb file. Notice this is an https link and you need to be logged-in.

[edit] Getting the binaries : CLI

Simply run:

 osc getbinaries MerExtrasStable_MerStable_Ubuntu_9.04 armv5el

in the package directory.

[edit] Using your repository

OBS takes a while (up to several hours if busy) to publish and update repositories; however once it is done the final (optional) step is to add an entry to your tablet to use the OBS repository for your project.

Create a file called /etc/apt/sources.list.d/MyOBS.list and add the following line (using your name):

 deb http://download.opensuse.org/repositories/home:/yourname/MerExtrasStable_MerStable_Ubuntu_9.04/ /

Then running the application manager should show your MerPad.

[edit] Local Builds

OBS lets you run a local build on your desktop.

Simply checkout a package:

 osc co home:username/merpad

and run:

 cd home:username/merpad
 osc build MerExtrasStable_MerStable_Ubuntu_9.04 armv5el merpad_1.0-1.dsc

Then wait...

This goes to the server to determine where to get the build-depends (remember the build-target stack) and then downloads them to a local cache. Eventually it installs a bootstrap set to a directory and then does a qemu chroot into it and builds the package.

Note that the following 2 python modules may be required

apt-get install python-m2crypto
apt-get install python-urlgrabber

Once it is done you should get a line telling you where the deb is:

 /scratch3/maemo/Mer/obs/build-MerExtrasStable_MerStable_Ubuntu_9.04-armv5el-merpad/usr/src/packages/DEBS/merpad_1.0-1_armel.deb

It will ask for a password at one stage. You can use your local root password for this. If you get an error complaining about a lack of /usr/lib/common_functions, then create a folder in your home folder, cd into it, and then follow the instructions HERE . they should ask you to run the command

 git clone git://gitorious.org/mer/build.git 

in that folder. This will use git to download a newer 'build' tool for you. See the pageafter it has finished, run make install to install the tool, and then go back and run the osc build step again. It should continue from the password prompt step successfully this time.


You can also do:

 sudo chroot /scratch3/maemo/Mer/obs/build-MerExtrasStable_MerStable_Ubuntu_9.04-armv5el-merpad/ su abuild

and once there, run arm commands inside the chroot.

[edit] Co-existing with Scratchbox

If you use the OBS local build facility and the scratchbox-1 local builder then you need to know how to teach the two emulators how to co-exist.

Both OBS and Scratchbox use binfmt_misc to cause the kernel to invoke (in our case) qemu when it comes across an armel binary.

To disable qemu and enable sbox

 echo 0 > /proc/sys/fs/binfmt_misc/arm
 echo 0 > /proc/sys/fs/binfmt_misc/armeb
 echo 1 > /proc/sys/fs/binfmt_misc/sbox-arm
 echo 1 > /proc/sys/fs/binfmt_misc/sbox-armeb

To disable sbox and enable arm

 echo 1 > /proc/sys/fs/binfmt_misc/arm
 echo 1 > /proc/sys/fs/binfmt_misc/armeb
 echo 0 > /proc/sys/fs/binfmt_misc/sbox-arm
 echo 0 > /proc/sys/fs/binfmt_misc/sbox-armeb

Don't do this whilst a build is in progress!

Note that you may need to run :

 qemu-binfmt-conf.sh

to register qemu to handle arm binaries

A typical error signifying you have this issue is

 Exec format error

which means the kernel doesn't understand the binary format of the executable.