#!/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
tmpdir = ${ tmpdir :- "/var/tmp" }
docker_user = ${ docker_user :- ${ USER } }
if test -z " $archs " ; then
case " $( dpkg --print-architecture) " in
( amd64) archs = "i386 amd64" ; ;
( *) archs = $( dpkg --print-architecture) ; ;
esac
fi
ubuntu_qt5 = "yakkety xenial wily vivid trusty"
ubuntu_qt4 = "precise"
debian_qt5 = "stretch jessie sid"
debian_qt4 = "wheezy"
debian_unsupported = "buster" # not in /usr/share/debootstrap/scripts
ubuntu = ( " ${ ubuntu_qt5 } " " ${ ubuntu_qt4 } " )
debian = ( " ${ debian_qt5 } " " ${ debian_qt4 } " )
distros = ( ${ distros :- " ${ ubuntu [@] } " " ${ debian [@] } " } )
packages_qt5 = "qtbase5-dev qtbase5-dev-tools qtbase5-dev-tools libqt5webkit5-dev libqt5svg5-dev qt5-default qttools5-dev"
# |libqtcore4-qmake|libqt4-core
packages_qt4 = "qt4-qmake libqt4-dev"
# |software-properties-common|python-software-properties
packages_base = "software-properties-common apt-transport-https dpkg-dev lsb-release debhelper git subversion pkg-config automake libtool autotools-dev doxygen graphviz mscgen libcppunit-dev xvfb nodejs"
package_not_in_xenial = ""
package_not_in_xenial_qt5 = ""
packages = ( ${ packages :- " ${ packages_base } ${ packages_qt5 } " " ${ packages_base } ${ packages_qt4 } " " ${ packages_base } ${ packages_qt5 } " " ${ packages_base } ${ packages_qt4 } " } )
if test -z " ${ index } " -a " ${# distros [@] } " -ne " ${# packages [@] } " ; then
echo "**** ERROR: number of distribution lists doesn't match package lists" 1>& 2
echo " distribution lists: ${# distros [@] } " 1>& 2
echo " package lists: ${# packages [@] } " 1>& 2
exit 1
fi
for ( ( i = 0; i<${# distros [@] } ; ++i) ) ; do
package = " ${ packages [ ${ index :- $i } ] } "
for distro in ${ distros [ $i ] } ; do
ubuntus = " ${ ubuntu [@] } "
if test " ${ ubuntus // ${ distro } / } " != " ${ ubuntus } " ; then
type = "ubuntu"
else
type = "debian"
fi
for arch in ${ archs } ; do
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 " ---- prevent packages in ${ tmpdir } / ${ distro } - ${ arch } " 1>& 2
for f in "dbus" "libpam-systemd*" "packagekit*" "policykit*" "colord" ; do
sudo chroot " ${ tmpdir } / ${ distro } - ${ arch } " <<EOF1
if ! grep -q " Package: $f " /etc/apt/preferences; then
cat >> /etc/apt/preferences <<EOF2
Package: $f
Pin-Priority: -100
EOF2
fi
EOF1
done
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 install -y python-software-properties software-properties-common || \
sudo chroot " ${ tmpdir } / ${ distro } - ${ arch } " apt-get install -y software-properties-common
if test " ${ distro } " != "jessie" -a " ${ distro } " != "sid" ; then
sudo chroot " ${ tmpdir } / ${ distro } - ${ arch } " add-apt-repository universe || \
sudo chroot " ${ tmpdir } / ${ distro } - ${ arch } " add-apt-repository " deb http://archive.ubuntu.com/ubuntu ${ distro } universe "
fi
sudo chroot " ${ tmpdir } / ${ distro } - ${ arch } " apt-get update
sudo chroot " ${ tmpdir } / ${ distro } - ${ arch } " apt-get -y dist-upgrade
echo " ---- install ${ package } to ${ tmpdir } / ${ distro } - ${ arch } " 1>& 2
sudo chroot " ${ tmpdir } / ${ distro } - ${ arch } " apt-get install -y ${ package }
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
done