[packages] Alphabetize package manager implementations

This commit is contained in:
Adriaan de Groot 2020-08-19 21:12:40 +02:00
parent 4a9f409422
commit 41769c8794

View File

@ -161,101 +161,28 @@ class PackageManager(metaclass=abc.ABCMeta):
self.run(packagedata["post-script"]) self.run(packagedata["post-script"])
class PMPackageKit(PackageManager): ### PACKAGE MANAGER IMPLEMENTATIONS
backend = "packagekit" #
# 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): def install(self, pkgs, from_local=False):
for pkg in pkgs: for pkg in pkgs:
check_target_env_call(["pkcon", "-py", "install", pkg]) check_target_env_call(["apk", "add", pkg])
def remove(self, pkgs): def remove(self, pkgs):
for pkg in pkgs: for pkg in pkgs:
check_target_env_call(["pkcon", "-py", "remove", pkg]) check_target_env_call(["apk", "del", pkg])
def update_db(self): def update_db(self):
check_target_env_call(["pkcon", "refresh"]) check_target_env_call(["apk", "update"])
def update_system(self): def update_system(self):
check_target_env_call(["pkcon", "-py", "update"]) check_target_env_call(["apk", "upgrade", "--available"])
class PMZypp(PackageManager):
backend = "zypp"
def install(self, pkgs, from_local=False):
check_target_env_call(["zypper", "--non-interactive",
"--quiet-install", "install",
"--auto-agree-with-licenses",
"install"] + pkgs)
def remove(self, pkgs):
check_target_env_call(["zypper", "--non-interactive",
"remove"] + pkgs)
def update_db(self):
check_target_env_call(["zypper", "--non-interactive", "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"
def install(self, pkgs, from_local=False):
check_target_env_call(["dnf", "-y", "install"] + pkgs)
def remove(self, pkgs):
# ignore the error code for now because dnf thinks removing a
# nonexistent package is an error
target_env_call(["dnf", "--disablerepo=*", "-C", "-y",
"remove"] + pkgs)
def update_db(self):
# Doesn't need updates
pass
def update_system(self):
check_target_env_call(["dnf", "-y", "upgrade"])
class PMUrpmi(PackageManager):
backend = "urpmi"
def install(self, pkgs, from_local=False):
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(["urpme", "--auto"] + pkgs)
def update_db(self):
check_target_env_call(["urpmi.update", "-a"])
def update_system(self):
# Doesn't need to update the system explicitly
pass
class PMApt(PackageManager): class PMApt(PackageManager):
@ -278,20 +205,82 @@ class PMApt(PackageManager):
pass pass
class PMXbps(PackageManager): class PMDnf(PackageManager):
backend = "xbps" backend = "dnf"
def install(self, pkgs, from_local=False): def install(self, pkgs, from_local=False):
check_target_env_call(["xbps-install", "-Sy"] + pkgs) check_target_env_call(["dnf", "-y", "install"] + pkgs)
def remove(self, pkgs): def remove(self, pkgs):
check_target_env_call(["xbps-remove", "-Ry", "--noconfirm"] + pkgs) # ignore the error code for now because dnf thinks removing a
# nonexistent package is an error
target_env_call(["dnf", "--disablerepo=*", "-C", "-y",
"remove"] + pkgs)
def update_db(self): def update_db(self):
check_target_env_call(["xbps-install", "-S"]) # Doesn't need updates
pass
def update_system(self): def update_system(self):
check_target_env_call(["xbps", "-Suy"]) check_target_env_call(["dnf", "-y", "upgrade"])
class PMDummy(PackageManager):
backend = "dummy"
def install(self, pkgs, from_local=False):
from time import sleep
libcalamares.utils.debug("Dummy backend: Installing " + str(pkgs))
sleep(3)
def remove(self, pkgs):
from time import sleep
libcalamares.utils.debug("Dummy backend: Removing " + str(pkgs))
sleep(3)
def update_db(self):
libcalamares.utils.debug("Dummy backend: Updating DB")
def update_system(self):
libcalamares.utils.debug("Dummy backend: Updating System")
def run(self, script):
libcalamares.utils.debug("Dummy backend: Running script '" + str(script) + "'")
class PMEntropy(PackageManager):
backend = "entropy"
def install(self, pkgs, from_local=False):
check_target_env_call(["equo", "i"] + pkgs)
def remove(self, pkgs):
check_target_env_call(["equo", "rm"] + pkgs)
def update_db(self):
check_target_env_call(["equo", "update"])
def update_system(self):
# Doesn't need to update the system explicitly
pass
class PMPackageKit(PackageManager):
backend = "packagekit"
def install(self, pkgs, from_local=False):
for pkg in pkgs:
check_target_env_call(["pkcon", "-py", "install", pkg])
def remove(self, pkgs):
for pkg in pkgs:
check_target_env_call(["pkcon", "-py", "remove", pkg])
def update_db(self):
check_target_env_call(["pkcon", "refresh"])
def update_system(self):
check_target_env_call(["pkcon", "-py", "update"])
class PMPacman(PackageManager): class PMPacman(PackageManager):
@ -341,6 +330,23 @@ class PMPamac(PackageManager):
check_target_env_call([self.backend, "upgrade", "--no-confirm"]) 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): class PMPortage(PackageManager):
backend = "portage" backend = "portage"
@ -359,81 +365,81 @@ class PMPortage(PackageManager):
pass pass
class PMEntropy(PackageManager): class PMUrpmi(PackageManager):
backend = "entropy" backend = "urpmi"
def install(self, pkgs, from_local=False): 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): def remove(self, pkgs):
check_target_env_call(["equo", "rm"] + pkgs) check_target_env_call(["urpme", "--auto"] + pkgs)
def update_db(self): def update_db(self):
check_target_env_call(["equo", "update"]) check_target_env_call(["urpmi.update", "-a"])
def update_system(self): def update_system(self):
# Doesn't need to update the system explicitly # Doesn't need to update the system explicitly
pass pass
class PMDummy(PackageManager): class PMXbps(PackageManager):
backend = "dummy" backend = "xbps"
def install(self, pkgs, from_local=False): def install(self, pkgs, from_local=False):
from time import sleep check_target_env_call(["xbps-install", "-Sy"] + pkgs)
libcalamares.utils.debug("Dummy backend: Installing " + str(pkgs))
sleep(3)
def remove(self, pkgs): def remove(self, pkgs):
from time import sleep check_target_env_call(["xbps-remove", "-Ry", "--noconfirm"] + pkgs)
libcalamares.utils.debug("Dummy backend: Removing " + str(pkgs))
sleep(3)
def update_db(self): def update_db(self):
libcalamares.utils.debug("Dummy backend: Updating DB") check_target_env_call(["xbps-install", "-S"])
def update_system(self): def update_system(self):
libcalamares.utils.debug("Dummy backend: Updating System") check_target_env_call(["xbps", "-Suy"])
def run(self, script):
libcalamares.utils.debug("Dummy backend: Running script '" + str(script) + "'")
class PMPisi(PackageManager): class PMYum(PackageManager):
backend = "pisi" backend = "yum"
def install(self, pkgs, from_local=False): 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): 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): def update_db(self):
check_target_env_call(["pisi", "update-repo"]) # Doesn't need updates
pass
def update_system(self):
check_target_env_call(["yum", "-y", "upgrade"])
class PMZypp(PackageManager):
backend = "zypp"
def install(self, pkgs, from_local=False):
check_target_env_call(["zypper", "--non-interactive",
"--quiet-install", "install",
"--auto-agree-with-licenses",
"install"] + pkgs)
def remove(self, pkgs):
check_target_env_call(["zypper", "--non-interactive",
"remove"] + pkgs)
def update_db(self):
check_target_env_call(["zypper", "--non-interactive", "update"])
def update_system(self): def update_system(self):
# Doesn't need to update the system explicitly # Doesn't need to update the system explicitly
pass pass
class PMApk(PackageManager):
backend = "apk"
def install(self, pkgs, from_local=False):
for pkg in pkgs:
check_target_env_call(["apk", "add", pkg])
def remove(self, pkgs):
for pkg in pkgs:
check_target_env_call(["apk", "del", pkg])
def update_db(self):
check_target_env_call(["apk", "update"])
def update_system(self):
check_target_env_call(["apk", "upgrade", "--available"])
# Collect all the subclasses of PackageManager defined above, # Collect all the subclasses of PackageManager defined above,
# and index them based on the backend property of each class. # and index them based on the backend property of each class.
backend_managers = [ backend_managers = [