summaryrefslogtreecommitdiffstats
path: root/meta/classes/sstate.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/sstate.bbclass')
-rw-r--r--meta/classes/sstate.bbclass65
1 files changed, 3 insertions, 62 deletions
diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index 763fce07f9..2f0bbd2d7d 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -83,9 +83,9 @@ SSTATE_SIG_PASSPHRASE ?= ""
83# Whether to verify the GnUPG signatures when extracting sstate archives 83# Whether to verify the GnUPG signatures when extracting sstate archives
84SSTATE_VERIFY_SIG ?= "0" 84SSTATE_VERIFY_SIG ?= "0"
85 85
86SSTATE_HASHEQUIV_METHOD ?= "OEOuthashBasic" 86SSTATE_HASHEQUIV_METHOD ?= "oe.sstatesig.OEOuthashBasic"
87SSTATE_HASHEQUIV_METHOD[doc] = "The function used to calculate the output hash \ 87SSTATE_HASHEQUIV_METHOD[doc] = "The fully-qualified function used to calculate \
88 for a task, which in turn is used to determine equivalency. \ 88 the output hash for a task, which in turn is used to determine equivalency. \
89 " 89 "
90 90
91SSTATE_HASHEQUIV_SERVER ?= "" 91SSTATE_HASHEQUIV_SERVER ?= ""
@@ -782,65 +782,6 @@ python sstate_sign_package () {
782 d.getVar('SSTATE_SIG_PASSPHRASE'), armor=False) 782 d.getVar('SSTATE_SIG_PASSPHRASE'), armor=False)
783} 783}
784 784
785def OEOuthashBasic(path, sigfile, task, d):
786 import hashlib
787 import stat
788
789 def update_hash(s):
790 s = s.encode('utf-8')
791 h.update(s)
792 if sigfile:
793 sigfile.write(s)
794
795 h = hashlib.sha256()
796 prev_dir = os.getcwd()
797
798 try:
799 os.chdir(path)
800
801 update_hash("OEOuthashBasic\n")
802
803 # It is only currently useful to get equivalent hashes for things that
804 # can be restored from sstate. Since the sstate object is named using
805 # SSTATE_PKGSPEC and the task name, those should be included in the
806 # output hash calculation.
807 update_hash("SSTATE_PKGSPEC=%s\n" % d.getVar('SSTATE_PKGSPEC'))
808 update_hash("task=%s\n" % task)
809
810 for root, dirs, files in os.walk('.', topdown=True):
811 # Sort directories and files to ensure consistent ordering
812 dirs.sort()
813 files.sort()
814
815 for f in files:
816 path = os.path.join(root, f)
817 s = os.lstat(path)
818
819 # Hash file path
820 update_hash(path + '\n')
821
822 # Hash file mode
823 update_hash("\tmode=0x%x\n" % stat.S_IMODE(s.st_mode))
824 update_hash("\ttype=0x%x\n" % stat.S_IFMT(s.st_mode))
825
826 if stat.S_ISBLK(s.st_mode) or stat.S_ISBLK(s.st_mode):
827 # Hash device major and minor
828 update_hash("\tdev=%d,%d\n" % (os.major(s.st_rdev), os.minor(s.st_rdev)))
829 elif stat.S_ISLNK(s.st_mode):
830 # Hash symbolic link
831 update_hash("\tsymlink=%s\n" % os.readlink(path))
832 else:
833 fh = hashlib.sha256()
834 # Hash file contents
835 with open(path, 'rb') as d:
836 for chunk in iter(lambda: d.read(4096), b""):
837 fh.update(chunk)
838 update_hash("\tdigest=%s\n" % fh.hexdigest())
839 finally:
840 os.chdir(prev_dir)
841
842 return h.hexdigest()
843
844python sstate_report_unihash() { 785python sstate_report_unihash() {
845 report_unihash = getattr(bb.parse.siggen, 'report_unihash', None) 786 report_unihash = getattr(bb.parse.siggen, 'report_unihash', None)
846 787