Skip to content

Commit

Permalink
updater: cleanup
Browse files Browse the repository at this point in the history
move package manager logic to subclasses
  • Loading branch information
piotrbartman committed Oct 2, 2024
1 parent fc9e5a1 commit 528a5d0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 3 additions & 1 deletion vmupdate/agent/source/apt/apt_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ def get_action(self, remove_obsolete: bool) -> List[str]:
"""
Return command `upgrade` or `dist-upgrade` if `remove_obsolete`.
"""
return ["dist-upgrade"] if remove_obsolete else ["upgrade"]
result = ["-y"]
result += ["dist-upgrade"] if remove_obsolete else ["upgrade"]
return result

def clean(self) -> int:
"""
Expand Down
6 changes: 2 additions & 4 deletions vmupdate/agent/source/common/package_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,15 @@ def get_packages(self) -> Dict[str, List[str]]:

def get_action(self, remove_obsolete: bool) -> List[str]:
"""
Return command for upgrade or upgrade with removing obsolete packages.
Return command and options for upgrade with optional removing obsoletes.
"""
raise NotImplementedError()

def upgrade_internal(self, remove_obsolete: bool) -> ProcessResult:
"""
Just run upgrade via CLI.
"""
cmd = [self.package_manager,
"--noconfirm" if self.package_manager == "pacman" else "-y",
*self.get_action(remove_obsolete)]
cmd = [self.package_manager, *self.get_action(remove_obsolete)]

return self.run_cmd(cmd)

Expand Down
4 changes: 2 additions & 2 deletions vmupdate/agent/source/dnf/dnf_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ def get_action(self, remove_obsolete) -> List[str]:
Disable or enforce obsolete flag in dnf/yum.
"""
if remove_obsolete:
return ["--obsoletes", "upgrade"]
return ["--setopt=obsoletes=0",
return ["-y", "--obsoletes", "upgrade"]
return ["-y", "--setopt=obsoletes=0",
"upgrade" if self.package_manager == "dnf" else "update"]

def clean(self) -> int:
Expand Down
2 changes: 1 addition & 1 deletion vmupdate/agent/source/pacman/pacman_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def get_action(self, remove_obsolete) -> List[str]:
"""
Pacman will handle obsoletions itself
"""
return ["-Syu"]
return ["--noconfirm", "-Syu"]

def clean(self) -> int:
"""
Expand Down

0 comments on commit 528a5d0

Please sign in to comment.