Re: fakechroot + qemu user emulation
On Sat, Jan 22, 2011, Roger Leigh wrote:
> BTW, now all the work on schroot for squeeze is done, I just set up a
> 1.5.0 development release on the schroot master branch, and I'll look
> at getting your patch merged as soon as I find time.
Awesome; I'ved fixed a couple of bugs in my local version (attached),
but still didn't implement support for script config
# Copyright (C) 2010 Loïc Minier <email@example.com>
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# SOFTWARE IN THE PUBLIC INTEREST, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
# Except as contained in this notice, the name of the author shall not be used
# in advertising or otherwise to promote the sale, use or other dealings in
# this Software without prior written authorization from the author.
# depends: file, qemu-user-static | qemu-kvm-extras
# - allow setting the qemu interpreter in the script-config file
# - allow forcing use of qemu even when not particularly needed
# - test support for all architectures
# - add support for more architectures
# - add more biarch cases
if [ "$STAGE" != "setup-start" ]; then
info "Stage isn't setup-start; skipping $self"
# outputs QEMU architecture name for specified ELF file; returns 0 on success
# and 1 on failure
if ! which file >/dev/null; then
warn "You need \"file\" to use $self"
if ! output="$(LC_ALL=C file -b "$file")"; then
warn "Couldn't run \"file -b $file\""
case "$output" in
"ELF 32-bit LSB executable, ARM,"*|"ELF 32-bit LSB shared object, ARM,"*)
"ELF 32-bit LSB executable, Intel 80386,"*|"ELF 32-bit LSB shared object, Intel 80386,"*)
"ELF 32-bit LSB executable, MIPS,"*|"ELF 32-bit LSB shared object, MIPS,"*)
"ELF 32-bit MSB executable, MIPS,"*|"ELF 32-bit MSB shared object,"*)
"ELF 32-bit MSB executable, SPARC32PLUS,"*|"ELF 32-bit MSB shared object, SPARC32PLUS,"*)
# XXX or is it just sparc?
"ELF 32-bit MSB shared object, PowerPC "*|"ELF 32-bit MSB executable, PowerPC "*)
"ELF 64-bit LSB executable, Alpha "*|"ELF 64-bit LSB shared object, Alpha "*)
"ELF 64-bit LSB executable, x86-64,"*|"ELF 64-bit LSB shared object, x86-64,"*)
warn "Unrecognized file output \"$output\""
if ! system_arch="$(get_arch /bin/true)"; then
warn "Couldn't identify host architecture; skipping $self"
if ! chroot_arch="$(get_arch "$CHROOT_PATH/bin/true")"; then
warn "Couldn't identify chroot architecture; skipping $self"
# skip cases where system_arch is the same as chroot_arch, and cases supported
# by biarch
if [ "$system_arch" = "$chroot_arch" ]; then
info "qemu not needed (chroot for same architecture as the system); skipping $self"
case "$system_arch:$chroot_arch" in
info "qemu not needed (biarch); skipping $self"
if ! qemu="$(which qemu-$chroot_arch-static)"; then
warn "Couldn't find qemu-$chroot_arch-static; skipping $self"
mkdir -p "$CHROOT_PATH/usr/bin/"
cp -f "$qemu" "$CHROOT_PATH/usr/bin/"