packages/srcinfo_cache: track whether cache was correct or state had been changed
This commit is contained in:
parent
0983d3466d
commit
b709fd73b9
1 changed files with 19 additions and 5 deletions
|
@ -26,6 +26,7 @@ class SrcinfoMetaFile(DataClass):
|
||||||
build_mode: Optional[str]
|
build_mode: Optional[str]
|
||||||
|
|
||||||
_relative_path: str
|
_relative_path: str
|
||||||
|
_changed: bool
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse_existing(relative_pkg_dir: str) -> SrcinfoMetaFile:
|
def parse_existing(relative_pkg_dir: str) -> SrcinfoMetaFile:
|
||||||
|
@ -35,13 +36,21 @@ class SrcinfoMetaFile(DataClass):
|
||||||
if not os.path.exists(srcinfo_meta_file):
|
if not os.path.exists(srcinfo_meta_file):
|
||||||
raise Exception(f"{relative_pkg_dir}: {SRCINFO_METADATA_FILE} doesn't exist")
|
raise Exception(f"{relative_pkg_dir}: {SRCINFO_METADATA_FILE} doesn't exist")
|
||||||
with open(srcinfo_meta_file, 'r') as meta_fd:
|
with open(srcinfo_meta_file, 'r') as meta_fd:
|
||||||
metadata_raw = json.load(meta_fd) | {'_relative_path': relative_pkg_dir}
|
metadata_raw = json.load(meta_fd)
|
||||||
return SrcinfoMetaFile.fromDict(metadata_raw, validate=True)
|
return SrcinfoMetaFile.fromDict(metadata_raw | {
|
||||||
|
'_relative_path': relative_pkg_dir,
|
||||||
|
'_changed': False,
|
||||||
|
}, validate=True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_new(relative_pkg_dir: str, write: bool = True) -> tuple[SrcinfoMetaFile, list[str]]:
|
def generate_new(relative_pkg_dir: str, write: bool = True) -> tuple[SrcinfoMetaFile, list[str]]:
|
||||||
'Creates a new SrcinfoMetaFile object with checksums, creating a SRCINFO as necessary'
|
'Creates a new SrcinfoMetaFile object with checksums, creating a SRCINFO as necessary'
|
||||||
s = SrcinfoMetaFile({'_relative_path': relative_pkg_dir, 'build_mode': '', 'checksums': {}}, validate=True)
|
s = SrcinfoMetaFile({
|
||||||
|
'_relative_path': relative_pkg_dir,
|
||||||
|
'_changed': True,
|
||||||
|
'build_mode': '',
|
||||||
|
'checksums': {},
|
||||||
|
}, validate=True)
|
||||||
return s, s.refresh_all()
|
return s, s.refresh_all()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -72,12 +81,17 @@ class SrcinfoMetaFile(DataClass):
|
||||||
|
|
||||||
def refresh_checksums(self):
|
def refresh_checksums(self):
|
||||||
pkgdir = os.path.join(config.get_path('pkgbuilds'), self._relative_path)
|
pkgdir = os.path.join(config.get_path('pkgbuilds'), self._relative_path)
|
||||||
|
if 'checksums' not in self:
|
||||||
|
self['checksums'] = None
|
||||||
|
checksums_old = self.checksums.copy()
|
||||||
checksums = self.Checksums({p: sha256sum(os.path.join(pkgdir, p)) for p in SRCINFO_CHECKSUM_FILES})
|
checksums = self.Checksums({p: sha256sum(os.path.join(pkgdir, p)) for p in SRCINFO_CHECKSUM_FILES})
|
||||||
if 'checksums' not in self or self.checksums is None:
|
if self.checksums is None:
|
||||||
self['checksums'] = checksums
|
self.checksums = checksums
|
||||||
else:
|
else:
|
||||||
self.checksums.clear()
|
self.checksums.clear()
|
||||||
self.checksums.update(checksums)
|
self.checksums.update(checksums)
|
||||||
|
if checksums != checksums_old:
|
||||||
|
self._changed = True
|
||||||
|
|
||||||
def refresh_build_mode(self):
|
def refresh_build_mode(self):
|
||||||
self['build_mode'] = None
|
self['build_mode'] = None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue