feat: add migration step to install cmd (#126)

* feat: add migration step to install cmd

* fix: set packages to explicitly installed

* fix: legacy remote check

Oops

* fix: generator

* fix: better legacy detection

* fix: run legacy detection before deployment

Also fix unlink on dir

* fix: legacy file check issue

* fix: handle no legacy

* fix: make sure not to go past home when looking for repo

* fix: wrong dir for default legacy path

* fix: catch errors with deleting legacy install
This commit is contained in:
2 * r + 2 * t
2026-06-18 21:40:05 +10:00
committed by GitHub
parent 7ff0913826
commit f53b3d036f
3 changed files with 145 additions and 7 deletions
+27 -3
View File
@@ -73,6 +73,9 @@ class PackageInstaller(ABC):
def build_install(self, directory: Path) -> list[str]:
"""Build and install the PKGBUILD in `directory`, returning the installed package names."""
@abstractmethod
def is_installed(self, package: str) -> bool: ...
@abstractmethod
def system_update(self) -> None: ...
@@ -92,6 +95,9 @@ class NoopInstaller(PackageInstaller):
info(f"Skipping local package build (not on Arch): {directory}")
return []
def is_installed(self, package: str) -> bool:
return False
def system_update(self) -> None:
info("Skipping system update (not on Arch)")
@@ -101,10 +107,18 @@ class ArchInstaller(PackageInstaller):
self.helper = helper
self.flags = ["--noconfirm"] if noconfirm else []
def install(self, packages: list[str], extra_flags: list[str] | None = None) -> None:
def install(self, packages: list[str], explicit: bool = True) -> None:
if not packages:
return
subprocess.run([self.helper, "-S", "--needed", *self.flags, *(extra_flags or []), *packages], check=True)
cmd = [self.helper, "-S", "--needed", *self.flags]
if not explicit:
cmd.append("--asdeps") # Set install reason to dep (does not affect already installed packages)
subprocess.run(cmd + packages, check=True)
# Force install reason to explicit install
if explicit:
subprocess.run([self.helper, "-D", "--asexplicit", *self.flags, *packages], check=True)
def remove(self, packages: list[str]) -> None:
if not packages:
@@ -126,7 +140,7 @@ class ArchInstaller(PackageInstaller):
elif key == "depends":
depends.append(value.strip())
self.install(depends, extra_flags=["--asdeps"])
self.install(depends, explicit=False)
# Stop makepkg from resetting sudo
env = {**os.environ, "PACMAN_AUTH": "sudo"}
@@ -135,5 +149,15 @@ class ArchInstaller(PackageInstaller):
return names
def is_installed(self, package: str) -> bool:
return (
subprocess.run(
["pacman", "-Q", package],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
).returncode
== 0
)
def system_update(self) -> None:
subprocess.run([self.helper, "-Syu", *self.flags], check=True)