import argparse
import logging
+import os
import sys
import bricklayer
parser = argparse.ArgumentParser(
description=_("IPFire Installation Tool CLI"),
)
+ parser.add_argument("--arch", nargs="?", default=self.native_arch,
+ help=_("Select the target architecture"))
parser.add_argument("--debug", action="store_true",
help=_("Enable debugging mode"))
parser.add_argument("--unattended", action="store_true",
# Run it
return bl()
+ @property
+ def native_arch(self):
+ """
+ Return the native system architecture (i.e. uname -m)
+ """
+ sysname, nodename, release, version, arch = os.uname()
+
+ return arch
# Main
c = Cli()
import tempfile
import traceback
+import pakfire
+
from . import disk
from . import i18n
from . import logger
+from . import packages
from . import step
from . import tui
from . import util
"""
Bricklayer's base class
"""
- def __init__(self, debug=False, unattended=False, disks=[]):
+ def __init__(self, arch, debug=False, unattended=False, disks=[]):
+ self.arch = arch
self.unattended = unattended
# Enable debug logging
self.settings = {
"language" : i18n.default_language,
+ "packages" : [
+ # Install the Base group
+ "@Base",
+ ],
+
# Set the default swap size to 1 GiB
"swap-size": 1024 ** 3,
}
disk.CreatePartitionLayout,
disk.CreateFilesystems,
disk.MountFilesystems,
+ packages.InstallPackages,
# Done!
disk.UmountFilesystems,
log.debug(output)
return output
+
+ def setup_pakfire(self):
+ """
+ Calls Pakfire and has it load its configuration
+ """
+ return pakfire.Pakfire(self.root, arch=self.arch,
+ conf="/etc/pakfire/distros/ipfire3.conf")
--- /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 pakfire.errors
+
+from . import step
+from .i18n import _
+
+# Set up logging
+log = logging.getLogger("bricklayer.packages")
+
+class InstallPackages(step.Step):
+ def run(self, tui):
+ # Set up Pakfire
+ with tui.progress(
+ _("Setting Up Pakfire"),
+ _("Pakfire is being set up..."),
+ ):
+ p = self.bricklayer.setup_pakfire()
+
+ # Get list of all packages to be installed
+ packages = self.bricklayer.settings.get("packages", [])
+
+ with p as p:
+ # Resolve package dependencies
+ with tui.progress(
+ _("Resolving Dependencies"),
+ _("Resolving package dependencies..."),
+ ):
+ try:
+ transaction = p.install(packages)
+
+ # Abort on any dependencies problems
+ except pakfire.errors.DependencyError as e:
+ problems = e.args[0]
+
+ # Format problem descriptions
+ text = []
+ for problem in problems:
+ lines = [
+ "* %s" % problem
+ ]
+ for solution in problem.solutions:
+ lines.append(" --> %s" % solution)
+
+ text.append("\n".join(lines))
+
+ tui.error(
+ _("Dependency Problem"),
+ _(
+ "A problem has occured during resolving package dependencies:\n\n%s",
+ "Problems have occured during resolving package dependencies:\n\n%s",
+ len(problems),
+ ) % "\n\n".join(text),
+ width=78,
+ )
+
+ # Log the transaction
+ log.info("%s" % transaction.dump())
+
+ # Run the transaction
+ with tui.progress(
+ _("Installing Packages"),
+ _("Installing packages..."),
+ ):
+ transaction.run()