#!/bin/bash #deb version number suite=saucy chroot=`mktemp -u --tmpdir=/srv` version=0.7.2 set -e if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" 1>&2 exit 1 fi if test -f ${suite}-crosschroot_${version}-2_all.deb; then echo "${suite}-crosschroot-${version}-2.deb already exists - perhaps you wanted to bump version?" read -r -p "Continue and regenerate existing version? [y/N] " a if [[ "$a" = "y" || "$a" = "Y" ]]; then : else exit 0 fi fi if test -z ${chroot}; then echo "tmpdir nonexistent - bailing" exit 1 fi # create the sbuild chroot for target suite echo "Doing debootstrap" debootstrap --variant=buildd ${suite} ${chroot} # and add our little modifications to that chroot cp configchrootforarch ${chroot}/usr/local/bin/ # set up apt sources and turn off recommends echo "Configuring apt" cat <<-EOF > ${chroot}/etc/apt/sources.list.d/linaro-overlay.list deb http://repo.linaro.org/ubuntu/linaro-overlay ${suite} main deb-src http://repo.linaro.org/ubuntu/linaro-overlay ${suite} main EOF cat <<-EOF > ${chroot}/etc/apt/sources.list deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${suite} main universe deb [arch=armhf,arm64] http://ports.ubuntu.com/ ${suite} main universe deb-src http://archive.ubuntu.com/ubuntu/ ${suite} main universe deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${suite}-updates main universe deb [arch=armhf,arm64] http://ports.ubuntu.com/ ${suite}-updates main universe deb-src http://archive.ubuntu.com/ubuntu/ ${suite}-updates main universe EOF cat <<-EOF > ${chroot}/etc/apt/apt.conf.d/30norecommends APT::Install-Suggests "0"; APT::Install-Recommends "0"; EOF #and set up an apt key for the linaro archive echo "Installing apt key" cp linarorepo.key ${chroot}/ chroot ${chroot} apt-key add linarorepo.key rm ${chroot}/linarorepo.key # now pack that up into filesystem structure suitable for use by schroot/sbuild mkdir -p ${suite}-crosschroot/srv/chroots mkdir -p ${suite}-crosschroot/etc/schroot/chroot.d echo "Tarring up chroot" tar -C ${chroot} -czf ${suite}-crosschroot/srv/chroots/${suite}-cross-buildd.tgz . #tidy up debootstrapped chroot if test -z ${chroot}; then echo "tmpdir nonexistent - avoiding deleting /" else rm -rf ${chroot} fi #add schroot config file for the chroot tarball cat <<-EOF > ${suite}-crosschroot/etc/schroot/chroot.d/${suite}-amd64-sbuild [${suite}-amd64-sbuild] type=file description=Ubuntu ${suite}/amd64 autobuilder file=/srv/chroots/${suite}-cross-buildd.tgz groups=root,sbuild,ubuntu root-groups=root,sbuild,ubuntu EOF #now pack all that up in a deb using alien set +e echo "Packaging result" rm -rf saucy-crosschroot-${version} (cd ${suite}-crosschroot; chown -R root: *) tar -C ${suite}-crosschroot -czvf ${suite}-crosschroot.tgz . fakeroot alien --version ${version} ${suite}-crosschroot.tgz