new feature: bootstrap-to-docker.sh

master
Marc Wäckerlin 9 years ago
parent 92918f20ae
commit 8d33f29880
  1. 59
      scripts/bootstrap-to-docker.sh
  2. 2
      scripts/makefile.am

@ -0,0 +1,59 @@
#!/bin/bash -e
# pass your docker hub login name as $1, defaults to your user name
# you should have a repositories named ubuntu and debian
# if you have your own repository, you can also prepend it:
# my.repo.url:5000/myname the script will then append ubuntu or debian
# e.g. to my.repo.url:5000/myname/ubuntu:trusty-amd64
# please login to docker before you start this script
docker_user=${1:-${docker_user:-$(id -un)}}
if test -f /etc/setup-debootstrap.conf; then
. /etc/setup-debootstrap.conf
fi
archs=${archs:-"i386 amd64"}
ubuntu=${ubuntu:-"wily vivid trusty precise"}
debian=${debian:-"jessie wheezy squeeze sid"}
distros="${ubuntu} ${debian}"
tmpdir=${tmpdir:-"/var/tmp"}
packages=(${packages:-"python-software-properties|software-properties-common" "apt-transport-https dpkg-dev lsb-release"})
for arch in ${archs}; do
for distro in ${distros}; do
if test "${ubuntu//${distro}/}" != "${ubuntu}"; then
type="ubuntu"
else
type="debian"
fi
echo "******** process $type $distro $arch ********" 1>&2
if test -d "${tmpdir}/${distro}-${arch}"; then
echo " ++++ already exists ${tmpdir}/${distro}-${arch}" 1>&2
else
echo " ---- install ${tmpdir}/${distro}-${arch}" 1>&2
sudo debootstrap --arch="$arch" "$distro" "${tmpdir}/${distro}-${arch}"
fi
echo " ---- upgrade ${tmpdir}/${distro}-${arch}" 1>&2
sudo chroot "${tmpdir}/${distro}-${arch}" apt-get update
sudo chroot "${tmpdir}/${distro}-${arch}" apt-get -y upgrade
sudo chroot "${tmpdir}/${distro}-${arch}" apt-get -y dist-upgrade
for package in "${packages[@]}"; do
echo " ---- install ${package//|/ or } to ${tmpdir}/${distro}-${arch}" 1>&2
IFS='|' read -r -a pkgs <<< "$package"
success=0
for pkg in "${pkgs[@]}"; do
if sudo chroot "${tmpdir}/${distro}-${arch}" apt-get install -y ${pkg}; then
success=1;
break;
fi
done
test $success -eq 1
done
echo " ---- import ${tmpdir}/${distro}-${arch} to ${docker_user}/${type}:${distro}-${arch}" 1>&2
cd "${tmpdir}/${distro}-${arch}"
sudo tar c . | docker import - "${docker_user}/${type}:${distro}-${arch}"
echo " ---- push ${tmpdir}/${distro}-${arch} to ${docker_user}/${type}:${distro}-${arch}" 1>&2
docker push "${docker_user}/${type}:${distro}-${arch}"
done
done

@ -3,7 +3,7 @@
## 1 2 3 4 5 6 7 8 ## 1 2 3 4 5 6 7 8
## 45678901234567890123456789012345678901234567890123456789012345678901234567890 ## 45678901234567890123456789012345678901234567890123456789012345678901234567890
dist_bin_SCRIPTS = setup-debootstrap.sh dist_bin_SCRIPTS = setup-debootstrap.sh bootstrap-to-docker.sh
MAINTAINERCLEANFILES = makefile.in MAINTAINERCLEANFILES = makefile.in

Loading…
Cancel
Save