Skip to contentSkip to conversation

sstatesig: Improve output hash calculation

PATCH Superseded [email protected] 2 participants 2 messages Feb 8, 2023 – Feb 9, 2023

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sstatesig: Improve output hash calculation

From: Mateusz Marciniec <[email protected]>

Symbolic links to the files are included during the output hash calculation but symlinks to the directories are missed. So if the new symlink to a directory was the only change made, then the output hash won't change,
and the Hash Equivalence server may change unihash.
In the next run bitbake may use an older package from sstate-cache.

To fix this followlinks=True flag could be set for os.walk but it can lead to infinite recursion if link points
to a parent directory of itself.
Also, all files from a directory to which symlink points would be included in depsig file.
Therefore another solution was applied, I added code that will loop through directories and process those that are symlinks.

---
 meta/lib/oe/sstatesig.py | 5 +++++
 1 file changed, 5 insertions(+)
meta/lib/oe/sstatesig.py +5 -0
index f0224454c9..a5bc030f58 100644
@@ -652,6 +652,11 @@ def OEOuthashBasic(path, sigfile, task, d):
                 if f == 'fixmepath':
                     continue
                 process(os.path.join(root, f))
+
+            for d in dirs:
+                if not os.path.islink(os.path.join(root, d)):
+                    continue
+                process(os.path.join(root, d))
     finally:
         os.chdir(prev_dir)
 
Signature · 1 line
2.39.1
#1 lore raw
Quoted 35 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Mateusz Marciniec
Sent: den 9 februari 2023 00:50
To: [email protected]
Cc: Mateusz Marciniec <[email protected]>; Tomasz Dziendzielski <[email protected]>
Subject: [OE-core][PATCH] sstatesig: Improve output hash calculation

From: Mateusz Marciniec <[email protected]>

Symbolic links to the files are included during the output hash calculation but symlinks to the directories are missed. So if the new symlink to a directory was the only change made, then the output hash won't change,
and the Hash Equivalence server may change unihash.
In the next run bitbake may use an older package from sstate-cache.

To fix this followlinks=True flag could be set for os.walk but it can lead to infinite recursion if link points
to a parent directory of itself.
Also, all files from a directory to which symlink points would be included in depsig file.
Therefore another solution was applied, I added code that will loop through directories and process those that are symlinks.

---
 meta/lib/oe/sstatesig.py | 5 +++++
 1 file changed, 5 insertions(+)
meta/lib/oe/sstatesig.py +0 -0
index f0224454c9..a5bc030f58 100644

meta/lib/oe/sstatesig.py def OEOuthashBasic(path, sigfile, task, d): · line 656

Quoted 5 lines
meta/lib/oe/sstatesig.py +2 -0
@@ -652,6 +652,11 @@ def OEOuthashBasic(path, sigfile, task, d):
                 if f == 'fixmepath':
                     continue
                 process(os.path.join(root, f))
+
+            for d in dirs:

Don't use d as a local variable for the directory, it is universally used as reference to the datastore (also in this function as the function declaration above indicates). Use dir instead.

Quoted 8 lines
meta/lib/oe/sstatesig.py +3 -1
+                if not os.path.islink(os.path.join(root, d)):
+                    continue
+                process(os.path.join(root, d))
     finally:
         os.chdir(prev_dir)
 
--

2.39.1

//Peter