[DEPRECATED, use docker as replacement] Scripts to generate Ubuntu and Debian docker images or chroot environments, i.e. used for building packages for these environments.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.5 KiB
60 lines
2.5 KiB
9 years ago
|
#!/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
|