Description: templates: don't fail on busy flock
 Just wait until the lock is available.  That is a nicer behavior
 for concurrent lxc-creates.
Author: Serge Hallyn <serge.hallyn@ubuntu.com>
Forwarded: yes
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1007483

Index: lxc-0.7.5/templates/lxc-debian.in
===================================================================
--- lxc-0.7.5.orig/templates/lxc-debian.in	2012-06-11 21:04:05.960253888 +0000
+++ lxc-0.7.5/templates/lxc-debian.in	2012-06-11 21:04:16.052249994 +0000
@@ -170,7 +170,7 @@
     rootfs=$1
     mkdir -p @LOCALSTATEDIR@/lock/subsys/
     (
-	flock -n -x 200
+	flock -x 200
 	if [ $? -ne 0 ]; then
 	    echo "Cache repository is busy."
 	    return 1
@@ -284,7 +284,7 @@
 
     # lock, so we won't purge while someone is creating a repository
     (
-	flock -n -x 200
+	flock -x 200
 	if [ $? != 0 ]; then
 	    echo "Cache repository is busy."
 	    exit 1
Index: lxc-0.7.5/templates/lxc-fedora.in
===================================================================
--- lxc-0.7.5.orig/templates/lxc-fedora.in	2012-06-11 21:04:05.960253888 +0000
+++ lxc-0.7.5/templates/lxc-fedora.in	2012-06-11 21:04:16.052249994 +0000
@@ -190,7 +190,7 @@
 {
     mkdir -p /var/lock/subsys/
     (
-	flock -n -x 200
+	flock -x 200
 	if [ $? -ne 0 ]; then
 	    echo "Cache repository is busy."
 	    return 1
@@ -281,7 +281,7 @@
 
     # lock, so we won't purge while someone is creating a repository
     (
-	flock -n -x 200
+	flock -x 200
 	if [ $? != 0 ]; then
 	    echo "Cache repository is busy."
 	    exit 1
Index: lxc-0.7.5/templates/lxc-lenny.in
===================================================================
--- lxc-0.7.5.orig/templates/lxc-lenny.in	2012-06-11 21:04:05.960253888 +0000
+++ lxc-0.7.5/templates/lxc-lenny.in	2012-06-11 21:04:16.052249994 +0000
@@ -142,7 +142,7 @@
     rootfs=$1
     mkdir -p @LOCALSTATEDIR@/lock/subsys/
     (
-	flock -n -x 200
+	flock -x 200
 	if [ $? -ne 0 ]; then
 	    echo "Cache repository is busy."
 	    return 1
@@ -225,7 +225,7 @@
 
     # lock, so we won't purge while someone is creating a repository
     (
-	flock -n -x 200
+	flock -x 200
 	if [ $? != 0 ]; then
 	    echo "Cache repository is busy."
 	    exit 1
Index: lxc-0.7.5/templates/lxc-opensuse.in
===================================================================
--- lxc-0.7.5.orig/templates/lxc-opensuse.in	2012-06-11 21:04:05.960253888 +0000
+++ lxc-0.7.5/templates/lxc-opensuse.in	2012-06-11 21:04:16.052249994 +0000
@@ -196,7 +196,7 @@
     rootfs=$1
     mkdir -p /var/lock/subsys/
     (
-	flock -n -x 200
+	flock -x 200
 	if [ $? -ne 0 ]; then
 	    echo "Cache repository is busy."
 	    return 1
@@ -284,7 +284,7 @@
 
     # lock, so we won't purge while someone is creating a repository
     (
-	flock -n -x 200
+	flock -x 200
 	if [ $? != 0 ]; then
 	    echo "Cache repository is busy."
 	    exit 1
Index: lxc-0.7.5/templates/lxc-ubuntu-cloud.in
===================================================================
--- lxc-0.7.5.orig/templates/lxc-ubuntu-cloud.in	2012-06-11 21:04:05.960253888 +0000
+++ lxc-0.7.5/templates/lxc-ubuntu-cloud.in	2012-06-11 21:04:16.052249994 +0000
@@ -292,7 +292,7 @@
 
 mkdir -p /var/lock/subsys/
 (
-    flock -n -x 200
+    flock -x 200
 
     cd $cache
     if [ $flushcache -eq 1 ]; then
Index: lxc-0.7.5/templates/lxc-ubuntu.in
===================================================================
--- lxc-0.7.5.orig/templates/lxc-ubuntu.in	2012-06-11 21:04:05.960253888 +0000
+++ lxc-0.7.5/templates/lxc-ubuntu.in	2012-06-11 21:04:16.052249994 +0000
@@ -229,7 +229,7 @@
     mkdir -p /var/lock/subsys/
 
     (
-        flock -n -x 200
+        flock -x 200
         if [ $? -ne 0 ]; then
             echo "Cache repository is busy."
             return 1
