Gentoo Wiki ArchivesGentoo Wiki

HOWTO_AMD64/chroot

Setting up a 32-bit chroot environment

Sometimes a 64-bit environment is required to run 32-bit programs. This can be accomplished by creating a 32-bit chroot in which to run these applications, which involves installing another gentoo installation inside your AMD64 installation.

To create a 32-bit chroot, please see the Offical 32-bit Chroot HOWTO

Accessing the chroot from a normal user: Using dchroot

To run applications installed in chroot as non-priviledged user, install dchroot: emerge -av dchroot

Now add info about your 32-bit chroot location to /etc/dchroot.conf: echo "gentoo32 /mnt/gentoo32" >> /etc/dchroot.conf

Since dchroot can run only scripts (it will complain on running binary files), there is a little workaround.

First, create a script my_app32 under x86_64 gentoo (/usr/bin/my_app should be the path and name of the application you want to run from 32-bit chroot):

File: /usr/local/bin/my_app32
#!/bin/bash
xhost local:localhost
linux32 dchroot -c gentoo32 /usr/local/bin/32run.sh /usr/bin/my_app

Then, create a helper script 32run.sh in 32-bit chroot environment:

File: /mnt/gentoo32/usr/local/bin/32run.sh
#!/bin/sh
exec "$@"

Now, you should be able to start "my_app" compiled in 32-bit chroot environment directly by executing /usr/local/bin/my_app32 in regular x86_64 environment.

If you get an error along the lines of:

Error: Can't open display: 
dchroot: Child exited non-zero.
dchroot: Operation failed.

Then, edit the helper script 32run.sh to specify the display:

File: /mnt/gentoo32/usr/local/bin/32run.sh
#!/bin/sh
export DISPLAY=:0.0
exec "$@"
File: /usr/local/bin/my_app32
xhost local:localhost
linux32 dchroot -c gentoo32 DISPLAY=:0.0 /usr/local/bin/32run.sh /usr/bin/my_app

Compiling Applications in the chroot and Installing them on 64-bit systems

The chroot can now be used to create 32-bit binary packages of any program for the parent 64-bit environment. Note that this method cannot be used for libraries, because of the conflicting /lib and /usr/lib symlinks (on amd64 it points to (/usr)/lib64 and on x86 it points to (/usr)/lib32).

Also note that this method of trying to get programs to work on amd64 is totally unsupported. Please do not file bugs about programs created using this method.

Emerge the package in the chroot with either the buildpkg FEATURES flag enabled in /etc/make.conf or specify the --buildpkgonly flag on the emerge commandline.

To enable the portage buildpkg feature, which will tell portage to create a binary package (the same way quickpkg does) for every package you install, run: echo 'FEATURES="${FEATURES} buildpkg"' >> /etc/make.conf

Alternatively, to just build a binary version of a single package, run: emerge --buildpkgonly <package>

The binary package will be put into /usr/portage/packages. If required, copy it to the same location on the destination system.

To install the package on the destination system, run: emerge --usepkgonly <package>

Note: You could use the --oneshot flag on the emerge command to prevent the package being added to the world file, and thus never have it upgraded to a compield version. However this would mean that the package could not be unmerged using portage.
Retrieved from "http://www.gentoo-wiki.info/HOWTO_AMD64/chroot"

Last modified: Mon, 11 Aug 2008 11:39:00 +1000 Hits: 5,757

Created by NickStallman.net, Luxury Homes Australia
Real estate agents should list their apartments, townhouses and units in Australia.