]> git.e2factory.org Git - e2factory.git/commitdiff
file_class: change the meaning of FileID to be inclusive of attributes
authorTobias Ulmer <tu@emlix.com>
Tue, 29 Nov 2016 15:22:53 +0000 (16:22 +0100)
committerTobias Ulmer <tu@emlix.com>
Tue, 29 Nov 2016 15:22:53 +0000 (16:22 +0100)
This is a departure from the previous convention where fileid() returned
the SHA1 sum of the file

Signed-off-by: Tobias Ulmer <tu@emlix.com>
local/chroot.lua
local/e2tool.lua
local/licence.lua
plugins/files.lua

index f5e7dac2041a35dfc6b8de014db846ad544b56b3..a44c8057bbdc7293272e77505eb2da4a271dfa3b 100644 (file)
@@ -148,8 +148,6 @@ function chroot.chroot:chrootgroupid(info)
 
     local fileid
     for file in self:file_iter() do
-        hash.hash_append(hc, file:server())
-        hash.hash_append(hc, file:location())
         fileid, re = file:fileid()
         if not fileid then
             return false, e:cat(re)
index 8b858c1644496297764b5d20c1c58b958accab5f..c63857dd21cade34cb0e7419c399afb82bc4c51a 100644 (file)
@@ -126,7 +126,7 @@ function e2tool.file_class:_compute_fileid(flags)
 
     info = e2tool.info()
 
-    path, re = cache.fetch_file_path(info.cache, self:server(), self:location())
+    path, re = cache.fetch_file_path(info.cache, self:server(), self:location(), flags)
     if not path then
         return false, re
     end
@@ -139,8 +139,8 @@ function e2tool.file_class:_compute_fileid(flags)
     return fileid
 end
 
---- Calculate the FileID for a file.
--- The name and location attributes are not included.
+--- Calculate the FileID for a file. This includes the checksum of the file
+-- as well as all set attributes.
 -- @return FileID string: hash value, or false on error.
 -- @return an error object on failure
 function e2tool.file_class:fileid()
@@ -169,7 +169,35 @@ function e2tool.file_class:fileid()
         end
     end
 
-    return fileid
+    local hc, info
+    info = e2tool.info()
+    hc = hash.hash_start()
+    hash.hash_append(hc, self._server)
+    hash.hash_append(hc, self._location)
+
+    hash.hash_append(hc, fileid)
+
+    if self._licences then
+        local lid
+
+        for licencename in self._licences:iter() do
+            local lid, re = licence.licences[licencename]:licenceid(info)
+            if not lid then
+                return false, e:cat(re)
+            end
+            hash.hash_append(hc, lid)
+        end
+    end
+
+    if self._unpack then
+        hash.hash_append(hc, self._unpack)
+    elseif self._patch then
+        hash.hash_append(hc, self._patch)
+    elseif self._copy then
+        hash.hash_append(hc, self._copy)
+    end
+
+    return hash.hash_finish(hc)
 end
 
 --- Set or return the server attribute.
index dd9b6129d21582778e41c32c6ead6d7b865ae5bd..fbfa060313afdee3ae758e699bc5de50cf101b70 100644 (file)
@@ -125,9 +125,6 @@ function licence.licence:licenceid(info)
     hash.hash_append(hc, self._name)
 
     for file in self:file_iter() do
-        hash.hash_append(hc, file:server())
-        hash.hash_append(hc, file:location())
-
         fileid, re = file:fileid()
         if not fileid then
             return false, e:cat(re)
index 8d40f5181a8e37cce8a07316fd24d3614aa04568..b7ae21843a1d6bab872aded46cb73c6bab0af30b 100644 (file)
@@ -266,26 +266,6 @@ function files.files_source:sourceid(sourceset --[[always ignored for files]])
             return false, re
         end
         hash.hash_append(hc, fileid)
-        hash.hash_append(hc, file:location())
-        hash.hash_append(hc, file:server())
-        if file:unpack() then
-            hash.hash_append(hc, file:unpack())
-        elseif file:patch() then
-            hash.hash_append(hc, file:patch())
-        elseif file:copy() then
-            hash.hash_append(hc, file:copy())
-        else
-            assert(false, "no file attribute set")
-        end
-
-        -- per file licence list
-        for licencename in file:licences():iter() do
-            local lid, re = licence.licences[licencename]:licenceid(info)
-            if not lid then
-                return false, re
-            end
-            hash.hash_append(hc, lid)
-        end
     end
 
     self._sourceid = hash.hash_finish(hc)