aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuomas Suutari <tuomas.suutari@gmail.com>2011-10-28 23:55:38 +0200
committerDaniel Lezcano <daniel.lezcano@free.fr>2011-10-28 23:55:38 +0200
commit7bd44bf6f68bfee9044ba783d1c3fc10f5f7650c (patch)
treed741016e8840a1173a6786a05eb259bfaec076b3 /templates/lxc-fedora.in
parentlxc-fedora.in: Use i386 instead of i686 (diff)
downloadlxc-7bd44bf6f68bfee9044ba783d1c3fc10f5f7650c.tar.gz
lxc-7bd44bf6f68bfee9044ba783d1c3fc10f5f7650c.tar.bz2
lxc-7bd44bf6f68bfee9044ba783d1c3fc10f5f7650c.zip
lxc-fedora.in: Fix fetching of the fedora-release rpm
The hardcoded URL seems to be broken and 404 error was not checked. Now the mirror is selected from mirrorlist (instead of hardcoding to funet.fi) and fetch errors are checked. Also added a retry loop (with 3 tries) to find a working mirror, since some of the mirrors are not OK. Signed-off-by: Tuomas Suutari <tuomas.suutari@gmail.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Diffstat (limited to 'templates/lxc-fedora.in')
-rw-r--r--templates/lxc-fedora.in26
1 files changed, 24 insertions, 2 deletions
diff --git a/templates/lxc-fedora.in b/templates/lxc-fedora.in
index 1e8fff2..e7f42a6 100644
--- a/templates/lxc-fedora.in
+++ b/templates/lxc-fedora.in
@@ -115,8 +115,30 @@ download_fedora()
echo "Downloading fedora minimal ..."
YUM="yum --installroot $INSTALL_ROOT -y --nogpgcheck"
PKG_LIST="yum initscripts passwd rsyslog vim-minimal dhclient chkconfig rootfiles policycoreutils"
- RELEASE_URL="http://ftp.funet.fi/pub/mirrors/fedora.redhat.com/pub/fedora/linux/releases/$release/Everything/$arch/os/Packages/fedora-release-$release-1.noarch.rpm"
- curl $RELEASE_URL > $INSTALL_ROOT/fedora-release-$release.noarch.rpm
+ MIRRORLIST_URL="http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$release&arch=$arch"
+
+ DOWNLOAD_OK=no
+ for trynumber in 1 2 3; do
+ [ $trynumber != 1 ] && echo "Trying again..."
+ MIRROR_URL=$(curl -s -S -f "$MIRRORLIST_URL" | head -n2 | tail -n1)
+ if [ $? -ne 0 ] || [ -z "$MIRROR_URL" ]; then
+ echo "Failed to get a mirror"
+ continue
+ fi
+ RELEASE_URL="$MIRROR_URL/Packages/fedora-release-$release-1.noarch.rpm"
+ echo "Fetching from $RELEASE_URL"
+ curl -f "$RELEASE_URL" > $INSTALL_ROOT/fedora-release-$release.noarch.rpm
+ if [ $? -ne 0 ]; then
+ echo "Failed to download fedora release rpm"
+ continue
+ fi
+ DOWNLOAD_OK=yes
+ break
+ done
+ if [ $DOWNLOAD_OK != yes ]; then
+ echo "Aborting"
+ return 1
+ fi
mkdir -p $INSTALL_ROOT/var/lib/rpm
rpm --root $INSTALL_ROOT --initdb