Skip to content

Commit 49c71f9

Browse files
r-barnesmeta-codesync[bot]
authored andcommitted
fbcode_builder: SystemPackageFetcher.hash() — hash package list, not bool
Summary: If `self.installed` is not a hash of what was installed then we handle it differently to take into account packages where we're relying on the system. Reviewed By: bigfootjon Differential Revision: D104428972 fbshipit-source-id: af51081007166de311b15f2b627d4cec77a91df4
1 parent 8d69f6a commit 49c71f9

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

build/fbcode_builder/getdeps/fetcher.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,16 @@ def update(self) -> ChangeStatus:
254254

255255
def hash(self) -> str:
256256
if self.packages_are_installed():
257-
# pyrefly: ignore [bad-argument-type]
258-
return hashlib.sha256(self.installed).hexdigest()
257+
# SystemPackageFetcher stashes the package-manager query output
258+
# (bytes including versions) in self.installed so upgrades change
259+
# the hash. PreinstalledNopFetcher just sets self.installed=True
260+
# and has no .packages, so fall back to an empty package list.
261+
if isinstance(self.installed, (bytes, bytearray)):
262+
payload = bytes(self.installed)
263+
else:
264+
packages = getattr(self, "packages", None) or []
265+
payload = ",".join(sorted(packages)).encode("utf-8")
266+
return hashlib.sha256(payload).hexdigest()
259267
else:
260268
return "0" * 40
261269

0 commit comments

Comments
 (0)