diff --git a/src/python/jw/pkg/cmds/distro/backend/debian/Base.py b/src/python/jw/pkg/cmds/distro/backend/debian/Base.py new file mode 100644 index 00000000..ff4105a3 --- /dev/null +++ b/src/python/jw/pkg/cmds/distro/backend/debian/Base.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from ...Cmd import Cmd +from ..BackendCmd import BackendCmd + +class Base(BackendCmd): + + def __init__(self, parent: Cmd): + super().__init__(parent) + + async def apt_get(self, *args): + cmd = ['/usr/bin/apt-get'] + mod_env = None + if not self.interactive: + cmd.extend(['-yq']) + mod_env = { 'DEBIAN_FRONTEND': 'noninteractive' } + cmd.extend(args) + return await self._sudo(cmd, mod_env=mod_env) diff --git a/src/python/jw/pkg/cmds/distro/backend/debian/Dup.py b/src/python/jw/pkg/cmds/distro/backend/debian/Dup.py new file mode 100644 index 00000000..9ccadd1b --- /dev/null +++ b/src/python/jw/pkg/cmds/distro/backend/debian/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 Debian-like distributions') diff --git a/src/python/jw/pkg/cmds/distro/backend/debian/Install.py b/src/python/jw/pkg/cmds/distro/backend/debian/Install.py new file mode 100644 index 00000000..17343fb1 --- /dev/null +++ b/src/python/jw/pkg/cmds/distro/backend/debian/Install.py @@ -0,0 +1,14 @@ +# -*- 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): + return await self.apt_get('install', *args.packages) diff --git a/src/python/jw/pkg/cmds/distro/backend/debian/Makefile b/src/python/jw/pkg/cmds/distro/backend/debian/Makefile new file mode 100644 index 00000000..d8d0e64b --- /dev/null +++ b/src/python/jw/pkg/cmds/distro/backend/debian/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/debian/Refresh.py b/src/python/jw/pkg/cmds/distro/backend/debian/Refresh.py new file mode 100644 index 00000000..328908bc --- /dev/null +++ b/src/python/jw/pkg/cmds/distro/backend/debian/Refresh.py @@ -0,0 +1,14 @@ +# -*- 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): + return await self.apt_get('update')