Meego Wiki
Views
From MeeGo wiki
< ARM(Difference between revisions)
Jump to: navigation, search
(Initial content)
(Creating the chroot)
 
(2 intermediate revisions not shown)
Line 26: Line 26:
  # FIXME: this doesn't work, one way is to branch the package to your OBS home project, add a repository and then build it.
  # FIXME: this doesn't work, one way is to branch the package to your OBS home project, add a repository and then build it.
  cd /tmp
  cd /tmp
-
  osc checkout MeeGo.com:MeeGo:1.2:oss zypper
+
  osc -A OSBHOST co MeeGo.com:MeeGo:1.2:oss zypper
  cd MeeGo.com:MeeGo:1.2:oss/zypper
  cd MeeGo.com:MeeGo:1.2:oss/zypper
-
  osc build --root=/tmp/meego-1.2-armv7hl -x vim -x openssh-clients -x git -x zypper --no-verify standard armv8el zypper.spec  
+
  osc build --root=/tmp/meego-1.2-armv7hl -x vim -x openssh-clients -x git -x iputils -x zypper --no-verify standard armv8el zypper.spec  
The ''-x'' option includes extra packages to the chroot.
The ''-x'' option includes extra packages to the chroot.
Line 59: Line 59:
  sudo mic-chroot --bind-mounts=\$HOME:\$HOME /tmp/meego-1.2-armv7hl
  sudo mic-chroot --bind-mounts=\$HOME:\$HOME /tmp/meego-1.2-armv7hl
 +
 +
WARNING!!! If you use --bind-mounts NEVER USE "rm -r /tmp/CHROOTmeego" that will remove your $HOME too, USE mic-rm-chroot-dir instead.
The first things to do is to add the needed MeeGo ARM ARMv7hl repositories and install the needed dependencies. E.g. to install the basic Qt dependencies, run the following commands:
The first things to do is to add the needed MeeGo ARM ARMv7hl repositories and install the needed dependencies. E.g. to install the basic Qt dependencies, run the following commands:
Line 70: Line 72:
  su - <user account>
  su - <user account>
  # FIXME: Include instructions to compile an ARM hello world and verify that it compiles and runs.
  # FIXME: Include instructions to compile an ARM hello world and verify that it compiles and runs.
-
 
== Current known issues ==
== Current known issues ==

Latest revision as of 13:08, 12 August 2011

This page describes how to create a chroot for ARMv7 to be used on a normal desktop Linux.

Contents

Introduction

For background information, you may check my blog post about the chroot.

Chroot is a convenient way to get an alternate root filesystem inside your native Linux distribution, e.g. MeeGo inside Ubuntu. This allows you to e.g. compile MeeGo packages inside your desktop Linux using your fast workstation CPU and memory.

The downside is, you need to have a matching CPU for both the desktop Linux and the MeeGo running in the chroot. Obviously this is a problem when you are targetting ARM architecture.

For ARM there has been several solutions but not so many native like environments. By "native like" I mean an environment, where you can run gcc without extra parameters and you get a native ARM binary, that you even can run after compiling. Scratchbox is such an environment but many dislike it because it has it's own problems. QEMU in system mode emulation also provides a native like environment but emulating everything is slow.

OBS actually uses similar approach that Scratchbox: Most of the binaries in a chroot are ARM binaries emulated with QEMU but the most time consuming components during a building of packages are actually X86 binaries. These components include e.g. bash, cross compilers and bzip2.

Luckily it's possible to use the OBS command line client tool, osc, to build components locally in a chroot. This page describes how to take that chroot and turn it into a standalone chroot independent of OBS. It can still use the official MeeGo ARM RPM repositories.

Creating the chroot

Creating the chroot needs an OBS account and it's created by building practically any package using the osc command line tool. I wanted to create a relatively small chroot for easier distribution so I tried to select a package without too many dependencies and I ended up selecting zypper.

Note that you may need really new build package. That's meant for building RPM packages and it's not privided by Debian nor Ubuntu but it's available from OpenSUSE OBS.


You can checkout and compile locally the zypper as follows (assuming you have already working MeeGo community OBS account set up):

# FIXME: this doesn't work, one way is to branch the package to your OBS home project, add a repository and then build it.
cd /tmp
osc -A OSBHOST co MeeGo.com:MeeGo:1.2:oss zypper
cd MeeGo.com:MeeGo:1.2:oss/zypper
osc build --root=/tmp/meego-1.2-armv7hl -x vim -x openssh-clients -x git -x iputils -x zypper --no-verify standard armv8el zypper.spec 

The -x option includes extra packages to the chroot.

Cleaning up the chroot

The newly created chroot contains a user abuild that's used for building the packages and all the zypper sources and built binaries which won't be ever actually needed. The chroot contains also a lot of localisation files, extra QEMU binaries and documentation that are not neccessarily needed and removing those makes it a bit more convenient to distribute.

I've used a small script (see the bottom of the page) to clean up the chroot after chowning it to my user account:

cd /tmp
sudo chown $USER.$USER -R /tmp/meego-1.2-armv7hl
/path/to/meego-chroot-cleanup.sh /tmp/meego-1.2-armv7hl

Preparing the chroot for usage

The chroot is now working to some extent but there are few things that should be done before taking the chroot into use.

The RPM package database files must be removed as they are broken (at least when the chroot is created with non-RPM distribution like Debian or Ubuntu). The RPM binary in the chroot is ARM binary and it must be swapped with the X86 version which is fortunately included in the chroot. Also the RPM and the zypper tools must be forced to use armv7hl architecture.

For conveniency the normal user account can be added to the chroot to allow using the same files inside and outside the chroot with the same user account.

I've used a small script (see the bottom of the page) also for that:

/path/to/chroot_run_me_first.sh /tmp/meego-1.2-armv7hl

Using the chroot

Now the chroot is usable. I recommend using mic-chroot for chrooting inside the chroot as that handles the bind mounts and umounts conveniently. The following command chroots inside the directory as root and bind mounts your home directory inside it:

sudo mic-chroot --bind-mounts=\$HOME:\$HOME /tmp/meego-1.2-armv7hl
WARNING!!! If you use --bind-mounts NEVER USE "rm -r /tmp/CHROOTmeego" that will remove your $HOME too, USE mic-rm-chroot-dir instead.

The first things to do is to add the needed MeeGo ARM ARMv7hl repositories and install the needed dependencies. E.g. to install the basic Qt dependencies, run the following commands:

zypper addrepo --refresh http://repo.meego.com/MeeGo/builds/1.2.0.90/latest/repos/oss/armv7hl/packages/ oss
zypper refresh
zypper install libqt-devel

Now you can switch to the normal user account and build your projects:

su - <user account>
# FIXME: Include instructions to compile an ARM hello world and verify that it compiles and runs.

Current known issues

  • Zypper doesn’t find noarch packages (this is an upstream bug, not cause by these instructions).
  • Tested only on Debian Squeeze. At some point there was a linker issue on Ubuntu and I don’t know if that still exists.

Download

Both the scripts used to clean up and prepare the chroot and the ready made chroot as a tarball are available in the locations mentioned below.

Scripts

The scripts can be cloned from my git repository with:

git clone http://git.pingu.fi/meego-chroot

Chroot binaries

If you want to try it out, it’s available via BitTorrent at http://tuomas.kulve.fi/tmp/torrent/ (temporary location). After extracting the tarball, see the readme file in the root directory.

The tar ball is available only through BitTorrent to hopefully distribute the network bandwidth a bit.

Personal tools