2014-08-29 22:55:11 +02:00
|
|
|
#!/usr/bin/env python3
|
2015-02-18 15:06:10 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
2020-08-25 16:05:56 +02:00
|
|
|
# === This file is part of Calamares - <https://calamares.io> ===
|
2014-08-29 22:55:11 +02:00
|
|
|
#
|
2020-08-24 16:36:47 +02:00
|
|
|
# SPDX-FileCopyrightText: 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
|
|
|
|
# SPDX-FileCopyrightText: 2015-2017 Teo Mrnjavac <teo@kde.org>
|
|
|
|
# SPDX-FileCopyrightText: 2016-2017 Kyle Robbertze <kyle@aims.ac.za>
|
|
|
|
# SPDX-FileCopyrightText: 2017 Alf Gaida <agaida@siduction.org>
|
|
|
|
# SPDX-FileCopyrightText: 2018 Adriaan de Groot <groot@kde.org>
|
|
|
|
# SPDX-FileCopyrightText: 2018 Philip Müller <philm@manjaro.org>
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2014-08-29 22:55:11 +02:00
|
|
|
#
|
2020-08-25 16:05:56 +02:00
|
|
|
# Calamares is Free Software: see the License-Identifier above.
|
2014-08-29 22:55:11 +02:00
|
|
|
#
|
|
|
|
|
2017-08-28 22:26:26 +02:00
|
|
|
import abc
|
|
|
|
from string import Template
|
2016-11-02 17:00:08 +01:00
|
|
|
import subprocess
|
2017-08-28 22:26:26 +02:00
|
|
|
|
2014-08-29 22:55:11 +02:00
|
|
|
import libcalamares
|
2015-08-06 12:13:21 +02:00
|
|
|
from libcalamares.utils import check_target_env_call, target_env_call
|
2017-08-30 17:03:52 +02:00
|
|
|
from libcalamares.utils import gettext_path, gettext_languages
|
2015-02-18 15:47:24 +01:00
|
|
|
|
2017-08-30 16:08:44 +02:00
|
|
|
import gettext
|
2017-08-30 17:03:52 +02:00
|
|
|
_translation = gettext.translation("calamares-python",
|
|
|
|
localedir=gettext_path(),
|
|
|
|
languages=gettext_languages(),
|
|
|
|
fallback=True)
|
|
|
|
_ = _translation.gettext
|
|
|
|
_n = _translation.ngettext
|
2017-08-30 16:08:44 +02:00
|
|
|
|
|
|
|
|
2017-08-31 09:51:18 +02:00
|
|
|
total_packages = 0 # For the entire job
|
|
|
|
completed_packages = 0 # Done so far for this job
|
|
|
|
group_packages = 0 # One group of packages from an -install or -remove entry
|
2017-08-30 16:08:44 +02:00
|
|
|
|
2021-11-09 14:42:12 +01:00
|
|
|
# A PM object may set this to a string (take care of translations!)
|
|
|
|
# to override the string produced by pretty_status_message()
|
|
|
|
custom_status_message = None
|
|
|
|
|
2017-08-30 17:03:52 +02:00
|
|
|
INSTALL = object()
|
|
|
|
REMOVE = object()
|
|
|
|
mode_packages = None # Changes to INSTALL or REMOVE
|
|
|
|
|
|
|
|
|
|
|
|
def _change_mode(mode):
|
|
|
|
global mode_packages
|
|
|
|
mode_packages = mode
|
|
|
|
libcalamares.job.setprogress(completed_packages * 1.0 / total_packages)
|
|
|
|
|
|
|
|
|
2017-08-30 16:08:44 +02:00
|
|
|
def pretty_name():
|
2020-03-09 21:40:45 +01:00
|
|
|
return _("Install packages.")
|
|
|
|
|
|
|
|
|
|
|
|
def pretty_status_message():
|
2021-11-09 14:42:12 +01:00
|
|
|
if custom_status_message is not None:
|
|
|
|
return custom_status_message
|
2017-08-31 09:51:18 +02:00
|
|
|
if not group_packages:
|
2017-12-01 22:48:02 +01:00
|
|
|
if (total_packages > 0):
|
|
|
|
# Outside the context of an operation
|
|
|
|
s = _("Processing packages (%(count)d / %(total)d)")
|
|
|
|
else:
|
|
|
|
s = _("Install packages.")
|
|
|
|
|
2017-08-31 09:51:18 +02:00
|
|
|
elif mode_packages is INSTALL:
|
|
|
|
s = _n("Installing one package.",
|
|
|
|
"Installing %(num)d packages.", group_packages)
|
2017-08-30 17:03:52 +02:00
|
|
|
elif mode_packages is REMOVE:
|
2017-08-31 09:51:18 +02:00
|
|
|
s = _n("Removing one package.",
|
|
|
|
"Removing %(num)d packages.", group_packages)
|
2017-08-30 17:03:52 +02:00
|
|
|
else:
|
|
|
|
# No mode, generic description
|
2017-08-31 09:51:18 +02:00
|
|
|
s = _("Install packages.")
|
|
|
|
|
|
|
|
return s % {"num": group_packages,
|
|
|
|
"count": completed_packages,
|
|
|
|
"total": total_packages}
|
2017-08-30 16:08:44 +02:00
|
|
|
|
2017-03-29 20:37:00 +02:00
|
|
|
|
2017-08-28 22:26:26 +02:00
|
|
|
class PackageManager(metaclass=abc.ABCMeta):
|
2017-03-29 20:37:00 +02:00
|
|
|
"""
|
2017-08-28 22:26:26 +02:00
|
|
|
Package manager base class. A subclass implements package management
|
|
|
|
for a specific backend, and must have a class property `backend`
|
|
|
|
with the string identifier for that backend.
|
2015-02-20 20:54:25 +01:00
|
|
|
|
2017-08-28 22:26:26 +02:00
|
|
|
Subclasses are collected below to populate the list of possible
|
|
|
|
backends.
|
2015-02-20 20:54:25 +01:00
|
|
|
"""
|
2017-08-28 22:26:26 +02:00
|
|
|
backend = None
|
2014-08-29 22:55:11 +02:00
|
|
|
|
2017-08-28 22:26:26 +02:00
|
|
|
@abc.abstractmethod
|
2015-03-02 00:28:14 +01:00
|
|
|
def install(self, pkgs, from_local=False):
|
2017-08-29 10:18:47 +02:00
|
|
|
"""
|
|
|
|
Install a list of packages (named) into the system.
|
|
|
|
Although this handles lists, in practice it is called
|
|
|
|
with one package at a time.
|
|
|
|
|
|
|
|
@param pkgs: list[str]
|
|
|
|
list of package names
|
|
|
|
@param from_local: bool
|
|
|
|
if True, then these are local packages (on disk) and the
|
|
|
|
pkgs names are paths.
|
|
|
|
"""
|
2017-08-28 22:26:26 +02:00
|
|
|
pass
|
2014-08-29 22:55:11 +02:00
|
|
|
|
2017-08-28 22:26:26 +02:00
|
|
|
@abc.abstractmethod
|
2014-08-29 22:55:11 +02:00
|
|
|
def remove(self, pkgs):
|
2017-08-29 10:18:47 +02:00
|
|
|
"""
|
|
|
|
Removes packages.
|
2015-02-20 20:54:25 +01:00
|
|
|
|
2017-08-29 10:18:47 +02:00
|
|
|
@param pkgs: list[str]
|
|
|
|
list of package names
|
2015-02-20 20:54:25 +01:00
|
|
|
"""
|
2017-08-28 22:26:26 +02:00
|
|
|
pass
|
2014-08-29 22:55:11 +02:00
|
|
|
|
2017-08-28 22:26:26 +02:00
|
|
|
@abc.abstractmethod
|
2016-11-02 13:03:44 +01:00
|
|
|
def update_db(self):
|
2017-08-28 22:26:26 +02:00
|
|
|
pass
|
2016-11-02 13:03:44 +01:00
|
|
|
|
2017-01-26 09:36:05 +01:00
|
|
|
def run(self, script):
|
|
|
|
if script != "":
|
2017-02-20 13:22:18 +01:00
|
|
|
check_target_env_call(script.split(" "))
|
2017-01-26 09:36:05 +01:00
|
|
|
|
2017-08-29 10:18:47 +02:00
|
|
|
def install_package(self, packagedata, from_local=False):
|
|
|
|
"""
|
|
|
|
Install a package from a single entry in the install list.
|
|
|
|
This can be either a single package name, or an object
|
2018-11-27 12:52:24 +01:00
|
|
|
with pre- and post-scripts. If @p packagedata is a dict,
|
|
|
|
it is assumed to follow the documented structure.
|
2017-08-29 10:18:47 +02:00
|
|
|
|
|
|
|
@param packagedata: str|dict
|
|
|
|
@param from_local: bool
|
|
|
|
see install.from_local
|
|
|
|
"""
|
|
|
|
if isinstance(packagedata, str):
|
|
|
|
self.install([packagedata], from_local=from_local)
|
|
|
|
else:
|
|
|
|
self.run(packagedata["pre-script"])
|
|
|
|
self.install([packagedata["package"]], from_local=from_local)
|
|
|
|
self.run(packagedata["post-script"])
|
|
|
|
|
2018-11-27 12:52:24 +01:00
|
|
|
def remove_package(self, packagedata):
|
|
|
|
"""
|
|
|
|
Remove a package from a single entry in the remove list.
|
|
|
|
This can be either a single package name, or an object
|
|
|
|
with pre- and post-scripts. If @p packagedata is a dict,
|
|
|
|
it is assumed to follow the documented structure.
|
|
|
|
|
|
|
|
@param packagedata: str|dict
|
|
|
|
"""
|
|
|
|
if isinstance(packagedata, str):
|
2019-01-03 14:36:48 +01:00
|
|
|
self.remove([packagedata])
|
2018-11-27 12:52:24 +01:00
|
|
|
else:
|
|
|
|
self.run(packagedata["pre-script"])
|
2019-01-03 14:36:48 +01:00
|
|
|
self.remove([packagedata["package"]])
|
2018-11-27 12:52:24 +01:00
|
|
|
self.run(packagedata["post-script"])
|
|
|
|
|
2021-07-26 21:31:57 +02:00
|
|
|
def operation_install(self, package_list, from_local=False):
|
|
|
|
"""
|
|
|
|
Installs the list of packages named in @p package_list .
|
|
|
|
These can be strings -- plain package names -- or
|
|
|
|
structures (with a pre- and post-install step).
|
|
|
|
|
|
|
|
This operation is called for "critical" packages,
|
|
|
|
which are expected to succeed, or fail, all together.
|
|
|
|
However, if there are packages with pre- or post-scripts,
|
|
|
|
then packages are installed one-by-one instead.
|
|
|
|
|
|
|
|
NOTE: package managers may reimplement this method
|
|
|
|
NOTE: exceptions are expected to leave this method, to indicate
|
|
|
|
failure of the installation.
|
|
|
|
"""
|
|
|
|
if all([isinstance(x, str) for x in package_list]):
|
|
|
|
self.install(package_list, from_local=from_local)
|
|
|
|
else:
|
|
|
|
for package in package_list:
|
|
|
|
self.install_package(package, from_local=from_local)
|
|
|
|
|
|
|
|
def operation_try_install(self, package_list):
|
|
|
|
"""
|
|
|
|
Installs the list of packages named in @p package_list .
|
|
|
|
These can be strings -- plain package names -- or
|
|
|
|
structures (with a pre- and post-install step).
|
|
|
|
|
|
|
|
This operation is called for "non-critical" packages,
|
|
|
|
which can succeed or fail without affecting the overall installation.
|
|
|
|
Packages are installed one-by-one to support package managers
|
|
|
|
that do not have a "install as much as you can" mode.
|
|
|
|
|
|
|
|
NOTE: package managers may reimplement this method
|
|
|
|
NOTE: no package-installation exceptions should be raised
|
|
|
|
"""
|
|
|
|
# we make a separate package manager call for each package so a
|
|
|
|
# single failing package won't stop all of them
|
|
|
|
for package in package_list:
|
|
|
|
try:
|
|
|
|
self.install_package(package)
|
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
libcalamares.utils.warning("Could not install package %s" % package)
|
|
|
|
|
|
|
|
def operation_remove(self, package_list):
|
|
|
|
"""
|
|
|
|
Removes the list of packages named in @p package_list .
|
|
|
|
These can be strings -- plain package names -- or
|
|
|
|
structures (with a pre- and post-install step).
|
|
|
|
|
|
|
|
This operation is called for "critical" packages, which are
|
|
|
|
expected to succeed or fail all together.
|
|
|
|
However, if there are packages with pre- or post-scripts,
|
|
|
|
then packages are removed one-by-one instead.
|
|
|
|
|
|
|
|
NOTE: package managers may reimplement this method
|
|
|
|
NOTE: exceptions should be raised to indicate failure
|
|
|
|
"""
|
|
|
|
if all([isinstance(x, str) for x in package_list]):
|
|
|
|
self.remove(package_list)
|
|
|
|
else:
|
|
|
|
for package in package_list:
|
|
|
|
self.remove_package(package)
|
|
|
|
|
|
|
|
def operation_try_remove(self, package_list):
|
|
|
|
"""
|
|
|
|
Same relation as try_install has to install, except it removes
|
|
|
|
packages instead. Packages are removed one-by-one.
|
|
|
|
|
|
|
|
NOTE: package managers may reimplement this method
|
|
|
|
NOTE: no package-installation exceptions should be raised
|
|
|
|
"""
|
|
|
|
for package in package_list:
|
|
|
|
try:
|
|
|
|
self.remove_package(package)
|
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
libcalamares.utils.warning("Could not remove package %s" % package)
|
2015-02-18 15:47:24 +01:00
|
|
|
|
2020-08-19 21:12:40 +02:00
|
|
|
### PACKAGE MANAGER IMPLEMENTATIONS
|
|
|
|
#
|
|
|
|
# Keep these alphabetical (presumably both by class name and backend name),
|
|
|
|
# even the Dummy implementation.
|
|
|
|
#
|
|
|
|
|
|
|
|
class PMApk(PackageManager):
|
|
|
|
backend = "apk"
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
def install(self, pkgs, from_local=False):
|
|
|
|
for pkg in pkgs:
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["apk", "add", pkg])
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
def remove(self, pkgs):
|
|
|
|
for pkg in pkgs:
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["apk", "del", pkg])
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
def update_db(self):
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["apk", "update"])
|
2017-08-28 22:26:26 +02:00
|
|
|
|
2018-06-17 12:53:31 +02:00
|
|
|
def update_system(self):
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["apk", "upgrade", "--available"])
|
2017-08-28 22:26:26 +02:00
|
|
|
|
2020-07-05 09:37:28 +02:00
|
|
|
|
2020-08-19 21:12:40 +02:00
|
|
|
class PMApt(PackageManager):
|
|
|
|
backend = "apt"
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
def install(self, pkgs, from_local=False):
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["apt-get", "-q", "-y", "install"] + pkgs)
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
def remove(self, pkgs):
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["apt-get", "--purge", "-q", "-y",
|
2017-08-29 10:18:47 +02:00
|
|
|
"remove"] + pkgs)
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["apt-get", "--purge", "-q", "-y",
|
|
|
|
"autoremove"])
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
def update_db(self):
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["apt-get", "update"])
|
2017-08-28 22:26:26 +02:00
|
|
|
|
2018-06-17 12:53:31 +02:00
|
|
|
def update_system(self):
|
|
|
|
# Doesn't need to update the system explicitly
|
|
|
|
pass
|
2017-08-28 22:26:26 +02:00
|
|
|
|
2020-07-05 09:37:28 +02:00
|
|
|
|
2017-08-28 22:26:26 +02:00
|
|
|
class PMDnf(PackageManager):
|
|
|
|
backend = "dnf"
|
|
|
|
|
|
|
|
def install(self, pkgs, from_local=False):
|
2018-06-18 13:52:07 +02:00
|
|
|
check_target_env_call(["dnf", "-y", "install"] + pkgs)
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
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",
|
2017-08-29 10:18:47 +02:00
|
|
|
"remove"] + pkgs)
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
def update_db(self):
|
2018-06-17 12:53:31 +02:00
|
|
|
# Doesn't need updates
|
|
|
|
pass
|
|
|
|
|
|
|
|
def update_system(self):
|
2018-06-18 13:52:07 +02:00
|
|
|
check_target_env_call(["dnf", "-y", "upgrade"])
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
|
2020-08-19 21:12:40 +02:00
|
|
|
class PMDummy(PackageManager):
|
|
|
|
backend = "dummy"
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
def install(self, pkgs, from_local=False):
|
2020-08-19 21:12:40 +02:00
|
|
|
from time import sleep
|
|
|
|
libcalamares.utils.debug("Dummy backend: Installing " + str(pkgs))
|
|
|
|
sleep(3)
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
def remove(self, pkgs):
|
2020-08-19 21:12:40 +02:00
|
|
|
from time import sleep
|
|
|
|
libcalamares.utils.debug("Dummy backend: Removing " + str(pkgs))
|
|
|
|
sleep(3)
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
def update_db(self):
|
2020-08-19 21:12:40 +02:00
|
|
|
libcalamares.utils.debug("Dummy backend: Updating DB")
|
2017-08-28 22:26:26 +02:00
|
|
|
|
2018-06-17 12:53:31 +02:00
|
|
|
def update_system(self):
|
2020-08-19 21:12:40 +02:00
|
|
|
libcalamares.utils.debug("Dummy backend: Updating System")
|
2018-06-17 12:53:31 +02:00
|
|
|
|
2020-08-19 21:12:40 +02:00
|
|
|
def run(self, script):
|
|
|
|
libcalamares.utils.debug("Dummy backend: Running script '" + str(script) + "'")
|
2017-08-28 22:26:26 +02:00
|
|
|
|
2020-08-19 21:12:40 +02:00
|
|
|
|
|
|
|
class PMEntropy(PackageManager):
|
|
|
|
backend = "entropy"
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
def install(self, pkgs, from_local=False):
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["equo", "i"] + pkgs)
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
def remove(self, pkgs):
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["equo", "rm"] + pkgs)
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
def update_db(self):
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["equo", "update"])
|
2017-08-28 22:26:26 +02:00
|
|
|
|
2018-06-17 12:53:31 +02:00
|
|
|
def update_system(self):
|
|
|
|
# Doesn't need to update the system explicitly
|
|
|
|
pass
|
|
|
|
|
2021-04-23 23:04:51 +02:00
|
|
|
|
|
|
|
class PMLuet(PackageManager):
|
2021-04-22 18:18:41 +02:00
|
|
|
backend = "luet"
|
|
|
|
|
|
|
|
def install(self, pkgs, from_local=False):
|
|
|
|
check_target_env_call(["luet", "install", "-y"] + pkgs)
|
|
|
|
|
|
|
|
def remove(self, pkgs):
|
|
|
|
check_target_env_call(["luet", "uninstall", "-y"] + pkgs)
|
|
|
|
|
|
|
|
def update_db(self):
|
|
|
|
# Luet checks for DB update everytime its ran.
|
|
|
|
pass
|
|
|
|
|
|
|
|
def update_system(self):
|
|
|
|
check_target_env_call(["luet", "upgrade", "-y"])
|
2021-04-23 23:04:51 +02:00
|
|
|
|
2020-07-05 09:37:28 +02:00
|
|
|
|
2020-08-19 21:12:40 +02:00
|
|
|
class PMPackageKit(PackageManager):
|
|
|
|
backend = "packagekit"
|
2020-06-11 11:45:50 +02:00
|
|
|
|
|
|
|
def install(self, pkgs, from_local=False):
|
2020-08-19 21:12:40 +02:00
|
|
|
for pkg in pkgs:
|
|
|
|
check_target_env_call(["pkcon", "-py", "install", pkg])
|
2020-06-11 11:45:50 +02:00
|
|
|
|
|
|
|
def remove(self, pkgs):
|
2020-08-19 21:12:40 +02:00
|
|
|
for pkg in pkgs:
|
|
|
|
check_target_env_call(["pkcon", "-py", "remove", pkg])
|
2020-06-11 11:45:50 +02:00
|
|
|
|
|
|
|
def update_db(self):
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["pkcon", "refresh"])
|
2020-06-11 11:45:50 +02:00
|
|
|
|
|
|
|
def update_system(self):
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["pkcon", "-py", "update"])
|
2017-08-28 22:26:26 +02:00
|
|
|
|
2020-07-05 09:37:28 +02:00
|
|
|
|
2017-08-28 22:26:26 +02:00
|
|
|
class PMPacman(PackageManager):
|
|
|
|
backend = "pacman"
|
|
|
|
|
2021-11-09 13:07:29 +01:00
|
|
|
def __init__(self):
|
|
|
|
import re
|
|
|
|
progress_match = re.compile("^\\((\\d+)/(\\d+)\\)")
|
2021-11-25 18:52:41 +01:00
|
|
|
|
2021-11-09 13:07:29 +01:00
|
|
|
def line_cb(line):
|
2021-11-09 14:42:12 +01:00
|
|
|
if line.startswith(":: "):
|
2022-01-17 23:24:56 +01:00
|
|
|
self.in_package_changes = "package" in line or "hooks" in line
|
2021-11-09 14:42:12 +01:00
|
|
|
else:
|
|
|
|
if self.in_package_changes and line.endswith("...\n"):
|
|
|
|
# Update the message, untranslated; do not change the
|
|
|
|
# progress percentage, since there may be more "installing..."
|
|
|
|
# lines in the output for the group, than packages listed
|
|
|
|
# explicitly. We don't know how to calculate proper progress.
|
|
|
|
global custom_status_message
|
2021-11-09 15:25:06 +01:00
|
|
|
custom_status_message = "pacman: " + line.strip()
|
2021-11-09 14:42:12 +01:00
|
|
|
libcalamares.job.setprogress(self.progress_fraction)
|
2022-01-17 14:07:09 +01:00
|
|
|
libcalamares.utils.debug(line)
|
2021-11-09 14:42:12 +01:00
|
|
|
|
|
|
|
self.in_package_changes = False
|
2021-11-09 13:07:29 +01:00
|
|
|
self.line_cb = line_cb
|
|
|
|
|
2021-11-29 11:59:09 +01:00
|
|
|
pacman = libcalamares.job.configuration.get("pacman", None)
|
|
|
|
if pacman is None:
|
|
|
|
pacman = dict()
|
|
|
|
if type(pacman) is not dict:
|
|
|
|
libcalamares.utils.warning("Job configuration *pacman* will be ignored.")
|
|
|
|
pacman = dict()
|
2021-11-29 14:23:15 +01:00
|
|
|
self.pacman_num_retries = pacman.get("num_retries", 0)
|
|
|
|
self.pacman_disable_timeout = pacman.get("disable_download_timeout", False)
|
|
|
|
self.pacman_needed_only = pacman.get("needed_only", False)
|
2021-11-25 18:52:41 +01:00
|
|
|
|
2021-11-09 14:42:12 +01:00
|
|
|
def reset_progress(self):
|
|
|
|
self.in_package_changes = False
|
|
|
|
# These are globals
|
|
|
|
self.progress_fraction = (completed_packages * 1.0 / total_packages)
|
|
|
|
|
2021-11-26 15:30:18 +01:00
|
|
|
def run_pacman(self, command, callback=False):
|
2021-11-28 22:56:16 +01:00
|
|
|
"""
|
|
|
|
Call pacman in a loop until it is successful or the number of retries is exceeded
|
|
|
|
:param command: The pacman command to run
|
|
|
|
:param callback: An optional boolean that indicates if this pacman run should use the callback
|
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
|
2021-11-25 18:52:41 +01:00
|
|
|
pacman_count = 0
|
|
|
|
while pacman_count <= self.pacman_num_retries:
|
|
|
|
pacman_count += 1
|
|
|
|
try:
|
2022-03-04 14:28:07 +01:00
|
|
|
if False: # callback:
|
2021-11-26 15:30:18 +01:00
|
|
|
libcalamares.utils.target_env_process_output(command, self.line_cb)
|
|
|
|
else:
|
|
|
|
libcalamares.utils.target_env_process_output(command)
|
|
|
|
|
2021-11-25 18:52:41 +01:00
|
|
|
return
|
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
if pacman_count <= self.pacman_num_retries:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
raise
|
|
|
|
|
2017-08-28 22:26:26 +02:00
|
|
|
def install(self, pkgs, from_local=False):
|
2021-11-25 18:52:41 +01:00
|
|
|
command = ["pacman"]
|
|
|
|
|
2017-08-28 22:26:26 +02:00
|
|
|
if from_local:
|
2021-11-25 18:52:41 +01:00
|
|
|
command.append("-U")
|
2017-08-28 22:26:26 +02:00
|
|
|
else:
|
2021-11-25 18:52:41 +01:00
|
|
|
command.append("-S")
|
|
|
|
|
2022-01-17 23:24:56 +01:00
|
|
|
# Don't ask for user intervention, take the default action
|
2021-11-25 18:52:41 +01:00
|
|
|
command.append("--noconfirm")
|
|
|
|
|
2022-01-17 23:24:56 +01:00
|
|
|
# Don't report download progress for each file
|
|
|
|
command.append("--noprogressbar")
|
|
|
|
|
2021-11-25 18:52:41 +01:00
|
|
|
if self.pacman_needed_only is True:
|
|
|
|
command.append("--needed")
|
|
|
|
|
|
|
|
if self.pacman_disable_timeout is True:
|
|
|
|
command.append("--disable-download-timeout")
|
|
|
|
|
|
|
|
command += pkgs
|
|
|
|
|
2021-11-09 14:42:12 +01:00
|
|
|
self.reset_progress()
|
2021-11-26 17:56:32 +01:00
|
|
|
self.run_pacman(command, True)
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
def remove(self, pkgs):
|
2021-11-09 14:42:12 +01:00
|
|
|
self.reset_progress()
|
2021-11-26 15:30:18 +01:00
|
|
|
self.run_pacman(["pacman", "-Rs", "--noconfirm"] + pkgs, True)
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
def update_db(self):
|
2021-11-25 18:52:41 +01:00
|
|
|
self.run_pacman(["pacman", "-Sy"])
|
2017-08-28 22:26:26 +02:00
|
|
|
|
2018-06-17 12:53:31 +02:00
|
|
|
def update_system(self):
|
2021-11-25 18:52:41 +01:00
|
|
|
command = ["pacman", "-Su", "--noconfirm"]
|
|
|
|
if self.pacman_disable_timeout is True:
|
|
|
|
command.append("--disable-download-timeout")
|
|
|
|
|
2021-11-26 17:56:32 +01:00
|
|
|
self.run_pacman(command)
|
2020-07-05 09:35:52 +02:00
|
|
|
|
|
|
|
|
2020-06-21 18:24:29 +02:00
|
|
|
class PMPamac(PackageManager):
|
|
|
|
backend = "pamac"
|
2020-07-05 09:35:52 +02:00
|
|
|
|
|
|
|
def del_db_lock(self, lock="/var/lib/pacman/db.lck"):
|
2020-06-21 19:03:21 +02:00
|
|
|
# In case some error or crash, the database will be locked,
|
|
|
|
# resulting in remaining packages not being installed.
|
2020-07-05 09:35:52 +02:00
|
|
|
check_target_env_call(["rm", "-f", lock])
|
2020-06-21 18:24:29 +02:00
|
|
|
|
|
|
|
def install(self, pkgs, from_local=False):
|
2020-07-05 09:35:52 +02:00
|
|
|
self.del_db_lock()
|
2020-06-22 01:12:02 +02:00
|
|
|
check_target_env_call([self.backend, "install", "--no-confirm"] + pkgs)
|
2020-06-21 18:24:29 +02:00
|
|
|
|
|
|
|
def remove(self, pkgs):
|
2020-07-05 09:35:52 +02:00
|
|
|
self.del_db_lock()
|
2020-06-22 00:43:31 +02:00
|
|
|
check_target_env_call([self.backend, "remove", "--no-confirm"] + pkgs)
|
2020-06-21 18:24:29 +02:00
|
|
|
|
|
|
|
def update_db(self):
|
2020-07-05 09:35:52 +02:00
|
|
|
self.del_db_lock()
|
2020-06-22 00:43:31 +02:00
|
|
|
check_target_env_call([self.backend, "update", "--no-confirm"])
|
2020-06-21 18:24:29 +02:00
|
|
|
|
|
|
|
def update_system(self):
|
2020-07-05 09:35:52 +02:00
|
|
|
self.del_db_lock()
|
2020-06-22 00:43:31 +02:00
|
|
|
check_target_env_call([self.backend, "upgrade", "--no-confirm"])
|
2018-06-17 12:53:31 +02:00
|
|
|
|
2017-08-28 22:26:26 +02:00
|
|
|
|
2020-08-19 21:12:40 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2017-08-28 22:26:26 +02:00
|
|
|
class PMPortage(PackageManager):
|
|
|
|
backend = "portage"
|
|
|
|
|
|
|
|
def install(self, pkgs, from_local=False):
|
|
|
|
check_target_env_call(["emerge", "-v"] + pkgs)
|
|
|
|
|
|
|
|
def remove(self, pkgs):
|
|
|
|
check_target_env_call(["emerge", "-C"] + pkgs)
|
|
|
|
check_target_env_call(["emerge", "--depclean", "-q"])
|
|
|
|
|
|
|
|
def update_db(self):
|
|
|
|
check_target_env_call(["emerge", "--sync"])
|
|
|
|
|
2018-06-17 12:53:31 +02:00
|
|
|
def update_system(self):
|
|
|
|
# Doesn't need to update the system explicitly
|
|
|
|
pass
|
|
|
|
|
2017-08-28 22:26:26 +02:00
|
|
|
|
2020-08-19 21:12:40 +02:00
|
|
|
class PMXbps(PackageManager):
|
|
|
|
backend = "xbps"
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
def install(self, pkgs, from_local=False):
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["xbps-install", "-Sy"] + pkgs)
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
def remove(self, pkgs):
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["xbps-remove", "-Ry", "--noconfirm"] + pkgs)
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
def update_db(self):
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["xbps-install", "-S"])
|
2017-08-28 22:26:26 +02:00
|
|
|
|
2018-06-17 12:53:31 +02:00
|
|
|
def update_system(self):
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["xbps", "-Suy"])
|
2017-08-29 10:18:47 +02:00
|
|
|
|
2017-08-28 22:26:26 +02:00
|
|
|
|
2020-08-19 21:12:40 +02:00
|
|
|
class PMYum(PackageManager):
|
|
|
|
backend = "yum"
|
2018-02-01 09:14:54 +01:00
|
|
|
|
|
|
|
def install(self, pkgs, from_local=False):
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["yum", "-y", "install"] + pkgs)
|
2018-02-01 09:14:54 +01:00
|
|
|
|
|
|
|
def remove(self, pkgs):
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["yum", "--disablerepo=*", "-C", "-y",
|
|
|
|
"remove"] + pkgs)
|
2018-02-01 09:14:54 +01:00
|
|
|
|
|
|
|
def update_db(self):
|
2020-08-19 21:12:40 +02:00
|
|
|
# Doesn't need updates
|
|
|
|
pass
|
2018-02-01 09:14:54 +01:00
|
|
|
|
2018-06-17 12:53:31 +02:00
|
|
|
def update_system(self):
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["yum", "-y", "upgrade"])
|
2018-06-17 12:53:31 +02:00
|
|
|
|
2018-02-01 09:14:54 +01:00
|
|
|
|
2020-08-19 21:12:40 +02:00
|
|
|
class PMZypp(PackageManager):
|
|
|
|
backend = "zypp"
|
2020-02-27 12:58:53 +01:00
|
|
|
|
|
|
|
def install(self, pkgs, from_local=False):
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["zypper", "--non-interactive",
|
|
|
|
"--quiet-install", "install",
|
|
|
|
"--auto-agree-with-licenses",
|
|
|
|
"install"] + pkgs)
|
2020-02-27 12:58:53 +01:00
|
|
|
|
|
|
|
def remove(self, pkgs):
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["zypper", "--non-interactive",
|
|
|
|
"remove"] + pkgs)
|
2020-02-27 12:58:53 +01:00
|
|
|
|
|
|
|
def update_db(self):
|
2020-08-19 21:12:40 +02:00
|
|
|
check_target_env_call(["zypper", "--non-interactive", "update"])
|
2020-02-27 12:58:53 +01:00
|
|
|
|
|
|
|
def update_system(self):
|
2020-08-19 21:12:40 +02:00
|
|
|
# Doesn't need to update the system explicitly
|
|
|
|
pass
|
2020-02-27 12:58:53 +01:00
|
|
|
|
|
|
|
|
2017-08-29 12:33:07 +02:00
|
|
|
# Collect all the subclasses of PackageManager defined above,
|
|
|
|
# and index them based on the backend property of each class.
|
2017-08-28 22:26:26 +02:00
|
|
|
backend_managers = [
|
|
|
|
(c.backend, c)
|
|
|
|
for c in globals().values()
|
2017-08-29 10:18:47 +02:00
|
|
|
if type(c) is abc.ABCMeta and issubclass(c, PackageManager) and c.backend]
|
2017-08-28 22:26:26 +02:00
|
|
|
|
|
|
|
|
2017-08-29 12:33:07 +02:00
|
|
|
def subst_locale(plist):
|
|
|
|
"""
|
|
|
|
Returns a locale-aware list of packages, based on @p plist.
|
|
|
|
Package names that contain LOCALE are localized with the
|
|
|
|
BCP47 name of the chosen system locale; if the system
|
|
|
|
locale is 'en' (e.g. English, US) then these localized
|
|
|
|
packages are dropped from the list.
|
|
|
|
|
|
|
|
@param plist: list[str|dict]
|
|
|
|
Candidate packages to install.
|
|
|
|
@return: list[str|dict]
|
|
|
|
"""
|
2017-01-26 07:29:46 +01:00
|
|
|
locale = libcalamares.globalstorage.value("locale")
|
2017-08-29 12:33:07 +02:00
|
|
|
if not locale:
|
2018-04-03 14:02:16 +02:00
|
|
|
# It is possible to skip the locale-setting entirely.
|
|
|
|
# Then pretend it is "en", so that {LOCALE}-decorated
|
|
|
|
# package names are removed from the list.
|
|
|
|
locale = "en"
|
2017-08-29 12:33:07 +02:00
|
|
|
|
|
|
|
ret = []
|
|
|
|
for packagedata in plist:
|
|
|
|
if isinstance(packagedata, str):
|
|
|
|
packagename = packagedata
|
|
|
|
else:
|
|
|
|
packagename = packagedata["package"]
|
|
|
|
|
|
|
|
# Update packagename: substitute LOCALE, and drop packages
|
|
|
|
# if locale is en and LOCALE is in the package name.
|
|
|
|
if locale != "en":
|
|
|
|
packagename = Template(packagename).safe_substitute(LOCALE=locale)
|
|
|
|
elif 'LOCALE' in packagename:
|
|
|
|
packagename = None
|
|
|
|
|
|
|
|
if packagename is not None:
|
|
|
|
# Put it back in packagedata
|
|
|
|
if isinstance(packagedata, str):
|
|
|
|
packagedata = packagename
|
|
|
|
else:
|
|
|
|
packagedata["package"] = packagename
|
|
|
|
|
|
|
|
ret.append(packagedata)
|
|
|
|
|
2017-01-26 07:29:46 +01:00
|
|
|
return ret
|
2016-12-01 11:59:44 +01:00
|
|
|
|
2017-03-29 20:37:00 +02:00
|
|
|
|
2014-08-29 22:55:11 +02:00
|
|
|
def run_operations(pkgman, entry):
|
2017-03-29 20:37:00 +02:00
|
|
|
"""
|
2017-10-23 22:41:12 +02:00
|
|
|
Call package manager with suitable parameters for the given
|
|
|
|
package actions.
|
|
|
|
|
|
|
|
:param pkgman: PackageManager
|
|
|
|
This is the manager that does the actual work.
|
|
|
|
:param entry: dict
|
|
|
|
Keys are the actions -- e.g. "install" -- to take, and the values
|
|
|
|
are the (list of) packages to apply the action to. The actions are
|
|
|
|
not iterated in a specific order, so it is recommended to use only
|
|
|
|
one action per dictionary. The list of packages may be package
|
|
|
|
names (strings) or package information dictionaries with pre-
|
|
|
|
and post-scripts.
|
2015-02-20 20:54:25 +01:00
|
|
|
"""
|
2017-08-31 09:51:18 +02:00
|
|
|
global group_packages, completed_packages, mode_packages
|
2017-08-30 16:08:44 +02:00
|
|
|
|
2014-08-29 22:55:11 +02:00
|
|
|
for key in entry.keys():
|
2018-04-03 14:28:29 +02:00
|
|
|
package_list = subst_locale(entry[key])
|
|
|
|
group_packages = len(package_list)
|
2014-08-29 22:55:11 +02:00
|
|
|
if key == "install":
|
2017-08-30 17:03:52 +02:00
|
|
|
_change_mode(INSTALL)
|
2021-07-26 21:31:57 +02:00
|
|
|
pkgman.operation_install(package_list)
|
2016-11-02 17:00:08 +01:00
|
|
|
elif key == "try_install":
|
2017-08-30 17:03:52 +02:00
|
|
|
_change_mode(INSTALL)
|
2021-07-26 21:31:57 +02:00
|
|
|
pkgman.operation_try_install(package_list)
|
2014-08-29 22:55:11 +02:00
|
|
|
elif key == "remove":
|
2017-08-30 17:03:52 +02:00
|
|
|
_change_mode(REMOVE)
|
2021-07-26 21:31:57 +02:00
|
|
|
pkgman.operation_remove(package_list)
|
2016-11-02 17:00:08 +01:00
|
|
|
elif key == "try_remove":
|
2017-08-30 17:03:52 +02:00
|
|
|
_change_mode(REMOVE)
|
2021-07-26 21:31:57 +02:00
|
|
|
pkgman.operation_try_remove(package_list)
|
2015-03-04 16:19:26 +01:00
|
|
|
elif key == "localInstall":
|
2017-08-30 17:03:52 +02:00
|
|
|
_change_mode(INSTALL)
|
2021-07-26 21:31:57 +02:00
|
|
|
pkgman.operation_install(package_list, from_local=True)
|
2020-02-18 12:02:16 +01:00
|
|
|
elif key == "source":
|
|
|
|
libcalamares.utils.debug("Package-list from {!s}".format(entry[key]))
|
|
|
|
else:
|
|
|
|
libcalamares.utils.warning("Unknown package-operation key {!s}".format(key))
|
2018-04-03 14:28:29 +02:00
|
|
|
completed_packages += len(package_list)
|
2017-08-30 16:08:44 +02:00
|
|
|
libcalamares.job.setprogress(completed_packages * 1.0 / total_packages)
|
2020-03-05 03:31:47 +01:00
|
|
|
libcalamares.utils.debug("Pretty name: {!s}, setting progress..".format(pretty_name()))
|
2017-08-30 16:08:44 +02:00
|
|
|
|
2017-08-31 09:51:18 +02:00
|
|
|
group_packages = 0
|
|
|
|
_change_mode(None)
|
|
|
|
|
2015-02-18 15:47:24 +01:00
|
|
|
|
2014-08-29 22:55:11 +02:00
|
|
|
def run():
|
2017-03-29 20:37:00 +02:00
|
|
|
"""
|
|
|
|
Calls routine with detected package manager to install locale packages
|
2015-02-21 10:46:01 +01:00
|
|
|
or remove drivers not needed on the installed system.
|
2015-02-20 20:54:25 +01:00
|
|
|
|
|
|
|
:return:
|
|
|
|
"""
|
2017-08-31 09:51:18 +02:00
|
|
|
global mode_packages, total_packages, completed_packages, group_packages
|
2017-08-30 17:03:52 +02:00
|
|
|
|
2014-08-29 22:55:11 +02:00
|
|
|
backend = libcalamares.job.configuration.get("backend")
|
2015-06-14 13:25:37 +02:00
|
|
|
|
2017-08-28 22:26:26 +02:00
|
|
|
for identifier, impl in backend_managers:
|
|
|
|
if identifier == backend:
|
|
|
|
pkgman = impl()
|
|
|
|
break
|
|
|
|
else:
|
2015-06-14 13:25:37 +02:00
|
|
|
return "Bad backend", "backend=\"{}\"".format(backend)
|
2014-08-29 22:55:11 +02:00
|
|
|
|
2017-12-02 11:20:13 +01:00
|
|
|
skip_this = libcalamares.job.configuration.get("skip_if_no_internet", False)
|
2017-12-02 11:04:30 +01:00
|
|
|
if skip_this and not libcalamares.globalstorage.value("hasInternet"):
|
2018-02-20 10:42:56 +01:00
|
|
|
libcalamares.utils.warning( "Package installation has been skipped: no internet" )
|
2017-12-02 11:04:30 +01:00
|
|
|
return None
|
|
|
|
|
2016-11-02 13:03:44 +01:00
|
|
|
update_db = libcalamares.job.configuration.get("update_db", False)
|
|
|
|
if update_db and libcalamares.globalstorage.value("hasInternet"):
|
2021-05-24 23:07:11 +02:00
|
|
|
try:
|
|
|
|
pkgman.update_db()
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
libcalamares.utils.warning(str(e))
|
|
|
|
libcalamares.utils.debug("stdout:" + str(e.stdout))
|
|
|
|
libcalamares.utils.debug("stderr:" + str(e.stderr))
|
|
|
|
return (_("Package Manager error"),
|
|
|
|
_("The package manager could not prepare updates. The command <pre>{!s}</pre> returned error code {!s}.")
|
|
|
|
.format(e.cmd, e.returncode))
|
2016-11-02 13:03:44 +01:00
|
|
|
|
2018-06-17 12:53:31 +02:00
|
|
|
update_system = libcalamares.job.configuration.get("update_system", False)
|
|
|
|
if update_system and libcalamares.globalstorage.value("hasInternet"):
|
2021-05-24 23:07:11 +02:00
|
|
|
try:
|
|
|
|
pkgman.update_system()
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
libcalamares.utils.warning(str(e))
|
|
|
|
libcalamares.utils.debug("stdout:" + str(e.stdout))
|
|
|
|
libcalamares.utils.debug("stderr:" + str(e.stderr))
|
|
|
|
return (_("Package Manager error"),
|
|
|
|
_("The package manager could not update the system. The command <pre>{!s}</pre> returned error code {!s}.")
|
|
|
|
.format(e.cmd, e.returncode))
|
2018-06-17 12:53:31 +02:00
|
|
|
|
2017-08-30 17:03:52 +02:00
|
|
|
operations = libcalamares.job.configuration.get("operations", [])
|
|
|
|
if libcalamares.globalstorage.contains("packageOperations"):
|
|
|
|
operations += libcalamares.globalstorage.value("packageOperations")
|
|
|
|
|
|
|
|
mode_packages = None
|
|
|
|
total_packages = 0
|
|
|
|
completed_packages = 0
|
|
|
|
for op in operations:
|
|
|
|
for packagelist in op.values():
|
2018-04-03 14:28:29 +02:00
|
|
|
total_packages += len(subst_locale(packagelist))
|
2017-08-30 17:03:52 +02:00
|
|
|
|
|
|
|
if not total_packages:
|
|
|
|
# Avoids potential divide-by-zero in progress reporting
|
|
|
|
return None
|
|
|
|
|
2014-08-29 22:55:11 +02:00
|
|
|
for entry in operations:
|
2017-08-31 09:51:18 +02:00
|
|
|
group_packages = 0
|
|
|
|
libcalamares.utils.debug(pretty_name())
|
2021-05-24 23:07:11 +02:00
|
|
|
try:
|
|
|
|
run_operations(pkgman, entry)
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
libcalamares.utils.warning(str(e))
|
|
|
|
libcalamares.utils.debug("stdout:" + str(e.stdout))
|
|
|
|
libcalamares.utils.debug("stderr:" + str(e.stderr))
|
|
|
|
return (_("Package Manager error"),
|
2021-07-14 12:54:07 +02:00
|
|
|
_("The package manager could not make changes to the installed system. The command <pre>{!s}</pre> returned error code {!s}.")
|
2021-05-24 23:07:11 +02:00
|
|
|
.format(e.cmd, e.returncode))
|
2014-08-29 22:55:11 +02:00
|
|
|
|
2017-08-30 17:03:52 +02:00
|
|
|
mode_packages = None
|
2017-08-31 09:51:18 +02:00
|
|
|
|
2017-08-30 17:03:52 +02:00
|
|
|
libcalamares.job.setprogress(1.0)
|
2014-08-29 22:55:11 +02:00
|
|
|
|
|
|
|
return None
|