2013-04-26 14:54:29 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2013-04-28 18:31:28 +00:00
|
|
|
# these should match the names found at http://www.debian.org/releases/
|
|
|
|
stableSuite='squeeze'
|
|
|
|
testingSuite='wheezy'
|
|
|
|
unstableSuite='sid'
|
|
|
|
|
|
|
|
# if suite is equal to this, it gets the "latest" tag
|
|
|
|
latestSuite="$testingSuite"
|
|
|
|
|
|
|
|
variant='minbase'
|
|
|
|
include='iproute,iputils-ping'
|
2013-04-26 14:54:29 +00:00
|
|
|
|
|
|
|
repo="$1"
|
|
|
|
suite="${2:-$latestSuite}"
|
2013-04-28 19:37:52 +00:00
|
|
|
mirror="${3:-}" # stick to the default debootstrap mirror if one is not provided
|
2013-04-26 14:54:29 +00:00
|
|
|
|
|
|
|
if [ ! "$repo" ]; then
|
|
|
|
echo >&2 "usage: $0 repo [suite [mirror]]"
|
|
|
|
echo >&2 " ie: $0 tianon/debian squeeze"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2013-04-28 19:37:52 +00:00
|
|
|
target="/tmp/docker-rootfs-debian-$suite-$$-$RANDOM"
|
2013-04-26 14:54:29 +00:00
|
|
|
|
|
|
|
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
|
|
|
|
returnTo="$(pwd -P)"
|
|
|
|
|
|
|
|
set -x
|
|
|
|
|
|
|
|
# bootstrap
|
|
|
|
mkdir -p "$target"
|
2013-04-28 18:31:28 +00:00
|
|
|
sudo debootstrap --verbose --variant="$variant" --include="$include" "$suite" "$target" "$mirror"
|
2013-04-26 14:54:29 +00:00
|
|
|
|
|
|
|
cd "$target"
|
|
|
|
|
|
|
|
# create the image
|
|
|
|
img=$(sudo tar -c . | docker import -)
|
|
|
|
|
|
|
|
# tag suite
|
|
|
|
docker tag $img $repo $suite
|
|
|
|
|
|
|
|
if [ "$suite" = "$latestSuite" ]; then
|
|
|
|
# tag latest
|
|
|
|
docker tag $img $repo latest
|
|
|
|
fi
|
|
|
|
|
|
|
|
# test the image
|
|
|
|
docker run -i -t $repo:$suite echo success
|
|
|
|
|
2013-04-28 18:31:28 +00:00
|
|
|
# unstable's version numbers match testing (since it's mostly just a sandbox for testing), so it doesn't get a version number tag
|
|
|
|
if [ "$suite" != "$unstableSuite" -a "$suite" != 'unstable' ]; then
|
|
|
|
# tag the specific version
|
|
|
|
ver=$(docker run $repo:$suite cat /etc/debian_version)
|
|
|
|
docker tag $img $repo $ver
|
|
|
|
fi
|
|
|
|
|
2013-04-26 14:54:29 +00:00
|
|
|
# cleanup
|
|
|
|
cd "$returnTo"
|
|
|
|
sudo rm -rf "$target"
|