packetary/perestroika/docker-builder/create-deb-chroot.sh
Sergey Kulanov 05d86902d5 [perestroika] Inject perestroika into fuel-mirror
While we have migration of perestroika to Python implementation
we need to have friendly and open way to share and fix issues
in current perestroika code

Change-Id: I7fced52ddadc81d4d8a52659358936f6e68cc3e4
Closes-bug: #1489470
2015-10-19 20:59:46 +03:00

37 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
#
# Prepare chroot (must exist before starting any builds) environment
# with `sbuild-createchroot` which prepares everything for building DEBs
#
# Usage: DIST=trusty ./create-deb-chroot.sh # for Trusty
# DIST=precise ./create-deb-chroot.sh # for Precise
# UPSTREAM_MIRROR=http://ua.archive.ubuntu.com/ubuntu/ ./create-deb-chroot.sh
set -ex
BIN="${0%/*}"
source "${BIN}/config"
CONTAINERNAME=sbuild:latest
CACHEPATH=/var/cache/docker-builder/sbuild
# define upstream Ubuntu mirror
MIRROR=${UPSTREAM_MIRROR:-http://mirror.yandex.ru/ubuntu}
# Use trusty distro by default
[ -z "${DIST}" ] && DIST=trusty
if [ "${DIST}" != "precise" ] && [ "${DIST}" != "trusty" ]; then
echo "Unknown dist version: ${DIST}"
exit 1
fi
docker run ${DNSPARAM} --privileged --rm -v ${CACHEPATH}:/srv/images ${CONTAINERNAME} \
bash -c "rm -f /etc/schroot/chroot.d/*
sbuild-createchroot ${DIST} /srv/images/${DIST}-amd64 ${MIRROR}
echo deb ${MIRROR} ${DIST} main universe multiverse restricted > /srv/images/${DIST}-amd64/etc/apt/sources.list
echo deb ${MIRROR} ${DIST}-updates main universe multiverse restricted >> /srv/images/${DIST}-amd64/etc/apt/sources.list
sbuild-update -udcar ${DIST}
echo '#!/bin/bash' > /srv/images/${DIST}-amd64/usr/bin/apt-add-repo
echo 'echo \$* >> /etc/apt/sources.list' >> /srv/images/${DIST}-amd64/usr/bin/apt-add-repo
chmod +x /srv/images/${DIST}-amd64/usr/bin/apt-add-repo"