Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/139'
Browse files Browse the repository at this point in the history
* origin/pr/139:
  Remove pacman_api and references
  Make refresh() for pacman_cli a no-op
  Fix pacman interaction with new realtime output
  Initial support for progress reporting updates via pacman_api
  • Loading branch information
marmarek committed Jul 19, 2024
2 parents 746fe54 + 6f58852 commit 3af99eb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
rpm/
pkgs/

__pycache__/
Empty file modified vmupdate/agent/entrypoint.py
100644 → 100755
Empty file.
27 changes: 13 additions & 14 deletions vmupdate/agent/source/pacman/pacman_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.

import shutil
from typing import List
from typing import List, Dict

from source.common.package_manager import PackageManager
from source.common.process_result import ProcessResult
Expand All @@ -29,34 +28,34 @@
class PACMANCLI(PackageManager):
def __init__(self, log_handler, log_level):
super().__init__(log_handler, log_level)
self.package_manager: str = "pacman"
self.package_manager = "pacman"

def refresh(self, hard_fail: bool) -> ProcessResult:
"""
Use package manager to refresh available packages.
:param hard_fail: raise error if some repo is unavailable
Note: Is a no-op in ArchLinux because upgrade takes care of it, and
having just sync could cause problems.
See: https://github.com/QubesOS/qubes-core-admin-linux/pull/139#pullrequestreview-1845574713
:return: (exit_code, stdout, stderr)
"""
cmd = [ self.package_manager,
"-Sy" ]
return self.run_cmd(cmd)
cmd = ["true"]
return self.run_cmd(cmd)

def get_packages(self):
def get_packages(self) -> Dict[str, List[str]]:
"""
Use pacman to return the installed packages and their versions.
"""

cmd = [ self.package_manager,
"-Q" ]
cmd = [self.package_manager, "-Q"]
# EXAMPLE OUTPUT:
# qubes-vm-core 4.2.25-1
result = self.run_cmd(cmd)
result = self.run_cmd(cmd, realtime=False)

packages = {}
packages: Dict[str, List[str]] = {}
for line in result.out.splitlines():
cols = line.split()
package, version = cols
package, version = line.split()
packages.setdefault(package, []).append(version)

return packages
Expand Down

0 comments on commit 3af99eb

Please sign in to comment.