#!/usr/bin/env bash # # Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file # for details. All rights reserved. Use of this source code is governed by a # BSD-style license that can be found in the LICENSE file. # # Script to create a Debian wheezy chroot environment for building Dart # Debian packages. # proc usage { setglobal USAGE = ""Usage: $0 i386|amd64 [target dir] [be|dev|]]\n \n The first mandatory argument speciifies the CPU architecture using\n the Debian convention (e.g. i386 and amd64).\n \n The second optional argument specifies the destination\n directory. This defaults to 'debian_'.\n \n The third optional argument specifies whether the chroot is\n populated with a Dart checkout. Use 'be' for bleeding edge, 'dev'\n for trunk/developer or the specific version number for a stable\n version (e.g. 1.2)."" echo -e $USAGE exit 1 } # Expect one to three arguments, architecture, optional directory and # optional channel. if test $Argc -lt 1 || test $Argc -gt 3 { usage } setglobal ARCH = $1 if test -n $2 { setglobal CHROOT = $2 } else { setglobal CHROOT = "debian_$ARCH" } if test -n $3 { setglobal CHANNEL = $3 } if test $ARCH != "i386" && test $ARCH != "amd64" { usage } setglobal SVN_REPRO = '"http://dart.googlecode.com/svn/'" if test -n $CHANNEL { if test $CHANNEL == "be" { setglobal SVN_PATH = '"branches/bleeding_edge/deps/all.deps'" } elif test $CHANNEL == "dev" { setglobal SVN_PATH = '"trunk/deps/all.deps'" } else { setglobal SVN_PATH = ""branches/$CHANNEL/deps/all.deps"" } setglobal SRC_URI = "$SVN_REPRO$SVN_PATH" } # Create Debian wheezy chroot. debootstrap --arch=$ARCH --components=main,restricted,universe,multiverse \ wheezy $CHROOT http://http.us.debian.org/debian/ chroot $CHROOT apt-get update chroot $CHROOT apt-get -y install \ debhelper python git gcc sudo make # Add chrome-bot user. chroot $CHROOT groupadd --gid 1001 chrome-bot chroot $CHROOT useradd --gid 1001 --uid 1001 --create-home chrome-bot mkdir $CHROOT/b chown 1001:1001 $CHROOT/b # Create trampoline script for running the initialization as chrome-bot. cat << """ > $CHROOT/b/init_chroot_trampoline.sh #!/bin/sh su -c /b/init_chroot.sh chrome-bot """ > $CHROOT/b/init_chroot_trampoline.sh #!/bin/sh su -c /b/init_chroot.sh chrome-bot EOF # Create initialization script which does nothing. cat << ''' > $CHROOT/b/init_chroot.sh #!/bin/sh cd /b ''' > $CHROOT/b/init_chroot.sh #!/bin/sh cd /b EOF # If the channel is set extend the initialization script to check out # the Dart sources. This uses two cat commands as the first part needs # to bypass variable interpretation. if test -n $SRC_URI { cat << ''' >> $CHROOT/b/init_chroot.sh git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git export PATH=$PATH:/b/depot_tools ''' >> $CHROOT/b/init_chroot.sh git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git export PATH=$PATH:/b/depot_tools EOF cat << """ >> $CHROOT/b/init_chroot.sh gclient config $SRC_URI gclient sync gclient runhooks """ >> $CHROOT/b/init_chroot.sh gclient config $SRC_URI gclient sync gclient runhooks EOF } chmod 755 $CHROOT/b/init_chroot_trampoline.sh chown 1001:1001 $CHROOT/b/init_chroot.sh chmod 755 $CHROOT/b/init_chroot.sh chroot $CHROOT /bin/sh /b/init_chroot_trampoline.sh