[packages] add initial support for update target system

main
Philip Müller 7 years ago
parent 18bd455ae1
commit 1bd149c14e

@ -8,6 +8,7 @@
# Copyright 2016-2017, Kyle Robbertze <kyle@aims.ac.za> # Copyright 2016-2017, Kyle Robbertze <kyle@aims.ac.za>
# Copyright 2017, Alf Gaida <agaida@siduction.org> # Copyright 2017, Alf Gaida <agaida@siduction.org>
# Copyright 2018, Adriaan de Groot <groot@kde.org> # Copyright 2018, Adriaan de Groot <groot@kde.org>
# Copyright 2018, Philip Müller <philm@manjaro.org>
# #
# Calamares is free software: you can redistribute it and/or modify # Calamares is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -153,6 +154,9 @@ class PMPackageKit(PackageManager):
def update_db(self): def update_db(self):
check_target_env_call(["pkcon", "refresh"]) check_target_env_call(["pkcon", "refresh"])
def update_system(self):
# Doesn't need to update the system explicitly
pass
class PMZypp(PackageManager): class PMZypp(PackageManager):
backend = "zypp" backend = "zypp"
@ -170,6 +174,9 @@ class PMZypp(PackageManager):
def update_db(self): def update_db(self):
check_target_env_call(["zypper", "--non-interactive", "update"]) check_target_env_call(["zypper", "--non-interactive", "update"])
def update_system(self):
# Doesn't need to update the system explicitly
pass
class PMYum(PackageManager): class PMYum(PackageManager):
backend = "yum" backend = "yum"
@ -185,6 +192,9 @@ class PMYum(PackageManager):
# Doesn't need updates # Doesn't need updates
pass pass
def update_system(self):
# Doesn't need to update the system explicitly
pass
class PMDnf(PackageManager): class PMDnf(PackageManager):
backend = "dnf" backend = "dnf"
@ -199,7 +209,11 @@ class PMDnf(PackageManager):
"remove"] + pkgs) "remove"] + pkgs)
def update_db(self): def update_db(self):
# Doesn't need to update explicitly # Doesn't need updates
pass
def update_system(self):
# Doesn't need to update the system explicitly
pass pass
@ -218,6 +232,10 @@ class PMUrpmi(PackageManager):
def update_db(self): def update_db(self):
check_target_env_call(["urpmi.update", "-a"]) 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):
backend = "apt" backend = "apt"
@ -234,6 +252,10 @@ class PMApt(PackageManager):
def update_db(self): def update_db(self):
check_target_env_call(["apt-get", "update"]) check_target_env_call(["apt-get", "update"])
def update_system(self):
# Doesn't need to update the system explicitly
pass
class PMPacman(PackageManager): class PMPacman(PackageManager):
backend = "pacman" backend = "pacman"
@ -242,7 +264,7 @@ class PMPacman(PackageManager):
if from_local: if from_local:
pacman_flags = "-U" pacman_flags = "-U"
else: else:
pacman_flags = "-Sy" pacman_flags = "-S"
check_target_env_call(["pacman", pacman_flags, check_target_env_call(["pacman", pacman_flags,
"--noconfirm"] + pkgs) "--noconfirm"] + pkgs)
@ -253,6 +275,9 @@ class PMPacman(PackageManager):
def update_db(self): def update_db(self):
check_target_env_call(["pacman", "-Sy"]) check_target_env_call(["pacman", "-Sy"])
def update_system(self):
check_target_env_call(["pacman", "-Su"])
class PMPortage(PackageManager): class PMPortage(PackageManager):
backend = "portage" backend = "portage"
@ -267,6 +292,10 @@ class PMPortage(PackageManager):
def update_db(self): def update_db(self):
check_target_env_call(["emerge", "--sync"]) check_target_env_call(["emerge", "--sync"])
def update_system(self):
# Doesn't need to update the system explicitly
pass
class PMEntropy(PackageManager): class PMEntropy(PackageManager):
backend = "entropy" backend = "entropy"
@ -280,6 +309,10 @@ class PMEntropy(PackageManager):
def update_db(self): def update_db(self):
check_target_env_call(["equo", "update"]) check_target_env_call(["equo", "update"])
def update_system(self):
# Doesn't need to update the system explicitly
pass
class PMDummy(PackageManager): class PMDummy(PackageManager):
backend = "dummy" backend = "dummy"
@ -293,6 +326,9 @@ class PMDummy(PackageManager):
def update_db(self): def update_db(self):
libcalamares.utils.debug("Updating DB") libcalamares.utils.debug("Updating DB")
def update_system(self):
libcalamares.utils.debug("Updating System")
def run(self, script): def run(self, script):
libcalamares.utils.debug("Running script '" + str(script) + "'") libcalamares.utils.debug("Running script '" + str(script) + "'")
@ -309,6 +345,10 @@ class PMPisi(PackageManager):
def update_db(self): def update_db(self):
check_target_env_call(["pisi", "update-repo"]) check_target_env_call(["pisi", "update-repo"])
def update_system(self):
# Doesn't need to update the system explicitly
pass
# 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.
@ -452,6 +492,10 @@ def run():
if update_db and libcalamares.globalstorage.value("hasInternet"): if update_db and libcalamares.globalstorage.value("hasInternet"):
pkgman.update_db() pkgman.update_db()
update_system = libcalamares.job.configuration.get("update_system", False)
if update_system and libcalamares.globalstorage.value("hasInternet"):
pkgman.update_system()
operations = libcalamares.job.configuration.get("operations", []) operations = libcalamares.job.configuration.get("operations", [])
if libcalamares.globalstorage.contains("packageOperations"): if libcalamares.globalstorage.contains("packageOperations"):
operations += libcalamares.globalstorage.value("packageOperations") operations += libcalamares.globalstorage.value("packageOperations")

@ -26,9 +26,11 @@ backend: dummy
# You can run a package-manager specific update procedure # You can run a package-manager specific update procedure
# before installing packages (for instance, to update the # before installing packages (for instance, to update the
# list of packages and dependencies); this is done only if there # list of packages and dependencies); this is done only if there
# is an internet connection. Set *update_db* to true to do so. # is an internet connection. Set *update_db* and/or *update_system*
# to true to do so.
skip_if_no_internet: false skip_if_no_internet: false
update_db: true update_db: true
update_system: false
# #
# List of maps with package operations such as install or remove. # List of maps with package operations such as install or remove.

Loading…
Cancel
Save