diff --git a/configure.ac b/configure.ac index 061e4c118c0c..3f8213158d5c 100644 --- a/configure.ac +++ b/configure.ac @@ -179,6 +179,7 @@ AC_CONFIG_FILES([Makefile pyanaconda/modules/payloads/source/url/Makefile pyanaconda/modules/runtime/Makefile pyanaconda/modules/runtime/dracut_commands/Makefile + pyanaconda/modules/runtime/scripts/Makefile pyanaconda/modules/runtime/user_interface/Makefile pyanaconda/modules/storage/Makefile pyanaconda/modules/storage/bootloader/Makefile diff --git a/pyanaconda/modules/common/constants/objects.py b/pyanaconda/modules/common/constants/objects.py index 2deb5890dcbe..7932a9275e80 100644 --- a/pyanaconda/modules/common/constants/objects.py +++ b/pyanaconda/modules/common/constants/objects.py @@ -21,6 +21,13 @@ PARTITIONING_NAMESPACE, DEVICE_TREE_NAMESPACE, \ RHSM_NAMESPACE, RUNTIME_NAMESPACE +# Runtime objects + +SCRIPTS = DBusObjectIdentifier( + namespace=RUNTIME_NAMESPACE, + basename="Scripts" +) + # Boss objects. USER_INTERFACE = DBusObjectIdentifier( diff --git a/pyanaconda/modules/runtime/Makefile.am b/pyanaconda/modules/runtime/Makefile.am index 5523d644dd39..5bbcfeec7c51 100644 --- a/pyanaconda/modules/runtime/Makefile.am +++ b/pyanaconda/modules/runtime/Makefile.am @@ -15,7 +15,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see . -SUBDIRS = dracut_commands user_interface +SUBDIRS = dracut_commands scripts user_interface pkgpyexecdir = $(pyexecdir)/py$(PACKAGE_NAME) runtimedir = $(pkgpyexecdir)/modules/runtime diff --git a/pyanaconda/modules/runtime/kickstart.py b/pyanaconda/modules/runtime/kickstart.py index 2f7627820ddf..8ed1dcb6c49b 100644 --- a/pyanaconda/modules/runtime/kickstart.py +++ b/pyanaconda/modules/runtime/kickstart.py @@ -17,6 +17,9 @@ # License and may only be used or replicated with the express permission of # Red Hat, Inc. # +from pykickstart.parser import Script +from pykickstart.sections import PreScriptSection + from pyanaconda.core.kickstart import KickstartSpecification, commands as COMMANDS @@ -41,3 +44,11 @@ class RuntimeKickstartSpecification(KickstartSpecification): "DriverDiskData": COMMANDS.DriverDiskData, "SshPwData": COMMANDS.SshPwData, } + + sections = { + "pre": PreScriptSection + } + + sections_data = { + "pre": Script + } diff --git a/pyanaconda/modules/runtime/runtime.py b/pyanaconda/modules/runtime/runtime.py index ca1d59d19877..bcd9562d6a91 100755 --- a/pyanaconda/modules/runtime/runtime.py +++ b/pyanaconda/modules/runtime/runtime.py @@ -25,6 +25,7 @@ from pyanaconda.modules.runtime.runtime_interface import RuntimeInterface from pyanaconda.modules.runtime.kickstart import RuntimeKickstartSpecification from pyanaconda.modules.runtime.dracut_commands import DracutCommandsModule +from pyanaconda.modules.runtime.scripts import ScriptsModule from pyanaconda.modules.runtime.user_interface import UIModule from pyanaconda.modules.common.base import KickstartService from pyanaconda.modules.common.constants.services import RUNTIME @@ -51,6 +52,9 @@ def __init__(self): self._dracut_module = DracutCommandsModule() self._modules.add_module(self._dracut_module) + self._scripts_module = ScriptsModule() + self._modules.add_module(self._scripts_module) + self._ui_module = UIModule() self._modules.add_module(self._ui_module) diff --git a/pyanaconda/modules/runtime/scripts/Makefile.am b/pyanaconda/modules/runtime/scripts/Makefile.am new file mode 100644 index 000000000000..c46bd8662fdf --- /dev/null +++ b/pyanaconda/modules/runtime/scripts/Makefile.am @@ -0,0 +1,21 @@ +# +# Copyright (C) 2024 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see . + +pkgpyexecdir = $(pyexecdir)/py$(PACKAGE_NAME) +scriptsdir = $(pkgpyexecdir)/modules/runtime/scripts +dist_scripts_DATA = $(wildcard $(srcdir)/*.py) + +MAINTAINERCLEANFILES = Makefile.in \ No newline at end of file diff --git a/pyanaconda/modules/runtime/scripts/__init__.py b/pyanaconda/modules/runtime/scripts/__init__.py new file mode 100644 index 000000000000..4f3b772bba62 --- /dev/null +++ b/pyanaconda/modules/runtime/scripts/__init__.py @@ -0,0 +1,20 @@ +# +# Copyright (C) 2024 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# the GNU General Public License v.2, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY expressed or implied, including the implied warranties of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. You should have received a copy of the +# GNU General Public License along with this program; if not, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the +# source code or documentation are not subject to the GNU General Public +# License and may only be used or replicated with the express permission of +# Red Hat, Inc. +# +from pyanaconda.modules.runtime.scripts.scripts import ScriptsModule + +__all__ = ["ScriptsModule"] diff --git a/pyanaconda/modules/runtime/scripts/scripts.py b/pyanaconda/modules/runtime/scripts/scripts.py new file mode 100644 index 000000000000..5ae40082593c --- /dev/null +++ b/pyanaconda/modules/runtime/scripts/scripts.py @@ -0,0 +1,39 @@ +# +# The user interface module +# +# Copyright (C) 2024 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# the GNU General Public License v.2, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY expressed or implied, including the implied warranties of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. You should have received a copy of the +# GNU General Public License along with this program; if not, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the +# source code or documentation are not subject to the GNU General Public +# License and may only be used or replicated with the express permission of +# Red Hat, Inc. +# +# Set up the modules logger. +from pyanaconda.anaconda_loggers import get_module_logger +from pyanaconda.modules.common.base import KickstartBaseModule + +log = get_module_logger(__name__) + +__all__ = ["ScriptsModule"] + + +log = get_module_logger(__name__) + +class ScriptsModule(KickstartBaseModule): + def __init__(self): + super().__init__() + + def process_kickstart(self, data): + log.info(data.scripts) + + def setup_kickstart(self, data): + pass diff --git a/pyanaconda/modules/runtime/scripts/scripts_interface.py b/pyanaconda/modules/runtime/scripts/scripts_interface.py new file mode 100644 index 000000000000..accb20f7e5ad --- /dev/null +++ b/pyanaconda/modules/runtime/scripts/scripts_interface.py @@ -0,0 +1,43 @@ +# +# DBus interface for the scripts module +# +# Copyright (C) 2021 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# the GNU General Public License v.2, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY expressed or implied, including the implied warranties of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. You should have received a copy of the +# GNU General Public License along with this program; if not, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the +# source code or documentation are not subject to the GNU General Public +# License and may only be used or replicated with the express permission of +# Red Hat, Inc. +# +from dasbus.server.interface import dbus_interface +from dasbus.typing import * # pylint: disable=wildcard-import + +from pyanaconda.modules.common.base import KickstartModuleInterfaceTemplate +from pyanaconda.modules.common.constants.objects import SCRIPTS +from pyanaconda.modules.common.containers import TaskContainer + +__all__ = ["ScriptsInterface"] + + +@dbus_interface(SCRIPTS.interface_name) +class ScriptsInterface(KickstartModuleInterfaceTemplate): + """DBus interface for the scripts module.""" + def RunPreScriptsWithTask(self) -> ObjPath: + """Run pre scripts with task.""" + return TaskContainer.to_object_path( + self.implementation.run_pre_scripts_with_task() + ) + + def RunPreInstallScriptsWithTask(self) -> ObjPath: + """Run pre install scripts with task.""" + return TaskContainer.to_object_path( + self.implementation.run_pre_install_scripts_with_task() + )