]> git.e2factory.org Git - e2factory.git/commitdiff
file_class: add servloc() method
authorTobias Ulmer <tu@emlix.com>
Fri, 25 Nov 2016 19:27:00 +0000 (20:27 +0100)
committerTobias Ulmer <tu@emlix.com>
Fri, 25 Nov 2016 19:27:00 +0000 (20:27 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
local/e2-ls-project.lua
local/e2tool.lua
plugins/files.lua

index d8faf7f19d116626c23ffabc9dd679ba207dd7a7..767689dab0590384f2a2471c806e326c488d0952 100644 (file)
@@ -300,7 +300,7 @@ local function e2_ls_project(arg)
         end
         p2(s1, s2, lic:get_name())
         for file in lic:file_iter() do
-            p3(s1, s2, "file", string.format("%s:%s", file:server(), file:location()))
+            p3(s1, s2, "file", file:servloc())
         end
     end
 
@@ -321,7 +321,7 @@ local function e2_ls_project(arg)
         end
         p2(s1, s2, grp:get_name(), grp:get_name())
         for file in grp:file_iter() do
-            p3(s1, s2, "file", string.format("%s:%s", file:server(), file:location()))
+            p3(s1, s2, "file", file:servloc())
         end
         --[[if grp.groupid then
             p3(s1, s2, "groupid", grp.groupid)
index f71125ed0813a3dd7fe15501fe25485419d41b07..7b35fdabc4c59c3df754bc321613326a6acfc636 100644 (file)
@@ -108,6 +108,12 @@ function e2tool.file_class:to_config_table()
     return t
 end
 
+--- Formatted server:location string.
+-- @return server:location string
+function e2tool.file_class:servloc()
+    return self._server .. ":" .. self._location
+end
+
 --- Set or return the server attribute.
 -- Server name is any name known to cache.
 -- @param server Optional server name to set
@@ -887,7 +893,7 @@ function e2tool.verify_hash(info, file)
 
     local rc, re, e, id_cache, id_remote, id_fetch, fileid
 
-    e = err.new("error verifying checksum of %s:%s", file:server(), file:location())
+    e = err.new("error verifying checksum of %s", file:servloc())
 
     if cache.cache_enabled(info.cache, file:server()) then
         id_cache, re = compute_fileid(file)
@@ -960,8 +966,7 @@ function e2tool.fileid(info, file)
 
     local rc, re, e, fileid
 
-    e = err.new("error calculating file id for file: %s:%s",
-        file:server(), file:location())
+    e = err.new("error calculating file id for file: %s", file:servloc())
 
     if file:sha1() then
         fileid = file:sha1()
index f6d6a2a5e96caf25c7936b2e82d4484854d4af85..14db4ff86a27324d89a323b24b8e001e0086b350 100644 (file)
@@ -306,7 +306,7 @@ function files.files_source:display()
         self:get_licences():concat(" ")))
 
     for file in self:file_iter() do
-        s = string.format("file       = %s:%s", file:server(), file:location())
+        s = string.format("file       = %s", file:servloc())
         table.insert(d, s)
         table.insert(d, string.format("licences   = %s",
             file:licences():concat(" ")))
@@ -331,15 +331,13 @@ function files.cache_source(info, sourcename)
     -- cache all files for this source
     for file in src:file_iter() do
         if cache.cache_enabled(info.cache, file:server()) then
-            e2lib.logf(3, "files.cache_source: caching file %s:%s",
-                file:server(), file:location())
+            e2lib.logf(3, "files.cache_source: caching file %s", file:servloc())
             rc, re = cache.fetch_file_path(info.cache, file:server(), file:location())
             if not rc then
                 return false, re
             end
         else
-            e2lib.logf(3, "not caching %s:%s (stored locally)", file:server(),
-                file:location())
+            e2lib.logf(3, "not caching %s (stored locally)", file:servloc())
         end
     end
     return true
@@ -581,7 +579,7 @@ function files.prepare_source(info, sourcename, sourceset, buildpath)
                 local argv = { "-p", file:patch(), "-d", symlink, "-i", path }
                 rc, re = patch_tool(argv)
                 if not rc then
-                    e:append("applying patch: \"%s:%s\"", file:server(), file:location())
+                    e:append("applying patch: \"%s\"", file:servloc())
                     return false, e:cat(re)
                 end
             elseif file:copy() then