From 31a07c46db262a08a7861e732c76fe366c378fef Mon Sep 17 00:00:00 2001 From: gerblesh <101901964+gerblesh@users.noreply.github.com> Date: Sun, 24 Nov 2024 18:47:27 -0800 Subject: [PATCH] update --- src/ublue_update/cli.py | 2 +- src/ublue_update/update_drivers/brew.py | 19 +++++++++---------- tests/unit/test_brew.py | 13 +++++++------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/ublue_update/cli.py b/src/ublue_update/cli.py index 746896e..482c01c 100644 --- a/src/ublue_update/cli.py +++ b/src/ublue_update/cli.py @@ -138,7 +138,7 @@ def run_updates(system: bool, system_update_available: bool, dry_run: bool): if out.returncode != 0: log.error(f"topgrade returned code {out.returncode}, program output:") - log.error(out.stdout.decode("utf-8")) + log.error(out.stderr.decode("utf-8")) os._exit(out.returncode) """Users""" diff --git a/src/ublue_update/update_drivers/brew.py b/src/ublue_update/update_drivers/brew.py index 3670286..88e835e 100644 --- a/src/ublue_update/update_drivers/brew.py +++ b/src/ublue_update/update_drivers/brew.py @@ -7,6 +7,8 @@ BREW_PREFIX = "/home/linuxbrew/.linuxbrew" BREW_CELLAR = f"{BREW_PREFIX}/Cellar" BREW_REPO = f"{BREW_PREFIX}/Homebrew" +BREW_PATH: str = f"{BREW_PREFIX}/bin/brew" + def detect_user() -> int: @@ -20,29 +22,26 @@ def brew_update(dry_run: bool): if uid == -1 or dry_run: return log.info(f"running brew updates for uid: {uid}") - env_path: str = os.environ["PATH"] - path: str = f"{env_path}:{BREW_PREFIX}/bin:{BREW_PREFIX}/sbin" args: list[str] = [ - f"--E=HOMEBREW_PREFIX='{BREW_PREFIX}'", - f"--E=HOMEBREW_CELLAR='{BREW_CELLAR}'", - f"--E=HOMEBREW_REPOSITORY='{BREW_REPO}'", - f"--E=PATH='{path}'", + f"--setenv=HOMEBREW_PREFIX='{BREW_PREFIX}'", + f"--setenv=HOMEBREW_CELLAR='{BREW_CELLAR}'", + f"--setenv=HOMEBREW_REPOSITORY='{BREW_REPO}'", ] - out = run_uid(uid, args + ["brew", "update"]) + out = run_uid(uid, args + [f"{BREW_PATH}", "update"]) if out.returncode != 0: log.error( f"brew update failed, returned code {out.returncode}, program output:" ) - log.error(out.stdout.decode("utf-8")) + log.error(out.stderr.decode("utf-8")) return - out = run_uid(uid, args + ["brew", "upgrade"]) + out = run_uid(uid, args + [f"{BREW_PATH}", "upgrade"]) if out.returncode != 0: log.error( f"brew upgrade failed, returned code {out.returncode}, program output:" ) - log.error(out.stdout.decode("utf-8")) + log.error(out.stderr.decode("utf-8")) return log.info("brew updates completed") diff --git a/tests/unit/test_brew.py b/tests/unit/test_brew.py index 124c44b..52aef82 100644 --- a/tests/unit/test_brew.py +++ b/tests/unit/test_brew.py @@ -7,6 +7,7 @@ ) from ublue_update.update_drivers.brew import ( + BREW_PATH, detect_user, brew_update, BREW_PREFIX, @@ -55,14 +56,14 @@ def test_brew_update(mock_log, mock_stat, mock_isdir, mock_run_uid): brew_update(False) env = [ - f"--E=HOMEBREW_PREFIX='{BREW_PREFIX}'", - f"--E=HOMEBREW_CELLAR='{BREW_CELLAR}'", - f"--E=HOMEBREW_REPOSITORY='{BREW_REPO}'", - f"--E=PATH='/usr/bin:{BREW_PREFIX}/bin:{BREW_PREFIX}/sbin'", + f"--setenv=HOMEBREW_PREFIX='{BREW_PREFIX}'", + f"--setenv=HOMEBREW_CELLAR='{BREW_CELLAR}'", + f"--setenv=HOMEBREW_REPOSITORY='{BREW_REPO}'", + f"--setenv=PATH='/usr/bin:{BREW_PREFIX}/bin:{BREW_PREFIX}/sbin'", ] - mock_run_uid.assert_any_call(1001, env + ["brew", "update"]) - mock_run_uid.assert_any_call(1001, env + ["brew", "upgrade"]) + mock_run_uid.assert_any_call(1001, env + [f"{BREW_PATH}", "update"]) + mock_run_uid.assert_any_call(1001, env + [f"{BREW_PATH}", "upgrade"]) @patch("ublue_update.update_drivers.brew.run_uid")