@@ -86,11 +86,13 @@ case $DISTRO in
8686 xenial|bionic)
8787 version=$( curl -s https://api.github.com/repos/$RELEASE_REPO /releases/latest | jq -r " .tag_name" )
8888 ROOTFS=" https://github.com/$RELEASE_REPO /releases/download/${version} /ubuntu-${DISTRO} -${VARIANT} -${version} -${BUILD_ARCH} .tar.xz"
89+ FALLBACK_ROOTFS=" https://github.com/$RELEASE_REPO /releases/download/${version} /ubuntu-${DISTRO} -minimal-${version} -${BUILD_ARCH} .tar.xz"
8990 TAR_OPTIONS=" -J --strip-components=1 binary"
9091 ;;
9192 sid|stretch)
9293 version=$( curl -s https://api.github.com/repos/$RELEASE_REPO /releases/latest | jq -r " .tag_name" )
9394 ROOTFS=" https://github.com/$RELEASE_REPO /releases/download/${version} /debian-${DISTRO} -${VARIANT} -${version} -${BUILD_ARCH} .tar.xz"
95+ FALLBACK_ROOTFS=" https://github.com/$RELEASE_REPO /releases/download/${version} /debian-${DISTRO} -minimal-${version} -${BUILD_ARCH} .tar.xz"
9496 TAR_OPTIONS=" -J --strip-components=1 binary"
9597 ;;
9698 * )
@@ -99,21 +101,26 @@ case $DISTRO in
99101 ;;
100102esac
101103
102- mkdir -p $BUILD
103- TARBALL=" $TEMP /$( basename $ROOTFS ) "
104+ CACHE_ROOT=" ${CACHE_ROOT:- tmp} "
105+ mkdir -p " $CACHE_ROOT "
106+ TARBALL=" ${CACHE_ROOT} /$( basename $ROOTFS ) "
104107
105- mkdir -p " $BUILD "
106108if [ ! -e " $TARBALL " ]; then
107109 echo " Downloading $DISTRO rootfs tarball ..."
108- wget -O " $TARBALL " " $ROOTFS "
110+ pushd " $CACHE_ROOT "
111+ if ! flock " $( basename " $ROOTFS " ) .lock" wget -c " $ROOTFS " ; then
112+ TARBALL=" ${CACHE_ROOT} /$( basename " $FALLBACK_ROOTFS " ) "
113+ echo " Downloading fallback $DISTRO rootfs tarball ..."
114+ flock " $( basename " $FALLBACK_ROOTFS " ) .lock" wget -c " $FALLBACK_ROOTFS "
115+ fi
116+ popd
109117fi
110118
111119# Extract with BSD tar
112120echo -n " Extracting ... "
113121set -x
114122tar -xf " $TARBALL " -C " $DEST " $TAR_OPTIONS
115123echo " OK"
116- rm -f " $TARBALL "
117124
118125# Add qemu emulation.
119126cp /usr/bin/qemu-aarch64-static " $DEST /usr/bin"
0 commit comments