import logging
from . import logger
+from . import step
from . import tui
# Setup logging
else:
log.info("Bricklayer initialized")
+ # An ordered list of all available steps
+ steps = (
+ step.Welcome,
+ )
+
def __call__(self):
with self.tui:
- pass
+ # Walk through all steps
+ for step in self.steps:
+ self._run_step(step)
+
+ def _run_step(self, stepcls):
+ """
+ Runs a single step
+ """
+ # Initialize the step
+ step = stepcls(self)
+
+ # Skip this step if it isn't enabled
+ if not step.enabled:
+ return
+
+ # Run it
+ return step.run(self.tui)
--- /dev/null
+###############################################################################
+# #
+# Bricklayer - An Installer for IPFire #
+# Copyright (C) 2021 IPFire Development Team #
+# #
+# This program is free software; you can redistribute it and/or #
+# modify it under the terms of the GNU General Public License #
+# as published by the Free Software Foundation; either version 2 #
+# 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 General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+###############################################################################
+
+import logging
+
+import snack
+
+from .i18n import _
+
+# Setup logging
+log = logging.getLogger("bricklayer.step")
+
+class Step(object):
+ """
+ Steps are the heart of this installer. They perform actions and are
+ being executed one after the other.
+ """
+ # This enables or disables this step
+ enabled = True
+
+ def __init__(self, bricklayer):
+ self.bricklayer = bricklayer
+
+ log.debug("Initializing step %s" % self.__class__.__name__)
+
+ # Call the custom initialization
+ self.initialize()
+
+ def initialize(self):
+ """
+ Custom initialization action to be overlayed
+ """
+ pass
+
+ def run(self, tui):
+ """
+ Run this step - to be overlayed
+ """
+ pass
+
+
+class Welcome(Step):
+ """
+ Shows a very warm welcome message to the user
+ """
+ @property
+ def enabled(self):
+ # Disable in unattended mode
+ return not self.bricklayer.unattended
+
+ def run(self, tui):
+ tui.message(
+ title=_("Welcome"),
+ text=_("Welcome to the %s installation program.\n\n"
+ "Selecting Cancel on any of the following screens will reboot the computer."),
+ buttons=(_("Start Installation"), _("Cancel"))
+ )