]> git.e2factory.org Git - e2factory.git/commitdiff
deployment: initial implementation
authorGordon Hecker <gh@emlix.com>
Thu, 29 Apr 2010 13:20:18 +0000 (15:20 +0200)
committerGordon Hecker <gh@emlix.com>
Fri, 7 May 2010 11:39:56 +0000 (13:39 +0200)
Signed-off-by: Gordon Hecker <gh@emlix.com>
local/e2build.lua

index 992ef5331b68f2a21e3fc8253e94715bd4c0b077..3f59c0d1af1c7405127f19879763f5ab393fa6e7 100644 (file)
@@ -787,6 +787,10 @@ function store_result(info, r, return_flags)
   if not rc then
     return false, e:cat(re)
   end
+  rc, re = deploy(info, r, return_flags)
+  if not rc then
+    return false, e:cat(re)
+  end
   rc, re = e2tool.lcd(info, ".")
   if not rc then
     return false, e:cat(re)
@@ -1203,6 +1207,49 @@ function collect_project(info, r, return_flags)
        return true, nil
 end
 
+--- deploy a result to the archive
+-- @param info
+-- @param r string: result name
+-- @param return_flags table
+-- @return bool
+-- @return an error object on failure
+function deploy(info, r, return_flags)
+--[[
+  This function is called located in a temporary directory that contains
+  the unpacked result structure and the result tarball itself as follows:
+  ./result/build.log.gz
+  ./result/checksums
+  ./result/files/*
+  ./result.tar
+
+  This function pushes the result files and the checksum file as follows:
+  -- result/checksums
+  --   -> releases:<project>/<archive>/<release_id>/<result>/checksums
+  -- result/files/*
+  --   -> releases:<project>/<archive>/<release_id>/<result>/files/*
+--]]
+  local files = {}
+  for f in e2lib.directory("result/files") do
+    table.insert(files, string.format("files/%s", f))
+  end
+  table.insert(files, "checksums")
+  local server = "releases"
+  local location = string.format("%s/archive/%s/%s", info.project_location,
+                                                       info.release_id, r)
+  for _,f in ipairs(files) do
+    local sourcefile = string.format("result/%s", f)
+    local location1 = string.format("%s/%s", location, f)
+    local cache_flags = {}
+    e2lib.logf(1, "result: %s deploying %s:%s", r, server, location1)
+    local rc, re = info.cache:push_file(sourcefile, server, location1,
+                                                               cache_flags)
+    if not rc then
+      return false, e:cat(re)
+    end
+  end
+  return true
+end
+
 --- register a function to extend the build process
 -- @param info
 -- @param name string: build function name (used for logging)