From 44df61b22db6a7abd24cb897d19c821182007e77 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sun, 14 Jun 2026 21:22:58 +1000 Subject: [PATCH] refactor: set default aur helper to constant --- src/caelestia/subcommands/install.py | 4 ++-- src/caelestia/utils/dots/packages.py | 12 +++++++----- src/caelestia/utils/dots/state.py | 3 ++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/caelestia/subcommands/install.py b/src/caelestia/subcommands/install.py index ff53d571..0f18be3c 100644 --- a/src/caelestia/subcommands/install.py +++ b/src/caelestia/subcommands/install.py @@ -7,7 +7,7 @@ from pathlib import Path from caelestia.utils.dots.deployer import Deployer from caelestia.utils.dots.manifest import Manifest, ManifestError, expand, expand_dests -from caelestia.utils.dots.packages import PackageInstaller +from caelestia.utils.dots.packages import DEFAULT_AUR_HELPER, PackageInstaller from caelestia.utils.dots.source import DotsSource, SourceError from caelestia.utils.dots.state import DotsState from caelestia.utils.io import confirm, disable_input, fatal, info, log, pause, warn @@ -155,7 +155,7 @@ class Command: log(f"Building {path}...") local_packages[path] = installer.build_install(directory) - return getattr(installer, "helper", ""), packages, local_packages + return getattr(installer, "helper", DEFAULT_AUR_HELPER), packages, local_packages def run_hooks(self, manifest: Manifest) -> None: hooks = manifest.enabled_hooks("post_install") diff --git a/src/caelestia/utils/dots/packages.py b/src/caelestia/utils/dots/packages.py index 3d3e7cd6..96aca252 100644 --- a/src/caelestia/utils/dots/packages.py +++ b/src/caelestia/utils/dots/packages.py @@ -1,11 +1,13 @@ import shutil import subprocess +import tempfile from abc import ABC, abstractmethod from pathlib import Path from caelestia.utils.io import fatal, info -AUR_HELPERS = "paru", "yay" +DEFAULT_AUR_HELPER = "paru" +AUR_HELPERS = DEFAULT_AUR_HELPER, "yay" def _install_aur_helper(helper: str, noconfirm: bool = False) -> None: @@ -31,7 +33,7 @@ def _install_aur_helper(helper: str, noconfirm: bool = False) -> None: if helper == "yay": subprocess.run(["yay", "-Y", "--gendb"], check=True) subprocess.run(["yay", "-Y", "--devel", "--save"], check=True) - else: + elif helper == "paru": subprocess.run(["paru", "--gendb"], check=True) @@ -59,9 +61,9 @@ class PackageInstaller(ABC): if shutil.which(candidate): return ArchInstaller(candidate, noconfirm) - info("No AUR helper found. Installing paru...") - _install_aur_helper("paru", noconfirm) - return ArchInstaller("paru", noconfirm) + info(f"No AUR helper found. Installing {DEFAULT_AUR_HELPER}...") + _install_aur_helper(DEFAULT_AUR_HELPER, noconfirm) + return ArchInstaller(DEFAULT_AUR_HELPER, noconfirm) # --- Abstract methods --- diff --git a/src/caelestia/utils/dots/state.py b/src/caelestia/utils/dots/state.py index 9529bf86..d47f3c96 100644 --- a/src/caelestia/utils/dots/state.py +++ b/src/caelestia/utils/dots/state.py @@ -1,6 +1,7 @@ import json from dataclasses import dataclass, field +from caelestia.utils.dots.packages import DEFAULT_AUR_HELPER from caelestia.utils.io import warn from caelestia.utils.paths import atomic_dump, dots_state_path @@ -31,7 +32,7 @@ class DotsState: return DotsState() return DotsState( - aur_helper=data.get("aur_helper"), + aur_helper=data.get("aur_helper", DEFAULT_AUR_HELPER), applied_rev=data.get("applied_rev"), enabled_components=data.get("enabled_components", []), packages=data.get("packages", []),