On Thu, Nov 11, 2010, Guilherme Salgado wrote:
> > In fact reading that work thing you seem to be wanting to build
> > exactly what I want to build: a system that repeatably builds
> > packages in pristine chroots. I thought sbuild didn't normally do the
> > pristine chroot thing? (which is why I've been using pbuilder to
> > supply that functionality to date).
> 
> Yeah, I don't think sbuild itself provides that, so I'm using schroot's
> type=file chroots for that.  You just point schroot to a tarball
> containing your chroot and it will (by default) create a new session
> (with a pristine chroot) every time you 'schroot -c <name>'.  If you
> want to change the contents of the tarball you can easily do that with
> 'schroot -c <name>-source'.  All you need for that to work is the
> following config:
> 
>         [natty]
>         description=Natty chroot
>         type=file
>         file=/var/chroots/natty.tar
>         location=/natty

 Seems it's actually on topic, I'd love sharing my setup!  :-)

 To setup, I use this schroot.conf snippet:
    [natty]
    type=file
    description=Ubuntu natty
    root-users=lool
    file=/srv/schroot/chroot-ubuntu-natty-amd64.tar.bz2
    location=/chroot-autobuild
    preserve-environment=true

 /srv/schroot/chroot-ubuntu-natty-amd64.tar.bz2 is the chroot used on
 Launchpad buildds for natty/amd64.  I'm attaching dl-lp-chroot which
 downloads such a chroot; it's a trivial wrapper around
 https://launchpad.net/api/devel/ubuntu/$dist/$arch/chroot_url URLs


 To use, I then do something like:
    mkdir ~/xdeb-dpkg
    cd ~/xdeb-dpkg
    schroot-xdeb --apt-source --only-explicit dpkg -aarmel

 (the above are just whatever xdeb args I'd like to use)

 schroot-xdeb will install xdeb and a cross-toolchain; it's sadly
 hardcodes my local mirror, but could obviously be adapted

 I should probably implement a feature to wait for confirmation before
 destroying the temporary chroot on failure.

PS: the above run will fail because xdeb doesn't import selinux for some
    reason; but it does illustrate things quite well here  :-)
-- 
Loïc Minier
#!/bin/sh
# dl-lp-chroot - download a chroot tarball from Launchpad
# Copyright (C) 2010 Loïc Minier <l...@dooz.org>
#
# 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: wget

set -e

self="$(basename "$0")"
arch="`dpkg --print-architecture`"
dist="`lsb_release -cs`"
output_file=""

usage() {
    echo "Usage: $self [--arch <arch>] [--dist <dist>] [-O output-file]" >&2
}

die() {
    echo "$*" >&2
    exit 1
}

if ! which wget >/dev/null; then
    die "Please install wget"
fi

while [ $# -gt 0 ]; do
    case "$1" in
      --help)
        usage
        exit 0
      ;;
      --arch)
        arch="$2"
        if [ -z "$arch" ]; then
            die "Empty arch argument"
        fi
        shift 2
      ;;
      --dist)
        dist="$2"
        if [ -z "$dist" ]; then
            die "Empty dist argument"
        fi
        shift 2
      ;;
      -O)
        output_file="$2"
        if [ -z "$output_file" ]; then
            die "Empty output file argument"
        fi
        shift 2
      ;;
      *)
        die "Unknown argument $1"
      ;;
    esac
done

chroot_url="`wget -q -O - 
"https://launchpad.net/api/devel/ubuntu/$dist/$arch/chroot_url"; | tr -d '"'`"

exec wget ${output_file:+-O "$output_file"} "$chroot_url"

#!/bin/sh

set -e

dist="natty"
chroot="$dist"
arch="armel"
cross_pkgs="binutils-arm-linux-gnueabi gcc-arm-linux-gnueabi 
g++-arm-linux-gnueabi libc6-armel-cross"

session=""

cleanup() {
    if [ -n "$session" ]; then
        schroot -c "$session" -e
        session=""
    fi
}

export LC_ALL=C

session=`schroot -c "$chroot" -b`

trap "cleanup" 0 1 2 3 9 11 13 15

run_root() {
    schroot -c "$session" -r -u root -- "$@"
}

run() {
    schroot -c "$session" -r -- ""$@
}

run_root tee /etc/apt/sources.list >/dev/null <<EOF
deb     http://mirror.dooz.org/ubuntu/ $dist main restricted universe multiverse
deb-src http://mirror.dooz.org/ubuntu/ $dist main restricted universe multiverse

deb [arch=$arch] http://mirror.dooz.org/ubuntu-ports/ $dist main restricted 
universe multiverse
EOF

run_root apt-get update

# don't need these, and won't work with xdeb (only with
# launchpad-buildd/sbuild)
run_root apt-get -y purge pkg-create-dbgsym pkgbinarymangler
run_root apt-get -y autoremove

run_root apt-get -y install --no-install-recommends xdeb
run_root apt-get -y install --no-install-recommends $cross_pkgs

run_root apt-get clean

# setup password-less sudo
run_root tee -a /etc/sudoers >/dev/null <<EOF
ALL ALL=(ALL) NOPASSWD: ALL
EOF

run xdeb -a "$arch" "$@"

_______________________________________________
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev

Reply via email to