Skip to content

Commit

Permalink
apport-retrace: avoid installing base-files unconditionally
Browse files Browse the repository at this point in the history
Installing `base-files` is not needed after applying the proper fix for
finding `ld-linux-x86-64.so.2`. So revert installing `base-files` unless
it was requested. In that case install it as first package to corretly
set-up the usrmerge symlinks.

Bug-Ubuntu: https://launchpad.net/bugs/2067120
Fixes: 52560e6 ("apport-retrace: install base-files first")
  • Loading branch information
bdrung committed Jun 12, 2024
1 parent 5037f04 commit 670083b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
10 changes: 4 additions & 6 deletions apport/sandboxutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,13 @@ def needed_runtime_packages(report, pkgmap_cache_dir, pkg_versions, verbose=Fals
return [(p, pkg_versions.get(p)) for p in pkgs]


def _move_or_add_base_files_first(pkgs: list[tuple[str, None | str]]) -> None:
def _move_base_files_first(pkgs: list[tuple[str, None | str]]) -> None:
"""Move base-files to the front or add it if missing."""
base_files_version = None
for i, (pkg, version) in enumerate(pkgs):
if pkg == "base-files":
base_files_version = version
pkgs.pop(i)
break
pkgs[:0] = [("base-files", base_files_version)]
pkgs[:0] = [("base-files", version)]
return


# pylint: disable-next=too-many-arguments
Expand Down Expand Up @@ -234,7 +232,7 @@ def make_sandbox(
apport.logging.log(f"Origins: {origins}")

# Install base-files first to get correct usrmerge
_move_or_add_base_files_first(pkgs)
_move_base_files_first(pkgs)

# unpack packages, if any, using cache and sandbox
try:
Expand Down
21 changes: 8 additions & 13 deletions tests/unit/test_sandboxutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from apport.packaging import PackageInfo
from apport.report import Report
from apport.sandboxutils import _move_or_add_base_files_first, make_sandbox
from apport.sandboxutils import _move_base_files_first, make_sandbox


class TestSandboxutils(unittest.TestCase):
Expand Down Expand Up @@ -72,14 +72,14 @@ def test_make_sandbox_with_sandbox_dir(self, packaging_mock: MagicMock) -> None:
self.assertEqual(outdated_msg, "obsolete\nobsolete\n")
self.assertEqual(packaging_mock.install_packages.call_count, 2)

def test_move_or_add_base_files_first_existing(self) -> None:
"""_move_or_add_base_files_first() with base-files in list."""
def test_move_base_files_first_existing(self) -> None:
"""_move_base_files_first() with base-files in list."""
pkgs: list[tuple[str, None | str]] = [
("chaos-marmosets", "0.1.2-2"),
("base-files", "13ubuntu9"),
("libc6", "2.39-0ubuntu8.2"),
]
_move_or_add_base_files_first(pkgs)
_move_base_files_first(pkgs)
self.assertEqual(
pkgs,
[
Expand All @@ -89,18 +89,13 @@ def test_move_or_add_base_files_first_existing(self) -> None:
],
)

def test_move_or_add_base_files_first_missing(self) -> None:
"""_move_or_add_base_files_first() without base-files in list."""
def test_move_base_files_first_missing(self) -> None:
"""_move_base_files_first() without base-files in list."""
pkgs: list[tuple[str, None | str]] = [
("chaos-marmosets", "0.1.2-2"),
("libc6", "2.39-0ubuntu8.2"),
]
_move_or_add_base_files_first(pkgs)
_move_base_files_first(pkgs)
self.assertEqual(
pkgs,
[
("base-files", None),
("chaos-marmosets", "0.1.2-2"),
("libc6", "2.39-0ubuntu8.2"),
],
pkgs, [("chaos-marmosets", "0.1.2-2"), ("libc6", "2.39-0ubuntu8.2")]
)

0 comments on commit 670083b

Please sign in to comment.