Skip to content

Commit

Permalink
Migrate the %pre script
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkankovsky committed Jul 3, 2024
1 parent c26b2ad commit c13788b
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 1 deletion.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions pyanaconda/modules/common/constants/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion pyanaconda/modules/runtime/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

SUBDIRS = dracut_commands user_interface
SUBDIRS = dracut_commands scripts user_interface

pkgpyexecdir = $(pyexecdir)/py$(PACKAGE_NAME)
runtimedir = $(pkgpyexecdir)/modules/runtime
Expand Down
11 changes: 11 additions & 0 deletions pyanaconda/modules/runtime/kickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -41,3 +44,11 @@ class RuntimeKickstartSpecification(KickstartSpecification):
"DriverDiskData": COMMANDS.DriverDiskData,
"SshPwData": COMMANDS.SshPwData,
}

sections = {
"pre": PreScriptSection
}

sections_data = {
"pre": Script
}
4 changes: 4 additions & 0 deletions pyanaconda/modules/runtime/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
21 changes: 21 additions & 0 deletions pyanaconda/modules/runtime/scripts/Makefile.am
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.

pkgpyexecdir = $(pyexecdir)/py$(PACKAGE_NAME)
scriptsdir = $(pkgpyexecdir)/modules/runtime/scripts
dist_scripts_DATA = $(wildcard $(srcdir)/*.py)

MAINTAINERCLEANFILES = Makefile.in
20 changes: 20 additions & 0 deletions pyanaconda/modules/runtime/scripts/__init__.py
Original file line number Diff line number Diff line change
@@ -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"]
39 changes: 39 additions & 0 deletions pyanaconda/modules/runtime/scripts/scripts.py
Original file line number Diff line number Diff line change
@@ -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
43 changes: 43 additions & 0 deletions pyanaconda/modules/runtime/scripts/scripts_interface.py
Original file line number Diff line number Diff line change
@@ -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()
)

0 comments on commit c13788b

Please sign in to comment.