From f6a8b6307a0b05bf8d523fbba1189f55256c8c4f Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Wed, 28 Jan 2026 07:30:34 +0100 Subject: [PATCH] jw.pkg.cmds.distro.backend.redhat: Add Module Add backend for YAM-based package management, as used by RHEL, Fedora, CentOS. Signed-off-by: Jan Lindemann --- .../jw/pkg/cmds/distro/backend/redhat/Base.py | 14 ++++++++++++++ .../jw/pkg/cmds/distro/backend/redhat/Dup.py | 14 ++++++++++++++ .../pkg/cmds/distro/backend/redhat/Install.py | 18 ++++++++++++++++++ .../jw/pkg/cmds/distro/backend/redhat/Makefile | 4 ++++ .../pkg/cmds/distro/backend/redhat/Refresh.py | 15 +++++++++++++++ 5 files changed, 65 insertions(+) create mode 100644 src/python/jw/pkg/cmds/distro/backend/redhat/Base.py create mode 100644 src/python/jw/pkg/cmds/distro/backend/redhat/Dup.py create mode 100644 src/python/jw/pkg/cmds/distro/backend/redhat/Install.py create mode 100644 src/python/jw/pkg/cmds/distro/backend/redhat/Makefile create mode 100644 src/python/jw/pkg/cmds/distro/backend/redhat/Refresh.py diff --git a/src/python/jw/pkg/cmds/distro/backend/redhat/Base.py b/src/python/jw/pkg/cmds/distro/backend/redhat/Base.py new file mode 100644 index 00000000..ce17d04b --- /dev/null +++ b/src/python/jw/pkg/cmds/distro/backend/redhat/Base.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- + +from ...Cmd import Cmd +from ..BackendCmd import BackendCmd + +class Base(BackendCmd): + + def __init__(self, parent: Cmd): + super().__init__(parent) + + async def yum(self, *args): + cmd = ['/usr/bin/yum'] + cmd.extend(args) + return await self._sudo(cmd) diff --git a/src/python/jw/pkg/cmds/distro/backend/redhat/Dup.py b/src/python/jw/pkg/cmds/distro/backend/redhat/Dup.py new file mode 100644 index 00000000..e348c256 --- /dev/null +++ b/src/python/jw/pkg/cmds/distro/backend/redhat/Dup.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- + +from argparse import Namespace + +from ...Cmd import Cmd +from .Base import Base + +class Dup(Base): + + def __init__(self, parent: Cmd): + super().__init__(parent) + + async def run(self, args: Namespace): + raise NotImplementedError('distro dup is not yet implemented for Red Hat-like distributions') diff --git a/src/python/jw/pkg/cmds/distro/backend/redhat/Install.py b/src/python/jw/pkg/cmds/distro/backend/redhat/Install.py new file mode 100644 index 00000000..59eb47ff --- /dev/null +++ b/src/python/jw/pkg/cmds/distro/backend/redhat/Install.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from argparse import Namespace + +from ...Cmd import Cmd +from .Base import Base + +class Install(Base): + + def __init__(self, parent: Cmd): + super().__init__(parent) + + async def run(self, args: Namespace): + yum_args = ['install'] + if not self.interactive: + yum_args.append['-y'] + yum_args.extend(args.packages) + return await self.yum(*yum_args) diff --git a/src/python/jw/pkg/cmds/distro/backend/redhat/Makefile b/src/python/jw/pkg/cmds/distro/backend/redhat/Makefile new file mode 100644 index 00000000..d8d0e64b --- /dev/null +++ b/src/python/jw/pkg/cmds/distro/backend/redhat/Makefile @@ -0,0 +1,4 @@ +TOPDIR = ../../../../../../../.. + +include $(TOPDIR)/make/proj.mk +include $(JWBDIR)/make/py-mod.mk diff --git a/src/python/jw/pkg/cmds/distro/backend/redhat/Refresh.py b/src/python/jw/pkg/cmds/distro/backend/redhat/Refresh.py new file mode 100644 index 00000000..03f582d7 --- /dev/null +++ b/src/python/jw/pkg/cmds/distro/backend/redhat/Refresh.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- + +from argparse import Namespace + +from ...Cmd import Cmd +from .Base import Base + +class Refresh(Base): + + def __init__(self, parent: Cmd): + super().__init__(parent) + + async def run(self, args: Namespace): + await self.yum('clean', 'expire-cache') + await self.yum('makecache')