Skip to content

Commit dcf478f

Browse files
authored
Merge pull request #5 from plesk/task-nvizovitin-tuxcare-els-support
TuxCare ELS support, update submodule
2 parents 08f7840 + bcfb597 commit dcf478f

File tree

4 files changed

+51
-25
lines changed

4 files changed

+51
-25
lines changed

dist-upgrader

Submodule dist-upgrader updated 67 files

ubuntu18to20/actions/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Copyright 2024. WebPros International GmbH. All rights reserved.
2+
from .packages import *

ubuntu18to20/actions/packages.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2024. WebPros International GmbH. All rights reserved.
2+
from pleskdistup.common import action, packages
3+
4+
5+
class RemoveUnusedPackages(action.ActiveAction):
6+
""" Removes packages that are not used anymore in the target OS after the dist-upgrade.
7+
These are mostly versioned packages, which have corresponding alternatives in the
8+
target OS with a different package name, which makes these ones obsolete and useless.
9+
The alternatives are expected to have been installed by the dist-upgrade itself.
10+
"""
11+
12+
def __init__(self):
13+
self.name = "remove unused packages"
14+
self.unused_packages = [
15+
"libmagickcore-6.q16-3",
16+
"libmagickwand-6.q16-3",
17+
"libmysqlclient20",
18+
"libprocps6",
19+
"perl-modules-5.26",
20+
]
21+
22+
def _prepare_action(self) -> action.ActionResult:
23+
return action.ActionResult()
24+
25+
def _post_action(self) -> action.ActionResult:
26+
packages.remove_packages(packages.filter_installed_packages(self.unused_packages))
27+
return action.ActionResult()
28+
29+
def _revert_action(self) -> action.ActionResult:
30+
return action.ActionResult()
31+
32+
def estimate_post_time(self) -> int:
33+
return 5

ubuntu18to20/upgrader.py

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,34 @@
77
from pleskdistup import actions
88
from pleskdistup.common import action, feedback
99
from pleskdistup.phase import Phase
10-
from pleskdistup.upgrader import DistUpgrader, DistUpgraderFactory, PathType, SystemDescription
10+
from pleskdistup.upgrader import dist, DistUpgrader, DistUpgraderFactory, PathType
1111

1212
import ubuntu18to20.config
13+
import ubuntu18to20.actions
1314

1415

1516
class Ubuntu18to20Upgrader(DistUpgrader):
16-
_os_from_name = "Ubuntu"
17-
_os_from_version = "18"
18-
_os_to_name = "Ubuntu"
19-
_os_to_version = "20"
17+
_distro_from = dist.Ubuntu("18")
18+
_distro_to = dist.Ubuntu("20")
2019

2120
def __init__(self):
2221
super().__init__()
2322

2423
def __repr__(self) -> str:
25-
attrs = ", ".join(f"{k}={getattr(self, k)!r}" for k in (
26-
"_os_from_name", "_os_from_version",
27-
"_os_to_name", "_os_to_version",
28-
))
29-
return f"{self.__class__.__name__}({attrs})"
24+
return f"{self.__class__.__name__}(From {self._distro_from}, To {self._distro_to})"
3025

3126
def __str__(self) -> str:
3227
return f"{self.__class__.__name__}"
3328

3429
@classmethod
3530
def supports(
3631
cls,
37-
from_system: typing.Optional[SystemDescription] = None,
38-
to_system: typing.Optional[SystemDescription] = None
32+
from_system: typing.Optional[dist.Distro] = None,
33+
to_system: typing.Optional[dist.Distro] = None
3934
) -> bool:
40-
def matching_system(system: SystemDescription, os_name: str, os_version: str) -> bool:
41-
return (
42-
(system.os_name is None or system.os_name == os_name)
43-
and (system.os_version is None or system.os_version == os_version)
44-
)
45-
4635
return (
47-
(from_system is None or matching_system(from_system, cls._os_from_name, cls._os_from_version))
48-
and (to_system is None or matching_system(to_system, cls._os_to_name, cls._os_to_version))
36+
(from_system is None or cls._distro_from == from_system)
37+
and (to_system is None or cls._distro_to == to_system)
4938
)
5039

5140
@property
@@ -78,14 +67,15 @@ def construct_actions(
7867
options: typing.Any,
7968
phase: Phase
8069
) -> typing.Dict[str, typing.List[action.ActiveAction]]:
81-
new_os = f"{self._os_to_name} {self._os_to_version}"
70+
new_os = str(self._distro_to)
8271
return {
8372
"Prepare": [
8473
actions.HandleConversionStatus(options.status_flag_path, options.completion_flag_path),
8574
actions.AddFinishSshLoginMessage(new_os), # Executed at the finish phase only
8675
actions.AddInProgressSshLoginMessage(new_os),
8776
actions.DisablePleskSshBanner(),
8877
actions.RepairPleskInstallation(), # Executed at the finish phase only
78+
actions.UninstallTuxcareEls(),
8979
actions.DisableMariadbInnodbFastShutdown(),
9080
actions.DisableUnsupportedMysqlModes(),
9181
actions.InstallUbuntuUpdateManager(),
@@ -113,6 +103,7 @@ def construct_actions(
113103
],
114104
"Dist-upgrade": [
115105
actions.DoDistupgrade(),
106+
ubuntu18to20.actions.RemoveUnusedPackages(),
116107
],
117108
"Finishing actions": [
118109
actions.Reboot(prepare_next_phase=Phase.FINISH, name="reboot and perform finishing actions"),
@@ -134,7 +125,7 @@ def get_check_actions(self, options: typing.Any, phase: Phase) -> typing.List[ac
134125
]
135126

136127
def parse_args(self, args: typing.Sequence[str]) -> None:
137-
DESC_MESSAGE = f"""Use this upgrader to dist-upgrade an {self._os_from_name} {self._os_from_version} server with Plesk to {self._os_to_name} {self._os_to_version}. The process consists of the following general stages:
128+
DESC_MESSAGE = f"""Use this upgrader to dist-upgrade an {self._distro_from} server with Plesk to {self._distro_to}. The process consists of the following general stages:
138129
139130
-- Preparation (about 5 minutes) - The OS is prepared for the conversion.
140131
-- Conversion (about 15 minutes) - Plesk and system dist-upgrade is performed.
@@ -173,8 +164,8 @@ def __str__(self) -> str:
173164

174165
def supports(
175166
self,
176-
from_system: typing.Optional[SystemDescription] = None,
177-
to_system: typing.Optional[SystemDescription] = None
167+
from_system: typing.Optional[dist.Distro] = None,
168+
to_system: typing.Optional[dist.Distro] = None
178169
) -> bool:
179170
return Ubuntu18to20Upgrader.supports(from_system, to_system)
180171

0 commit comments

Comments
 (0)