@ -12,21 +12,31 @@ if test -f /etc/setup-debootstrap.conf; then
. /etc/setup-debootstrap.conf
fi
tmpdir = ${ tmpdir :- "/var/tmp" }
tmpdir = ${ tmpdir :- "/var/tmp/chroots" }
test -d " ${ tmpdir } " || mkdir -p " ${ tmpdir } "
docker_user = ${ docker_user :- ${ USER } }
if test -z " ${ ports [@] } " ; then
ports = ( armhf powerpc ppc64el s390x arm64 )
qemus = ( arm ppc ppc64 s390x armb )
fi
numports = ${# ports [@] }
if test -z " $archs " ; then
case " $( dpkg --print-architecture) " in
( amd64) archs = "i386 amd64" ; ;
( amd64) archs = "amd64 i386 " ; ;
( *) archs = $( dpkg --print-architecture) ; ;
esac
for ( ( i = 0; i<${ num } ; ++i) ) ; do
if test -x /usr/bin/qemu-${ qemus [ $i ] } -static; then
archs += " ${ ports [ $i ] } "
fi
done
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
debian_qt5 = "jessie sid"
debian_qt4 = ""
# not yet successfully installable: debian stretch and buster
ubuntu = ( " ${ ubuntu_qt5 } " " ${ ubuntu_qt4 } " )
ubuntu = ( " ${ ubuntu_qt5 } " )
debian = ( " ${ debian_qt5 } " " ${ debian_qt4 } " )
distros = ( ${ distros :- " ${ ubuntu [@] } " " ${ debian [@] } " } )
@ -38,8 +48,9 @@ packages_base="software-properties-common apt-transport-https dpkg-dev lsb-relea
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 " ${ packages [@] } " ; then
packages = ( " ${ packages_base } ${ packages_qt5 } " " ${ packages_base } ${ packages_qt5 } " " ${ packages_base } ${ packages_qt4 } " )
fi
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
@ -47,9 +58,40 @@ if test -z "${index}" -a "${#distros[@]}" -ne "${#packages[@]}"; then
exit 1
fi
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
}
for ( ( i = 0; i<${# distros [@] } ; ++i) ) ; do
package = " ${ packages [ ${ index :- $i } ] } "
for distro in ${ distros [ $i ] } ; do
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
ubuntus = " ${ ubuntu [@] } "
if test " ${ ubuntus // ${ distro } / } " != " ${ ubuntus } " ; then
type = "ubuntu"
@ -57,12 +99,37 @@ for ((i=0; i<${#distros[@]}; ++i)); do
type = "debian"
fi
for arch in ${ archs } ; do
trap 'error "${LINENO}" "${tmpdir}" "${disto}" "${arch}"' ERR SIGINT
echo " ******** process $type $distro $arch ******** " 1>& 2
if test -d " ${ tmpdir } / ${ distro } - ${ arch } " ; then
echo " ++++ already exists ${ tmpdir } / ${ distro } - ${ arch } " 1>& 2
if test $fastmode -eq 1; then
continue ;
fi
else
echo " ---- install ${ tmpdir } / ${ distro } - ${ arch } " 1>& 2
sudo debootstrap --arch= " $arch " " $distro " " ${ tmpdir } / ${ distro } - ${ arch } "
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
fi
echo " ---- prevent packages in ${ tmpdir } / ${ distro } - ${ arch } " 1>& 2
for f in "dbus" "libpam-systemd*" "packagekit*" "policykit*" "colord" ; do
@ -78,18 +145,20 @@ 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
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
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 "
( test " $type " != "debian" && \
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
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
echo " ---- install ${ package } to ${ tmpdir } / ${ distro } - ${ arch } " 1>& 2
sudo chroot " ${ tmpdir } / ${ distro } - ${ arch } " apt-get install -y ${ package }
sudo chroot " ${ tmpdir } / ${ distro } - ${ arch } " apt-get -o Acquire::ForceIPv4= true 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 } "