From 41769c879466b3d4a488e4aac93535f893c96cfa Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 19 Aug 2020 21:12:40 +0200 Subject: [PATCH] [packages] Alphabetize package manager implementations --- src/modules/packages/main.py | 184 ++++++++++++++++++----------------- 1 file changed, 95 insertions(+), 89 deletions(-) diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index 4f746dccc..908d778b2 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -161,63 +161,50 @@ class PackageManager(metaclass=abc.ABCMeta): self.run(packagedata["post-script"]) -class PMPackageKit(PackageManager): - backend = "packagekit" +### PACKAGE MANAGER IMPLEMENTATIONS +# +# Keep these alphabetical (presumably both by class name and backend name), +# even the Dummy implementation. +# + +class PMApk(PackageManager): + backend = "apk" def install(self, pkgs, from_local=False): for pkg in pkgs: - check_target_env_call(["pkcon", "-py", "install", pkg]) + check_target_env_call(["apk", "add", pkg]) def remove(self, pkgs): for pkg in pkgs: - check_target_env_call(["pkcon", "-py", "remove", pkg]) + check_target_env_call(["apk", "del", pkg]) def update_db(self): - check_target_env_call(["pkcon", "refresh"]) + check_target_env_call(["apk", "update"]) def update_system(self): - check_target_env_call(["pkcon", "-py", "update"]) + check_target_env_call(["apk", "upgrade", "--available"]) -class PMZypp(PackageManager): - backend = "zypp" +class PMApt(PackageManager): + backend = "apt" def install(self, pkgs, from_local=False): - check_target_env_call(["zypper", "--non-interactive", - "--quiet-install", "install", - "--auto-agree-with-licenses", - "install"] + pkgs) + check_target_env_call(["apt-get", "-q", "-y", "install"] + pkgs) def remove(self, pkgs): - check_target_env_call(["zypper", "--non-interactive", + check_target_env_call(["apt-get", "--purge", "-q", "-y", "remove"] + pkgs) + check_target_env_call(["apt-get", "--purge", "-q", "-y", + "autoremove"]) def update_db(self): - check_target_env_call(["zypper", "--non-interactive", "update"]) + check_target_env_call(["apt-get", "update"]) def update_system(self): # Doesn't need to update the system explicitly pass -class PMYum(PackageManager): - backend = "yum" - - def install(self, pkgs, from_local=False): - check_target_env_call(["yum", "-y", "install"] + pkgs) - - def remove(self, pkgs): - check_target_env_call(["yum", "--disablerepo=*", "-C", "-y", - "remove"] + pkgs) - - def update_db(self): - # Doesn't need updates - pass - - def update_system(self): - check_target_env_call(["yum", "-y", "upgrade"]) - - class PMDnf(PackageManager): backend = "dnf" @@ -238,60 +225,62 @@ class PMDnf(PackageManager): check_target_env_call(["dnf", "-y", "upgrade"]) -class PMUrpmi(PackageManager): - backend = "urpmi" +class PMDummy(PackageManager): + backend = "dummy" def install(self, pkgs, from_local=False): - check_target_env_call(["urpmi", "--download-all", "--no-suggests", - "--no-verify-rpm", "--fastunsafe", - "--ignoresize", "--nolock", - "--auto"] + pkgs) + from time import sleep + libcalamares.utils.debug("Dummy backend: Installing " + str(pkgs)) + sleep(3) def remove(self, pkgs): - check_target_env_call(["urpme", "--auto"] + pkgs) + from time import sleep + libcalamares.utils.debug("Dummy backend: Removing " + str(pkgs)) + sleep(3) def update_db(self): - check_target_env_call(["urpmi.update", "-a"]) + libcalamares.utils.debug("Dummy backend: Updating DB") def update_system(self): - # Doesn't need to update the system explicitly - pass + libcalamares.utils.debug("Dummy backend: Updating System") + def run(self, script): + libcalamares.utils.debug("Dummy backend: Running script '" + str(script) + "'") -class PMApt(PackageManager): - backend = "apt" + +class PMEntropy(PackageManager): + backend = "entropy" def install(self, pkgs, from_local=False): - check_target_env_call(["apt-get", "-q", "-y", "install"] + pkgs) + check_target_env_call(["equo", "i"] + pkgs) def remove(self, pkgs): - check_target_env_call(["apt-get", "--purge", "-q", "-y", - "remove"] + pkgs) - check_target_env_call(["apt-get", "--purge", "-q", "-y", - "autoremove"]) + check_target_env_call(["equo", "rm"] + pkgs) def update_db(self): - check_target_env_call(["apt-get", "update"]) + check_target_env_call(["equo", "update"]) def update_system(self): # Doesn't need to update the system explicitly pass -class PMXbps(PackageManager): - backend = "xbps" +class PMPackageKit(PackageManager): + backend = "packagekit" def install(self, pkgs, from_local=False): - check_target_env_call(["xbps-install", "-Sy"] + pkgs) + for pkg in pkgs: + check_target_env_call(["pkcon", "-py", "install", pkg]) def remove(self, pkgs): - check_target_env_call(["xbps-remove", "-Ry", "--noconfirm"] + pkgs) + for pkg in pkgs: + check_target_env_call(["pkcon", "-py", "remove", pkg]) def update_db(self): - check_target_env_call(["xbps-install", "-S"]) + check_target_env_call(["pkcon", "refresh"]) def update_system(self): - check_target_env_call(["xbps", "-Suy"]) + check_target_env_call(["pkcon", "-py", "update"]) class PMPacman(PackageManager): @@ -341,6 +330,23 @@ class PMPamac(PackageManager): check_target_env_call([self.backend, "upgrade", "--no-confirm"]) +class PMPisi(PackageManager): + backend = "pisi" + + def install(self, pkgs, from_local=False): + check_target_env_call(["pisi", "install" "-y"] + pkgs) + + def remove(self, pkgs): + check_target_env_call(["pisi", "remove", "-y"] + pkgs) + + def update_db(self): + check_target_env_call(["pisi", "update-repo"]) + + def update_system(self): + # Doesn't need to update the system explicitly + pass + + class PMPortage(PackageManager): backend = "portage" @@ -359,79 +365,79 @@ class PMPortage(PackageManager): pass -class PMEntropy(PackageManager): - backend = "entropy" +class PMUrpmi(PackageManager): + backend = "urpmi" def install(self, pkgs, from_local=False): - check_target_env_call(["equo", "i"] + pkgs) + check_target_env_call(["urpmi", "--download-all", "--no-suggests", + "--no-verify-rpm", "--fastunsafe", + "--ignoresize", "--nolock", + "--auto"] + pkgs) def remove(self, pkgs): - check_target_env_call(["equo", "rm"] + pkgs) + check_target_env_call(["urpme", "--auto"] + pkgs) def update_db(self): - check_target_env_call(["equo", "update"]) + check_target_env_call(["urpmi.update", "-a"]) def update_system(self): # Doesn't need to update the system explicitly pass -class PMDummy(PackageManager): - backend = "dummy" +class PMXbps(PackageManager): + backend = "xbps" def install(self, pkgs, from_local=False): - from time import sleep - libcalamares.utils.debug("Dummy backend: Installing " + str(pkgs)) - sleep(3) + check_target_env_call(["xbps-install", "-Sy"] + pkgs) def remove(self, pkgs): - from time import sleep - libcalamares.utils.debug("Dummy backend: Removing " + str(pkgs)) - sleep(3) + check_target_env_call(["xbps-remove", "-Ry", "--noconfirm"] + pkgs) def update_db(self): - libcalamares.utils.debug("Dummy backend: Updating DB") + check_target_env_call(["xbps-install", "-S"]) def update_system(self): - libcalamares.utils.debug("Dummy backend: Updating System") - - def run(self, script): - libcalamares.utils.debug("Dummy backend: Running script '" + str(script) + "'") + check_target_env_call(["xbps", "-Suy"]) -class PMPisi(PackageManager): - backend = "pisi" +class PMYum(PackageManager): + backend = "yum" def install(self, pkgs, from_local=False): - check_target_env_call(["pisi", "install" "-y"] + pkgs) + check_target_env_call(["yum", "-y", "install"] + pkgs) def remove(self, pkgs): - check_target_env_call(["pisi", "remove", "-y"] + pkgs) + check_target_env_call(["yum", "--disablerepo=*", "-C", "-y", + "remove"] + pkgs) def update_db(self): - check_target_env_call(["pisi", "update-repo"]) + # Doesn't need updates + pass def update_system(self): - # Doesn't need to update the system explicitly - pass + check_target_env_call(["yum", "-y", "upgrade"]) -class PMApk(PackageManager): - backend = "apk" +class PMZypp(PackageManager): + backend = "zypp" def install(self, pkgs, from_local=False): - for pkg in pkgs: - check_target_env_call(["apk", "add", pkg]) + check_target_env_call(["zypper", "--non-interactive", + "--quiet-install", "install", + "--auto-agree-with-licenses", + "install"] + pkgs) def remove(self, pkgs): - for pkg in pkgs: - check_target_env_call(["apk", "del", pkg]) + check_target_env_call(["zypper", "--non-interactive", + "remove"] + pkgs) def update_db(self): - check_target_env_call(["apk", "update"]) + check_target_env_call(["zypper", "--non-interactive", "update"]) def update_system(self): - check_target_env_call(["apk", "upgrade", "--available"]) + # Doesn't need to update the system explicitly + pass # Collect all the subclasses of PackageManager defined above,