mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-12-05 17:28:21 +00:00
fix(packages): install the tool apt needs to read an xz control member
ansible.builtin.apt extracts a deb's control member through the xz binary rather than through dpkg's own library, and Cursor's deb compresses that member with xz. On a target without xz-utils the install failed after the download and the checksum had already passed, which is the most expensive place to discover a missing tool. The deb branch of the download plan now installs it first, the way build_calls installs its declared depends. The rpm branch is unaffected. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
b7891c666c
commit
18e644e53d
2 files changed
+23
-4
No files matched your search
@@ -19,6 +19,14 @@ from utils.packages.sources import (
|
||||
PACMAN_CONF,
|
||||
)
|
||||
|
||||
|
||||
def _only(plan, module):
|
||||
"""Return the single call to *module*, failing when it is not unique."""
|
||||
calls = [call for call in plan if call.module == module]
|
||||
assert len(calls) == 1, f"{module} appears {len(calls)} times"
|
||||
return calls[0]
|
||||
|
||||
|
||||
_DEB = {
|
||||
"url": "https://vendor.example/pool/editor_1.2.3_amd64.deb",
|
||||
"checksum": "sha256:" + "a" * 64,
|
||||
@@ -223,13 +231,15 @@ class TestDownloadSource(unittest.TestCase):
|
||||
self.assertEqual(
|
||||
_modules(plan),
|
||||
[
|
||||
"ansible.builtin.package",
|
||||
"ansible.builtin.file",
|
||||
"ansible.builtin.get_url",
|
||||
"ansible.builtin.apt",
|
||||
"ansible.builtin.package",
|
||||
],
|
||||
)
|
||||
cache, fetch, install, confirm = plan
|
||||
tools, cache, fetch, install, confirm = plan
|
||||
self.assertEqual(tools.args["name"], ["xz-utils"])
|
||||
self.assertEqual(cache.args["path"], DOWNLOAD_CACHE_DIR)
|
||||
self.assertEqual(cache.args["owner"], "root")
|
||||
self.assertEqual(confirm.args["name"], ["editor"])
|
||||
@@ -276,9 +286,10 @@ class TestDownloadSource(unittest.TestCase):
|
||||
download={**_DEB, "url": _DEB["url"] + "?token=abc"},
|
||||
)
|
||||
plan = build_plan(spec, STATE_PRESENT)
|
||||
self.assertEqual(plan[2].module, "ansible.builtin.apt")
|
||||
self.assertIn("ansible.builtin.apt", _modules(plan))
|
||||
fetch = _only(plan, "ansible.builtin.get_url")
|
||||
self.assertEqual(
|
||||
plan[1].args["dest"], f"{DOWNLOAD_CACHE_DIR}/editor_1.2.3_amd64.deb"
|
||||
fetch.args["dest"], f"{DOWNLOAD_CACHE_DIR}/editor_1.2.3_amd64.deb"
|
||||
)
|
||||
|
||||
def test_the_source_without_its_block_is_refused(self):
|
||||
@@ -291,7 +302,7 @@ class TestDownloadSource(unittest.TestCase):
|
||||
PackageSpec(("editor",), source=SOURCE_DOWNLOAD, download=_DEB),
|
||||
STATE_PRESENT,
|
||||
)
|
||||
self.assertIsNotNone(plan[1].retry)
|
||||
self.assertIsNotNone(_only(plan, "ansible.builtin.get_url").retry)
|
||||
|
||||
def test_removal_goes_through_the_host_manager(self):
|
||||
plan = build_plan(
|
||||
|
||||
Reference in new issue
Block a user