Meego Wiki
Views

Developing in a MeeGo Environment

From MeeGo wiki
(Difference between revisions)
Jump to: navigation, search
m (Meego->MeeGo)
Line 98: Line 98:
Provided the build completed without errors, you can now see the resulting rpms in ~/rpmbuild/RPMS/. You can transfer these back to your filesystem through the /parentroot directory and you can then transfer these to your MeeGo device, virtual machine, etc and install them there.
Provided the build completed without errors, you can now see the resulting rpms in ~/rpmbuild/RPMS/. You can transfer these back to your filesystem through the /parentroot directory and you can then transfer these to your MeeGo device, virtual machine, etc and install them there.
 +
 +
== Building your package using build ==
 +
 +
A more convenient package build way is to use 'build' which is a project from OpenSUSE, MeeGo build infrastructure used it.
 +
 +
You can get build binary package from http://repo.mobile-central.org/live/devel:/tools:/building/ per your Linux distribution, if your Linux distribution isn't there, you can get build source package to build it yourself manually.
 +
 +
After you install it ( I suppose you know how to install a package on your Linux), you can run “build –help” to get help info.
 +
 +
You must run build as root. If your network needs proxy, please export proxy environment variables, for example:
 +
 +
export http_proxy=http://proxy.yourcompany.com:port/
 +
export no_proxy=localhost,127.0.0.0/8,.yourcompany.com
 +
 +
If you used to run “sudo build …” and your network needs proxy, please ensure sudo to inherit proxy environment variables, you can do this by adding the below line to /etc/sudoers
 +
 +
Defaults    env_keep += "http_proxy no_proxy HTTP_PROXY NO_PROXY"
 +
 +
<pre>
 +
build --repository http://repo.meego.com/MeeGo/devel/trunk/repo/ia32/os/ --arch i686 cpio-2.11-1.2.src.rpm
 +
</pre>
 +
 +
This command will build a cpio binary package for MeeGo. Optionally, you also can use spec file to build it, for this case, build will find your source tar ball and patches under current work dir.
 +
 +
<pre>
 +
build --repository http://repo.meego.com/MeeGo/devel/trunk/repo/ia32/os/ --arch i686 cpio.spec
 +
</pre>
 +
 +
build will base your repo URL to cache your repo, so please use the same URL string for the same repo every time (URL with / at the end of it and the same URL without / at the end of it will result in different cache dirs), you can use multiple --repository options to specify multiple repos, for example:
 +
 +
# build --repository http://repo.meego.com/MeeGo/devel/trunk/repo/ia32/os/ --repository http://repo.meego.com/.mEeGo/devel/netbook/repo/ia32/os/ --arch i686 moblin-panel-applications-0.1.20-1.1.src.rpm
 +
 +
The default cache dir is /var/cache/build, you can use option –cachedir to set to other dir.
 +
 +
The default BUILDROOT dir is /var/tmp/build-root, you can use --root option to specify one more dir, once build is done, you can get your binary package in BUILDROOT, for example:
 +
 +
<pre>
 +
...
 +
Wrote: /home/abuild/rpmbuild/SRPMS/cpio-2.10-1.meego.src.rpm
 +
Wrote: /home/abuild/rpmbuild/RPMS/i586/cpio-2.10-1.meego.i586.rpm
 +
Wrote: /home/abuild/rpmbuild/RPMS/i586/cpio-debuginfo-2.10-1.meego.i586.rpm
 +
...
 +
</pre>
 +
 +
Your cpio binary package is /var/tmp/build-root/home/abuild/rpmbuild/RPMS/i586/cpio-2.10-1.meego.i586.rpm
 +
== Including your packages in a MeeGo image ==
== Including your packages in a MeeGo image ==

Revision as of 03:07, 21 April 2010

Contents

Introduction

This guide is a way to build packages for the MeeGo 'day one' release, before more proper developer tools are introduced.

Setting up your development environment

In order to begin developing for the MeeGo 'day one' release, you will need to follow these steps:

Introducing the tools

mic-chroot

mic-chroot is a tool that allows you to 'chroot' into an existing MeeGo image in order to develop within it, without contaminating your developer machine's environment. Chroot simply means to 'change the root' to a new location (so instead of your root being / on your dev machine, it will be the new root directory within the image).

This restricts access to your real root and your real file system, and instead, uses the image filesystem as its root and filesystem. No contamination, and no effect on your development machine.

With mic-chroot, you will effectively be able to modify and manipulate the image's filesystem as if you were running a shell within an installed image, without having to install the image. When finished, you can also create a new MeeGo image based on your changes.

Developer images

The developer images contain the exact same packages as is installed when you try to build a package in the MeeGo OBS without any dependencies, along with some helper packages (vim, nano) to make chroot usage easier. The list of these packages can be seen in the kickstart file mentioned above.

This is because it will in the end save you time when you want to upload your application into a builder system because it will make sure that you specify your package build dependencies correctly.

You can in the development image chroot run 'yum install <package names>' and that way install your package build dependencies to the chroot in order to compile your package.

Building your package: Step by step

Prerequisites:

  • It is assumed you have already made either a source rpm (.src.rpm) or a package (.spec and attached files) before these steps. For a guide how to create packaging for MeeGo, see Packaging
  • You have already chosen an architecture to build your package towards in these steps. That is the development image <image-name>, either meego-codedrop-ia32*.img (X86) or meego-codedrop-arm*.img (ARM)

Step 1: Chrooting into the development image

sudo mic-chroot <image-name>

With this command, you are now transported into the root filesystem of the image. It is possible to exchange files with your normal file system through the /parentroot directory. You can also conduct yum install, yum remove and any other network related operations.

Step 2: Setting up the build directories

You only need to do this once, but you may want to clean up the directory and remake it once in a while.

mkdir -p ~/rpmbuild
cd ~/rpmbuild
mkdir -p SOURCES SPECS BUILD RPMS SRPMS

Step 3: Staging source package for build

You must change directory to the location of your sources.

cd /parentroot/path/to/your/sources

If you have a source rpm (.src.rpm), you will need to extract it:

rpm2cpio <MyPkg>.src.rpm | cpio -idmv --no-absolute-filenames 

This will result in a .spec file and maybe some attached files (patches, source tarball, etc). The .spec file is in this guide called package.spec.

When you have a .spec file you need to place it in ~/rpmbuild/SPECS and the remaining files in ~/rpmbuild/SOURCES.

Step 4: Installing your build dependencies

You can see your build dependencies in the package.spec file, which is the lines starting with BuildRequires. Those packages can then be installed using 'yum install':

yum install <package names>

Step 5: Building your package

To build your package, you must then run the following command, where package.spec is the name of your spec file:

rpmbuild -ba ~/rpmbuild/SPECS/package.spec 

Step 6: Enjoying your built package

Provided the build completed without errors, you can now see the resulting rpms in ~/rpmbuild/RPMS/. You can transfer these back to your filesystem through the /parentroot directory and you can then transfer these to your MeeGo device, virtual machine, etc and install them there.

Building your package using build

A more convenient package build way is to use 'build' which is a project from OpenSUSE, MeeGo build infrastructure used it.

You can get build binary package from http://repo.mobile-central.org/live/devel:/tools:/building/ per your Linux distribution, if your Linux distribution isn't there, you can get build source package to build it yourself manually.

After you install it ( I suppose you know how to install a package on your Linux), you can run “build –help” to get help info.

You must run build as root. If your network needs proxy, please export proxy environment variables, for example:

export http_proxy=http://proxy.yourcompany.com:port/ export no_proxy=localhost,127.0.0.0/8,.yourcompany.com

If you used to run “sudo build …” and your network needs proxy, please ensure sudo to inherit proxy environment variables, you can do this by adding the below line to /etc/sudoers

Defaults env_keep += "http_proxy no_proxy HTTP_PROXY NO_PROXY"

build --repository http://repo.meego.com/MeeGo/devel/trunk/repo/ia32/os/ --arch i686 cpio-2.11-1.2.src.rpm

This command will build a cpio binary package for MeeGo. Optionally, you also can use spec file to build it, for this case, build will find your source tar ball and patches under current work dir.

build --repository http://repo.meego.com/MeeGo/devel/trunk/repo/ia32/os/ --arch i686 cpio.spec

build will base your repo URL to cache your repo, so please use the same URL string for the same repo every time (URL with / at the end of it and the same URL without / at the end of it will result in different cache dirs), you can use multiple --repository options to specify multiple repos, for example:

  1. build --repository http://repo.meego.com/MeeGo/devel/trunk/repo/ia32/os/ --repository http://repo.meego.com/.mEeGo/devel/netbook/repo/ia32/os/ --arch i686 moblin-panel-applications-0.1.20-1.1.src.rpm

The default cache dir is /var/cache/build, you can use option –cachedir to set to other dir.

The default BUILDROOT dir is /var/tmp/build-root, you can use --root option to specify one more dir, once build is done, you can get your binary package in BUILDROOT, for example:

...
Wrote: /home/abuild/rpmbuild/SRPMS/cpio-2.10-1.meego.src.rpm
Wrote: /home/abuild/rpmbuild/RPMS/i586/cpio-2.10-1.meego.i586.rpm
Wrote: /home/abuild/rpmbuild/RPMS/i586/cpio-debuginfo-2.10-1.meego.i586.rpm
...

Your cpio binary package is /var/tmp/build-root/home/abuild/rpmbuild/RPMS/i586/cpio-2.10-1.meego.i586.rpm


Including your packages in a MeeGo image

Before reading these sections, we suggest to first read Image Creation For Beginners and Image Creation

This will give you the basics of what you need to generate a basic MeeGo image.

Specifically, there are important details about how to modify a .ks file here: Image_Creation#Modifying_your_.ks

KickStart .ks files are the main configuration file that the Image Creator uses to create images, and the brunt of what is talked about in this section has to do with modifying your .ks file.

Recreating a standard MeeGo Image

To create a standard MeeGo image, please follow the instructions in Image Creation For Beginners.

Adding more MeeGo packages to a MeeGo Image

Here is a scenario where you want to add additional MeeGo packages to the standard MeeGo image.

First obtain a standard MeeGo .ks file from here

Check the MeeGo repos and make sure that the packages you're looking doesn't already exist in MeeGo

Now within the .ks file, add the MeeGo package names that you want included in this new image. For more on how add packages in a .ks file, please read this important section here: Image_Creation#Modifying_your_.ks

Run this modified .ks file through the Image Creator MIC.

sudo mic-image-creator -c my-new-ks.ks -f livecd

For more options and details on image creation and MIC, go here: Image_Creation

Your new image will now be a standard MeeGo image including the new packages you've added.

Again, this wiki is of great value to you when manipulating and navigating through .ks files: Image_Creation#Modifying_your_.ks It is the key to mastering the art of creating custom-made MeeGo images.

Adding your own code & and non-MeeGo packages to a MeeGo Image

If you have your own packages on your developer machine that you want to test out by creating a new MeeGo image with them.

First obtain a standard MeeGo .ks file. This is possible through the repository.

To add a new repo to your .ks file, go here for easy and detailed steps: Image_Creation#Modifying_your_.ks

Once you add the new repo(s) that the Image Creator will pull from, you now have to list the packages you want to pull down from these repos. For instructions on adding packages to your .ks file, go here: Image_Creation#Modifying_your_.ks

If you have local rpms on your local machine that you would like to include, you need to first create a local repo on your machine. Move your rpms into a directory. Then create a local repo with that directory like so:

$ mv *.rpms /home/user/my-local-repo

$ createrepo -d /home/user/my-local-repo

This turns /home/user/my-local-repo into a local repository that you can point your .ks file to. For steps on how to add a new repo, go here: Image_Creation#Modifying_your_.ks

And again, make sure you have listed in your .ks all the packages you would like to include in your new MeeGo Image.

Now, simply run this new .ks file through MIC, the Image Creator.

sudo mic-image-creator -c my-new-ks.ks -f livecd

For more options and details on image creation and MIC, go here: Image_Creation

Your new image will now be a standard MeeGo image including the new packages and repos you've added.

Again, this wiki is of great value to you when manipulating and navigating through .ks files: Image_Creation#Modifying_your_.ks It is the key to mastering the art of creating custom-made MeeGo images.

Troubleshooting (ARM)

Error: chroot: cannot run command X: No such file or directory

Most likely cause: You have Scratchbox1 installed and you need to follow instructions given in Prerequisites for ARM.

Exec format error

Most likely cause: You have not run qemu-binfmt-misc.sh as root.

mmap: permission denied

Most likely cause: VDSO

Do this as root:

echo 0 > /proc/sys/vm/vdso_enabled
echo 4096 > /proc/sys/vm/mmap_min_addr
Personal tools