[lxc-devel] A few fixes for lxc-fedora template

2011-10-26 Thread Tuomas Suutari
Hi,

I was setting up a Fedora container on my Ubuntu 11.10 system, but ran
into some problems with the lxc-fedora template. I tried with the
latest version from the git master, but it also needed some small
fixes to get it working. So here are the fixes that I did. Hopefully
someone else also finds these useful.

-- 
Tuomas Suutari


--
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


[lxc-devel] [PATCH 3/3] lxc-fedora.in: Fix fetching of the fedora-release rpm

2011-10-26 Thread Tuomas Suutari
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 
---
 templates/lxc-fedora.in |   26 --
 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
-- 
1.7.5.4


--
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


[lxc-devel] [PATCH 1/3] lxc-fedora.in: Add missing default release variable

2011-10-26 Thread Tuomas Suutari
The text says that 14 is default, but release=14 was not set anywhere
in the script.

Signed-off-by: Tuomas Suutari 
---
 templates/lxc-fedora.in |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/templates/lxc-fedora.in b/templates/lxc-fedora.in
index d35600a..8588aef 100644
--- a/templates/lxc-fedora.in
+++ b/templates/lxc-fedora.in
@@ -317,6 +317,7 @@ if [ -z "$release" ]; then
 release=$(cat /etc/fedora-release |awk '/^Fedora/ {print $3}')
 else
 echo "This is not a fedora host and release missing, defaulting to 14. 
use -R|--release to specify release"
+release=14
 fi
 fi
 
-- 
1.7.5.4


--
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


[lxc-devel] [PATCH 2/3] lxc-fedora.in: Use i386 instead of i686

2011-10-26 Thread Tuomas Suutari
There is no i686 variant of Fedora, but Ubuntu seems to return i686
from the arch command.

Signed-off-by: Tuomas Suutari 
---
 templates/lxc-fedora.in |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/templates/lxc-fedora.in b/templates/lxc-fedora.in
index 8588aef..1e8fff2 100644
--- a/templates/lxc-fedora.in
+++ b/templates/lxc-fedora.in
@@ -36,6 +36,10 @@ lxc_network_link=virbr0
 # is this fedora?
 [ -f /etc/fedora-release ] && is_fedora=true
 
+if [ "$arch" = "i686" ]; then
+arch=i386
+fi
+
 configure_fedora()
 {
 
-- 
1.7.5.4


--
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel