Rebuild the DKMS transaction instead of reusing released packages
This commit is contained in:
parent
f949e66949
commit
c63ebb7c2c
2 changed files with 29 additions and 7 deletions
Binary file not shown.
|
|
@ -167,15 +167,37 @@ def main():
|
|||
if headers:
|
||||
# Re-prepare the complete closure with exact kernel build inputs.
|
||||
# Explicit user requests remain separate in the durable plan.
|
||||
#
|
||||
# release() invalidates every package the transaction owns, and
|
||||
# pyalpm holds no reference that would keep them alive: a package
|
||||
# loaded from a local archive is freed with it. Reusing those
|
||||
# objects in the second transaction made libalpm sort a freed
|
||||
# package and crash in strcmp (packages named NULL), so the new
|
||||
# transaction is rebuilt from the durable request rows.
|
||||
requested = {pkg.name: pkg.version for pkg in additions}
|
||||
header_rows = [(pkg.name, pkg.version, pkg.arch) for pkg in headers]
|
||||
transaction.release()
|
||||
transaction = handle.init_transaction(downloadonly=(mode == 'download'), needed=False)
|
||||
targets = {pkg.name: pkg for pkg in additions}
|
||||
for header in headers:
|
||||
if header.name in targets:
|
||||
require(targets[header.name].version == header.version,
|
||||
'Requested headers differ from target kernel')
|
||||
targets[header.name] = header
|
||||
for pkg in targets.values():
|
||||
for item in request['requests']:
|
||||
if item['source'] == 'local':
|
||||
path = Path('/inputs', item['filename'])
|
||||
require(path.parent == Path('/inputs') and digest(path) == item['checksum'],
|
||||
'Invalid retained local input')
|
||||
transaction.add_pkg(handle.load_pkg(str(path), check_sig=0))
|
||||
continue
|
||||
pkg = next((db.get_pkg(item['name']) for db in databases
|
||||
if db.name == item['repository']), None)
|
||||
require(pkg is not None, 'Requested package absent from selected snapshot')
|
||||
require((pkg.version, pkg.sha256sum) == (item['version'], item['checksum']),
|
||||
'Snapshot package identity changed')
|
||||
transaction.add_pkg(pkg)
|
||||
for name, version, architecture in header_rows:
|
||||
if name in requested:
|
||||
require(requested[name] == version, 'Requested headers differ from target kernel')
|
||||
continue
|
||||
pkg = next((db.get_pkg(name) for db in databases if db.get_pkg(name) is not None), None)
|
||||
require(pkg is not None and (pkg.version, pkg.arch) == (version, architecture),
|
||||
'Kernel headers changed between transaction passes')
|
||||
transaction.add_pkg(pkg)
|
||||
transaction.prepare()
|
||||
require(not transaction.to_remove, 'Transaction would remove managed packages')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue