2015-12-02 15:58:18 +00:00
|
|
|
#!/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
|
|
|
|
|
2016-09-25 11:22:18 +00:00
|
|
|
tmpdir=${tmpdir:-"/var/tmp/chroots"}
|
|
|
|
test -d "${tmpdir}" || mkdir -p "${tmpdir}"
|
2016-05-31 13:26:52 +00:00
|
|
|
docker_user=${docker_user:-${USER}}
|
2016-09-25 11:22:18 +00:00
|
|
|
if test -z "${ports[@]}"; then
|
|
|
|
ports=( armhf powerpc ppc64el s390x arm64 )
|
|
|
|
qemus=( arm ppc ppc64 s390x armb )
|
|
|
|
fi
|
|
|
|
numports=${#ports[@]}
|
2016-09-23 18:23:58 +00:00
|
|
|
if test -z "$archs"; then
|
2016-09-23 18:24:23 +00:00
|
|
|
case "$(dpkg --print-architecture)" in
|
2016-09-25 11:22:18 +00:00
|
|
|
(amd64) archs="amd64 i386";;
|
2016-09-23 18:24:55 +00:00
|
|
|
(*) archs=$(dpkg --print-architecture);;
|
2016-09-23 18:23:58 +00:00
|
|
|
esac
|
2016-09-25 11:22:18 +00:00
|
|
|
for ((i=0; i<${num}; ++i)); do
|
|
|
|
if test -x /usr/bin/qemu-${qemus[$i]}-static; then
|
|
|
|
archs+=" ${ports[$i]}"
|
|
|
|
fi
|
|
|
|
done
|
2016-09-23 18:23:58 +00:00
|
|
|
fi
|
|
|
|
ubuntu_qt5="yakkety xenial wily vivid trusty"
|
2016-09-25 11:22:18 +00:00
|
|
|
debian_qt5="jessie sid"
|
|
|
|
debian_qt4=""
|
|
|
|
# not yet successfully installable: debian stretch and buster
|
2016-05-31 13:26:52 +00:00
|
|
|
|
2016-09-25 11:22:18 +00:00
|
|
|
ubuntu=("${ubuntu_qt5}")
|
2016-05-31 13:26:52 +00:00
|
|
|
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=""
|
|
|
|
|
2016-09-25 11:22:18 +00:00
|
|
|
if test -z "${packages[@]}"; then
|
|
|
|
packages=("${packages_base} ${packages_qt5}" "${packages_base} ${packages_qt5}" "${packages_base} ${packages_qt4}")
|
|
|
|
fi
|
2016-05-31 13:26:52 +00:00
|
|
|
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
|
2015-12-02 15:58:18 +00:00
|
|
|
|
2016-09-25 11:22:18 +00:00
|
|
|
fastmode=0;
|
|
|
|
limit=
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case "$1" in
|
|
|
|
(-f|--fastmode) fastmode=1;;
|
|
|
|
(-l|--limit) shift; limit=$1;;
|
|
|
|
(*)
|
|
|
|
echo "**** ERROR: unknown option $1" 1>&2
|
|
|
|
exit 1;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
error() {
|
|
|
|
tmpdir=$2
|
|
|
|
disto=$3
|
|
|
|
arch=$4
|
|
|
|
echo "**** ERROR at ${0}:${1}" 1>&2
|
|
|
|
echo ".... on $(eval echo \"${BASH_COMMAND}\")" 1>&2
|
|
|
|
echo ".... tmpdir=$tmpdir arch=$arch distro=$distro" 1>&2
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2016-05-31 13:26:52 +00:00
|
|
|
for ((i=0; i<${#distros[@]}; ++i)); do
|
|
|
|
package="${packages[${index:-$i}]}"
|
|
|
|
for distro in ${distros[$i]}; do
|
2016-09-25 11:22:18 +00:00
|
|
|
if test -n "$limit" -a "$distro" != "$limit"; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
if ! test -e /usr/share/debootstrap/scripts/${distro}; then
|
|
|
|
echo "**** WARNING: skipping unsupported ${distro}" 1>&2
|
|
|
|
continue;
|
|
|
|
fi
|
2016-05-31 13:26:52 +00:00
|
|
|
ubuntus="${ubuntu[@]}"
|
|
|
|
if test "${ubuntus//${distro}/}" != "${ubuntus}"; then
|
2015-12-02 15:58:18 +00:00
|
|
|
type="ubuntu"
|
|
|
|
else
|
|
|
|
type="debian"
|
|
|
|
fi
|
2016-05-31 13:26:52 +00:00
|
|
|
for arch in ${archs}; do
|
2016-09-25 11:22:18 +00:00
|
|
|
trap 'error "${LINENO}" "${tmpdir}" "${disto}" "${arch}"' ERR SIGINT
|
2016-05-31 13:26:52 +00:00
|
|
|
echo "******** process $type $distro $arch ********" 1>&2
|
|
|
|
if test -d "${tmpdir}/${distro}-${arch}"; then
|
|
|
|
echo " ++++ already exists ${tmpdir}/${distro}-${arch}" 1>&2
|
2016-09-25 11:22:18 +00:00
|
|
|
if test $fastmode -eq 1; then
|
|
|
|
continue;
|
|
|
|
fi
|
2016-05-31 13:26:52 +00:00
|
|
|
else
|
2016-09-25 11:22:18 +00:00
|
|
|
if test "$(dpkg --print-architecture)" = "$arch" -o \( "$(dpkg --print-architecture)" = amd64 -a "$arch" = i386 \) ; then
|
|
|
|
echo " ---- install ${tmpdir}/${distro}-${arch}" 1>&2
|
|
|
|
sudo debootstrap --arch="$arch" "$distro" "${tmpdir}/${distro}-${arch}"
|
|
|
|
else
|
|
|
|
for ((i=0; $i<$numports; ++i)); do
|
|
|
|
if test "${ports[$i]}" = "${arch}"; then
|
|
|
|
break;
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
qemu="${qemus[$i]}"
|
|
|
|
if ! test -e /usr/bin/qemu-${qemu}-static; then
|
|
|
|
echo "**** WARNING: no emulator ${qemu} found, skipping ${arch}" 1>&2
|
|
|
|
continue;
|
|
|
|
fi
|
|
|
|
arch=${arch#*-}
|
|
|
|
echo " ---- install on $qemu ${tmpdir}/${distro}-${arch}" 1>&2
|
|
|
|
sudo debootstrap --foreign --arch="$arch" "$distro" "${tmpdir}/${distro}-${arch}"
|
|
|
|
sudo cp /usr/bin/qemu-${qemu}-static "${tmpdir}/${distro}-${arch}/usr/bin/qemu-${qemu}-static"
|
|
|
|
sudo DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C chroot "${tmpdir}/${distro}-${arch}" /debootstrap/debootstrap --second-stage || \
|
|
|
|
sudo chroot "${tmpdir}/${distro}-${arch}" apt-get -o Acquire::ForceIPv4=true -y -f install && \
|
|
|
|
sudo DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C chroot "${tmpdir}/${distro}-${arch}" /debootstrap/debootstrap --second-stage
|
|
|
|
sudo DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C chroot "${tmpdir}/${distro}-${arch}" dpkg --configure -a
|
|
|
|
fi
|
2016-05-31 13:26:52 +00:00
|
|
|
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
|
|
|
|
|
2016-04-04 14:56:17 +00:00
|
|
|
Package: $f
|
|
|
|
Pin-Priority: -100
|
|
|
|
|
2016-05-31 13:26:52 +00:00
|
|
|
EOF2
|
|
|
|
fi
|
|
|
|
EOF1
|
2015-12-02 15:58:18 +00:00
|
|
|
done
|
2016-05-31 13:26:52 +00:00
|
|
|
echo " ---- upgrade ${tmpdir}/${distro}-${arch}" 1>&2
|
2016-09-25 11:22:18 +00:00
|
|
|
sudo chroot "${tmpdir}/${distro}-${arch}" apt-get -o Acquire::ForceIPv4=true update
|
|
|
|
sudo chroot "${tmpdir}/${distro}-${arch}" apt-get -o Acquire::ForceIPv4=true -y -f install
|
|
|
|
sudo chroot "${tmpdir}/${distro}-${arch}" apt-get -o Acquire::ForceIPv4=true -y upgrade
|
|
|
|
sudo chroot "${tmpdir}/${distro}-${arch}" apt-get -o Acquire::ForceIPv4=true install -y python-software-properties software-properties-common || \
|
|
|
|
sudo chroot "${tmpdir}/${distro}-${arch}" apt-get -o Acquire::ForceIPv4=true install -y software-properties-common
|
2016-05-31 13:26:52 +00:00
|
|
|
if test "${distro}" != "jessie" -a "${distro}" != "sid"; then
|
|
|
|
sudo chroot "${tmpdir}/${distro}-${arch}" add-apt-repository universe || \
|
2016-09-25 11:22:18 +00:00
|
|
|
( test "$type" != "debian" && \
|
|
|
|
sudo chroot "${tmpdir}/${distro}-${arch}" add-apt-repository "deb http://archive.ubuntu.com/ubuntu ${distro} universe" )
|
2016-05-31 13:26:52 +00:00
|
|
|
fi
|
2016-09-25 11:22:18 +00:00
|
|
|
sudo chroot "${tmpdir}/${distro}-${arch}" apt-get -o Acquire::ForceIPv4=true update
|
|
|
|
sudo chroot "${tmpdir}/${distro}-${arch}" apt-get -o Acquire::ForceIPv4=true -y dist-upgrade
|
2016-05-31 13:26:52 +00:00
|
|
|
echo " ---- install ${package} to ${tmpdir}/${distro}-${arch}" 1>&2
|
2016-09-25 11:22:18 +00:00
|
|
|
sudo chroot "${tmpdir}/${distro}-${arch}" apt-get -o Acquire::ForceIPv4=true install -y ${package}
|
2016-05-31 13:26:52 +00:00
|
|
|
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}"
|
2015-12-02 15:58:18 +00:00
|
|
|
done
|
|
|
|
done
|
|
|
|
done
|