]> git.e2factory.org Git - e2factory.git/commitdiff
lock chroot
authorGordon Hecker <gh@emlix.com>
Wed, 30 Sep 2009 14:10:15 +0000 (16:10 +0200)
committerGordon Hecker <gh@emlix.com>
Fri, 2 Oct 2009 10:40:08 +0000 (12:40 +0200)
Signed-off-by: Gordon Hecker <gh@emlix.com>
local/e2build.lua
local/policy.lua

index f3dbc505c99f29aa1781ceff6a094ca9b2c2eb10..b8034a0d1d26804b7e318c18bcb1aac6723a7d40 100644 (file)
@@ -173,6 +173,7 @@ function e2build.build_config(info, r)
   tab.base = string.format("%s/%s/%s", tmpdir, project, r)
   tab.c = string.format("%s/chroot", tab.base)
   tab.chroot_marker = string.format("%s/e2factory-chroot", tab.base)
+  tab.chroot_lock = string.format("%s/e2factory-chroot-lock", tab.base)
   tab.T = string.format("%s/%s/%s/chroot/%s", tmpdir, project, r, builddir)
   tab.Tc = string.format("/%s", builddir)
   tab.r = string.format("%s", r)
@@ -207,6 +208,32 @@ function e2build.build_config(info, r)
   return tab
 end
 
+function e2build.chroot_lock(info, r, return_flags)
+  local res = info.results[r]
+  local rc, re
+  local e = new_error("error locking chroot")
+  rc, re = e2lib.mkdir(res.build_config.c, "-p")
+  if not rc then
+    return false, e:cat(re)
+  end
+  rc, re = e2lib.lock:lock(res.build_config.chroot_lock)
+  if not rc then
+    return false, e:cat(re)
+  end
+  return true, nil
+end
+
+function e2build.chroot_unlock(info, r, return_flags)
+  local res = info.results[r]
+  local rc, re
+  local e = new_error("error unlocking chroot")
+  rc, re = e2lib.lock:unlock(res.build_config.chroot_lock)
+  if not rc then
+    return false, e:cat(re)
+  end
+  return true, nil
+end
+
 function e2build.setup_chroot(info, r, return_flags)
   local res = info.results[r]
   local rc, re
index 3cd351c3d9c7f97dbe5b2abaabbf0dce45bc9c86..9e900a0720ab2e59349eadfdff301faeac203615 100644 (file)
@@ -222,6 +222,7 @@ local default_build_process = {
        "build_config",
        "result_available",
        "remove_logfile",
+       "chroot_lock",
        "chroot_cleanup_if_exists",
        "setup_chroot",
        "sources",
@@ -233,6 +234,7 @@ local default_build_process = {
        "store_result",
        "linklast",
        "chroot_cleanup",
+       "chroot_unlock",
 }
 
 policy = {}