[packages] Add support for more pacman options
This commit is contained in:
parent
01d55254f2
commit
fa10bb8dd3
@ -379,6 +379,7 @@ class PMPacman(PackageManager):
|
||||
def __init__(self):
|
||||
import re
|
||||
progress_match = re.compile("^\\((\\d+)/(\\d+)\\)")
|
||||
|
||||
def line_cb(line):
|
||||
if line.startswith(":: "):
|
||||
self.in_package_changes = "package changes" in line
|
||||
@ -396,30 +397,64 @@ class PMPacman(PackageManager):
|
||||
self.in_package_changes = False
|
||||
self.line_cb = line_cb
|
||||
|
||||
self.pacman_num_retries = libcalamares.job.configuration.get("pacman_num_retries", 0)
|
||||
self.pacman_disable_timeout = libcalamares.job.configuration.get("pacman_disable_download_timeout", False)
|
||||
self.pacman_needed_only = libcalamares.job.configuration.get("pacman_needed_only", False)
|
||||
|
||||
def reset_progress(self):
|
||||
self.in_package_changes = False
|
||||
# These are globals
|
||||
self.progress_fraction = (completed_packages * 1.0 / total_packages)
|
||||
|
||||
def run_pacman(self, command):
|
||||
# Call pacman in a loop until it is successful or the number of retries is exceeded
|
||||
pacman_count = 0
|
||||
while pacman_count <= self.pacman_num_retries:
|
||||
pacman_count += 1
|
||||
try:
|
||||
libcalamares.utils.target_env_process_output(command, self.line_cb)
|
||||
return
|
||||
except subprocess.CalledProcessError:
|
||||
if pacman_count <= self.pacman_num_retries:
|
||||
pass
|
||||
else:
|
||||
raise
|
||||
|
||||
def install(self, pkgs, from_local=False):
|
||||
command = ["pacman"]
|
||||
|
||||
if from_local:
|
||||
pacman_flags = "-U"
|
||||
command.append("-U")
|
||||
else:
|
||||
pacman_flags = "-S"
|
||||
command.append("-S")
|
||||
|
||||
command.append("--noconfirm")
|
||||
|
||||
if self.pacman_needed_only is True:
|
||||
command.append("--needed")
|
||||
|
||||
if self.pacman_disable_timeout is True:
|
||||
command.append("--disable-download-timeout")
|
||||
|
||||
command += pkgs
|
||||
|
||||
self.run_pacman(command)
|
||||
|
||||
self.reset_progress()
|
||||
libcalamares.utils.target_env_process_output(["pacman", pacman_flags,
|
||||
"--noconfirm"] + pkgs, self.line_cb)
|
||||
|
||||
def remove(self, pkgs):
|
||||
self.reset_progress()
|
||||
libcalamares.utils.target_env_process_output(["pacman", "-Rs", "--noconfirm"] + pkgs, self.line_cb)
|
||||
self.run_pacman(["pacman", "-Rs", "--noconfirm"] + pkgs)
|
||||
|
||||
def update_db(self):
|
||||
check_target_env_call(["pacman", "-Sy"])
|
||||
self.run_pacman(["pacman", "-Sy"])
|
||||
|
||||
def update_system(self):
|
||||
check_target_env_call(["pacman", "-Su", "--noconfirm"])
|
||||
command = ["pacman", "-Su", "--noconfirm"]
|
||||
if self.pacman_disable_timeout is True:
|
||||
command.append("--disable-download-timeout")
|
||||
|
||||
self.run_pacman(command)
|
||||
|
||||
|
||||
class PMPamac(PackageManager):
|
||||
|
@ -62,6 +62,22 @@ skip_if_no_internet: false
|
||||
update_db: true
|
||||
update_system: false
|
||||
|
||||
# pacman specific options
|
||||
#
|
||||
# pacman_num_retries should be a positive integer which sepcifies the
|
||||
# number of times the call to pacman will be retried in the event of a
|
||||
# failure. If it is missing, it will be set to 0
|
||||
#
|
||||
# pacman_disable_download_timeout is a boolean that, when true, includes
|
||||
# the flag --disable-download-timeout on calls to pacman. When missing,
|
||||
# false is assumed
|
||||
#
|
||||
# pacman_needed_only is a boolean that includes the pacman argument --needed
|
||||
# when set to true. If missing, false is assumed
|
||||
pacman_num_retries: 0
|
||||
pacman_disable_download_timeout: false
|
||||
pacman_needed_only: false
|
||||
|
||||
#
|
||||
# List of maps with package operations such as install or remove.
|
||||
# Distro developers can provide a list of packages to remove
|
||||
|
@ -26,6 +26,10 @@ properties:
|
||||
update_system: { type: boolean, default: false }
|
||||
skip_if_no_internet: { type: boolean, default: false }
|
||||
|
||||
pacman_num_retries: { type: integer, default: 0 }
|
||||
pacman_disable_download_timeout: { type: boolean, default: false }
|
||||
pacman_needed_only: { type: boolean, default: false }
|
||||
|
||||
operations:
|
||||
type: array
|
||||
items:
|
||||
|
Loading…
Reference in New Issue
Block a user