Difference between revisions of "Running glibc programs"

From Alpine Linux
Jump to: navigation, search
(How to set up a 32bit chroot with glibc under Alpine)
 
(Using Busybox)
Line 28: Line 28:
 
===Using Busybox===
 
===Using Busybox===
 
First we need to download busybox.You can choose any of your favourit distros to download a prebuild version.I for instance would use Archlinux packages from http://www.archlinux.org/packages/community/i686/busybox/.<br>
 
First we need to download busybox.You can choose any of your favourit distros to download a prebuild version.I for instance would use Archlinux packages from http://www.archlinux.org/packages/community/i686/busybox/.<br>
  wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.tar.xz
+
  wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz
 +
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz
 +
for i in *.pkg.tar.xz;do
 +
bsdtar xfJ $i -C ~/chroot
 +
done
 
  mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}
 
  mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}
bsdtar xfJ busybox.tar.xz -C ~/chroot
 
rm busybox.tar.xz
 
 
  ln -s /bin/busybox ~/chroot/bin/sh
 
  ln -s /bin/busybox ~/chroot/bin/sh
 
  ln -s /bin/busybox ~/chroot/bin/ln
 
  ln -s /bin/busybox ~/chroot/bin/ln

Revision as of 16:47, 29 January 2012

This is a draft

If you want to run glibc programs under alpine there are a few ways to do so.You could install glibc additional to uclibc (you would have to do this manualy) or you could do the easy way and use a chroot.
Because there are different usecases I want to give a slight overview about what's possible and what is intelligent.

Your options

Using Busybox

First the most simple approach for setting up a chroot is using a glibc build of busybox.
This approach has just a few downsides:
- You have to link most /bin/ and /usr/bin program against /bin/busybox and some busybox builds break if you don't configure it right.
- You have to manually download every library you need for your program manually.

But if you want a small enviroment for one simple use case this is the solution you want.

Using a livecd

If you prefer any special distri you can always download and extract a livecd and use it as a chroot enviroment.

Using a stage3 gentoo archive

This is the fastest approach and you have the advantage of controlling which package version of which library you will install.
Drawbacks are as follow:
- Big build.You have to install a portage tree which uses up a lot of space.(It's not 100% necessary if you don't have to install any additional content you don't need it)
- On slow mashines not recommended because you have to compile your packages.

Using Archlinux or Debian

If you want a nice running system you can install Arch or Debian in a chroot.This approach isn't as easily executed as the other alternatives, but are in my opinion the cleanest and most recommended for the every day user.

How to do it

Like I said this is just a quick draft so here it comes.

Using Busybox

First we need to download busybox.You can choose any of your favourit distros to download a prebuild version.I for instance would use Archlinux packages from http://www.archlinux.org/packages/community/i686/busybox/.

wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz
for i in *.pkg.tar.xz;do
bsdtar xfJ $i -C ~/chroot
done
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}
ln -s /bin/busybox ~/chroot/bin/sh
ln -s /bin/busybox ~/chroot/bin/ln
sudo chroot ~/chroot/ /bin/sh

This creates a simple chroot enviroment which we will expand through all commands included in busybox.

for i in $(busybox --list);do ln -s /bin/busybox /usr/bin/$i;done

Using a livecd

WIP

Using a stage3 tar archive

Select a mirror from http://www.gentoo.org/main/en/mirrors2.xml , switch to /releases/x86/current-stage3/ and download the latest tar ball (for me stage3-i686-20120124.tar.bz2 ).

wget http://de-mirror.org/gentoo/releases/x86/current-stage3/stage3-i686-20120124.tar.bz2
mkdir ~/chroot
tar xfj stage3-i686-*.tar.bz2 -C ~/chroot
sudo chroot ~/chroot

And voila you got your working gentoo chroot.
You can now take a look at http://www.gentoo.org/doc/en/?catid=desktop to find out how you can configure and install your system or simply extract/copy the program you need to run in your chroot enviroment and execute it.

Using Archlinux or Debian

WIP

Example

Here will be an example of how to use a chroot.