Testing: Module Updates

Signed-off-by: debianpepper <pdpdebdevuan@protonmail.com>
This commit is contained in:
debianpepper 2023-12-12 14:47:22 +09:00
parent 2f0249424c
commit ea2085a79f
1 changed files with 296 additions and 93 deletions

View File

@ -3,14 +3,13 @@
* *
* License: SPDX-License-Identifier: GPL-3.0-or-later * License: SPDX-License-Identifier: GPL-3.0-or-later
* *
* Build the ISOs for the system to be deployed. * Build the ISOs for the system to be deployed
""" """
import os import os
import logging
from pathlib import Path from pathlib import Path
import argparse import argparse
import collections import collections
import logging
import conf import conf
import infra import infra
import inflate_bubble import inflate_bubble
@ -41,63 +40,116 @@ BUILD_COMPLETED = "ISO build has completed successfully"
BUILD_COMPLETED = "ISO is ready for usage." BUILD_COMPLETED = "ISO is ready for usage."
class BaseBuilder: class BuildXfce:
def __init__(self, sbase, sarch, desktop_helper, build_list): """
Determine what base to use and then build the ISO
"""
def __init__(self, sbase, sarch):
self.sbase = sbase self.sbase = sbase
self.sarch = sarch self.sarch = sarch
self.desktop_helper = desktop_helper
self.build_list = build_list
# Change to the root of Fusato # Change to the root of Fusato
# then run the build # then run the buils
os.chdir(HOME_FOLDER + FUSATO_ROOT) os.chdir(HOME_FOLDER + FUSATO_ROOT)
self.build_system() self.build_system()
def lb_helper(self):
if self.sbase == "deb":
lbsetup = getattr(conf, f'LBSET_DEB{self.sarch[1:]}', None)
elif self.sbase == "dev":
lbsetup = getattr(conf, f'LBSET_DEV{self.sarch[1:]}', None)
else:
lbsetup = None
if lbsetup: def lb_helper(self):
os.system(lbsetup) """
else: Helper for the lb setup this is shared for all builds
raise ValueError(f"Unsupported combination: sbase={self.sbase}, sarch={self.sarch[1:]}") """
if self.sbase == "deb":
if self.sarch[1:] == "64":
lbsetup = conf.LBSET_DEB64
os.system(lbsetup)
elif self.sarch[1:] == "32":
lbsetup = conf.LBSET_DEB32
os.system(lbsetup)
elif self.sarch[1:] == "arm":
lbsetup = conf.LBSET_DEBARM
os.system(lbsetup)
else:
lbsetup = None
elif self.sbase == "dev":
if self.sarch[1:] == "64":
lbsetup = conf.LBSET_DEV64
os.system(lbsetup)
elif self.sarch[1:] == "32":
lbsetup = conf.LBSET_DEV32
os.system(lbsetup)
elif self.sarch[1:] == "arm":
lbsetup = conf.LBSET_DEVARM
os.system(lbsetup)
else:
lbsetup = None
def infra_helper(self): def infra_helper(self):
"""
Helper for the infra classes this is shared for all builds
"""
infra.ChrootFolders(self.sbase, self.sarch) infra.ChrootFolders(self.sbase, self.sarch)
infra.BinaryFolders(self.sbase, self.sarch) infra.BinaryFolders(self.sbase, self.sarch)
infra.ArchitectureFiles(self.sbase, self.sarch) infra.ArchitectureFiles(self.sbase, self.sarch)
infra.Archive(self.sbase, self.sarch) infra.Archive(self.sbase, self.sarch)
def builder_helper(self):
cmd_list = collections.deque(self.build_list) def xfce_helper(self):
list_size = len(cmd_list) """
for _ in range(list_size): Helper for the xfce desktop shared for all builds
i = cmd_list.popleft() """
execute = i + '()' if self.sarch[1:] == "64":
exec(execute) cmd_list = collections.deque(conf.build64_xfce_build)
list_size = len(cmd_list)
for _ in range(list_size):
i = cmd_list.popleft()
execute = i + '()'
exec(execute)
elif self.sarch[1:] == "32":
cmd_list = collections.deque(conf.build32_xfce_build)
list_size = len(cmd_list)
for _ in range(list_size):
i = cmd_list.popleft()
execute = i + '()'
exec(execute)
elif self.sarch[1:] == "arm":
cmd_list = collections.deque(conf.buildarm_xfce_build)
list_size = len(cmd_list)
for _ in range(list_size):
i = cmd_list.popleft()
execute = i + '()'
exec(execute)
else:
cmd_list = None
def cleanup_helper(self): def cleanup_helper(self):
""" Clean up Helper to move the ISOs to the nightly location """
finish_cleanup.make_check_sum() finish_cleanup.make_check_sum()
finish_cleanup.check_build_type_xfce() finish_cleanup.check_build_type_xfce()
finish_cleanup.kill_old_iso() finish_cleanup.kill_old_iso()
def build_system(self): def build_system(self):
""" Builds the ISO XFCE Depedning on the Arch """
current_working_directory = os.getcwd() current_working_directory = os.getcwd()
dir_current = WRKING_DIR + current_working_directory dir_current = WRKING_DIR + current_working_directory
logger.info(f"Building a {self.sbase}{self.sarch[1:]} bit ISO") logger.info("Building a " + self.sbase + self.sarch[1:] + " bit ISO")
logger.info(dir_current) logger.info(dir_current)
# Set the config tree
self.lb_helper() self.lb_helper()
self.desktop_helper() # Start with the XFCE stuff
self.xfce_helper()
# Run the specific classes
self.infra_helper() self.infra_helper()
# Run the Build
logger.info(CFG_READY) logger.info(CFG_READY)
logger.info(START_LIVEBUILD) logger.info(START_LIVEBUILD)
logger.info(dir_current) logger.info(dir_current)
self.lb_helper() self.lb_helper()
run_cmd = 'sudo lb build' run_cmd = 'sudo lb build'
current_working_directory = os.getcwd()
os.chdir(HOME_FOLDER + FUSATO_ROOT) os.chdir(HOME_FOLDER + FUSATO_ROOT)
# Set the build inidcator
inflate_bubble.make_bld_xfce(self.sbase, self.sarch[1:]) inflate_bubble.make_bld_xfce(self.sbase, self.sarch[1:])
logger.info(dir_current) logger.info(dir_current)
os.system(run_cmd) os.system(run_cmd)
@ -107,20 +159,125 @@ class BaseBuilder:
logger.info(BUILD_COMPLETED) logger.info(BUILD_COMPLETED)
class BuildXfce(BaseBuilder):
def __init__(self, sbase, sarch, logger): class BuildGflashback:
build_list = conf.build64_xfce_build if sarch[1:] == "64" else ( """
conf.build32_xfce_build if sarch[1:] == "32" else conf.buildarm_xfce_build Determine what base to use and then build the ISO
) """
super().__init__(sbase, sarch, logger, build_list) def __init__(self, sbase, sarch):
self.sbase = sbase
self.sarch = sarch
# Change to the root of Fusato
# then run the buils
os.chdir(HOME_FOLDER + FUSATO_ROOT)
self.build_system()
class BuildGflashback(BaseBuilder): def lb_helper(self):
def __init__(self, sbase, sarch, logger): """
build_list = conf.build64_gfb_build if sarch[1:] == "64" else ( Helper for the lb setup this is shared for all builds
conf.build32_gfb_build if sarch[1:] == "32" else conf.buildarm_gfb_build """
) if self.sbase == "deb":
super().__init__(sbase, sarch, logger, build_list) if self.sarch[1:] == "64":
lbsetup = conf.LBSET_DEB64
os.system(lbsetup)
elif self.sarch[1:] == "32":
lbsetup = conf.LBSET_DEB32
os.system(lbsetup)
elif self.sarch[1:] == "arm":
lbsetup = conf.LBSET_DEBARM
os.system(lbsetup)
else:
lbsetup = None
elif self.sbase == "dev":
if self.sarch[1:] == "64":
lbsetup = conf.LBSET_DEV64
os.system(lbsetup)
elif self.sarch[1:] == "32":
lbsetup = conf.LBSET_DEV32
os.system(lbsetup)
elif self.sarch[1:] == "arm":
lbsetup = conf.LBSET_DEVARM
os.system(lbsetup)
else:
lbsetup = None
def infra_helper(self):
"""
Helper for the infra classes this is shared for all builds
"""
infra.ChrootFolders(self.sbase, self.sarch)
infra.BinaryFolders(self.sbase, self.sarch)
infra.ArchitectureFiles(self.sbase, self.sarch)
infra.Archive(self.sbase, self.sarch)
def gfb_helper(self):
"""
Helper for the gfb desktop shared for all builds
"""
if self.sarch[1:] == "64":
cmd_list = collections.deque(conf.build64_gfb_build)
list_size = len(cmd_list)
for _ in range(list_size):
i = cmd_list.popleft()
execute = i + '()'
exec(execute)
elif self.sarch[1:] == "32":
cmd_list = collections.deque(conf.build32_gfb_build)
list_size = len(cmd_list)
for _ in range(list_size):
i = cmd_list.popleft()
execute = i + '()'
exec(execute)
elif self.sarch[1:] == "arm":
cmd_list = collections.deque(conf.buildarm_gfb_build)
list_size = len(cmd_list)
for _ in range(list_size):
i = cmd_list.popleft()
execute = i + '()'
exec(execute)
else:
cmd_list = None
def cleanup_helper(self):
""" Clean up Helper to move the ISOs to the nightly location """
finish_cleanup.make_check_sum()
finish_cleanup.check_build_type_xfce()
finish_cleanup.kill_old_iso()
def build_system(self):
""" Builds the ISO GFB Depedning on the Arch """
current_working_directory = os.getcwd()
dir_current = WRKING_DIR + current_working_directory
logger.info("Building a " + self.sbase + self.sarch[1:] + " bit ISO")
logger.info(dir_current)
# Set the config tree
self.lb_helper()
# Start with the GFB stuff
self.gfb_helper()
# Run the specific classes
self.infra_helper()
# Run the Build
logger.info(CFG_READY)
logger.info(START_LIVEBUILD)
logger.info(dir_current)
self.lb_helper()
run_cmd = 'sudo lb build'
current_working_directory = os.getcwd()
os.chdir(HOME_FOLDER + FUSATO_ROOT)
# Set the build inidcator
inflate_bubble.make_bld_gnomeflashback(self.sbase, self.sarch[1:])
logger.info(dir_current)
os.system(run_cmd)
logger.info(BUILD_COMPLETED)
logger.info(dir_current)
self.cleanup_helper()
logger.info(BUILD_COMPLETED)
def readybuild(): def readybuild():
"""" Make Ready the bld structure If fusato exists remove it. """" Make Ready the bld structure If fusato exists remove it.
@ -138,69 +295,115 @@ def readybuild():
class Decisions: class Decsions:
""" """
Arguments used to tell the application what to build Aguments used to tell the application what to build
""" """
def __init__(self, logger): def __init__(self):
""" Initialize the building """ # Set up the terminal arguments
self.argument_parser = argparse.ArgumentParser() self.argument_parser = argparse.ArgumentParser()
self.argument_parser.add_argument("set", self.argument_parser.add_argument("set",
help="set what build to start", type=str help="set what build to start",
) type=str
self.argument_parser.add_argument("e", )
help="identify the desktop environment, e.g., e-xfce", type=str self.argument_parser.add_argument("e",
) help="identify the desktop"
self.argument_parser.add_argument("b", " environment for example"
help="identify the ISO to build, e.g., b-deb64", type=str " e-xfce",
) type=str
)
self.argument_parser.add_argument("b",
help="identify the ISO to"
"build for example"
" b-deb64",
type=str
)
self.arguments = self.argument_parser.parse_args() self.arguments = self.argument_parser.parse_args()
self.logger = logger # Then determine what desktop build to look for
self.make_build_decision() if self.arguments.e == 'e-gnomefb':
self.dgnomefb()
elif self.arguments.e == 'e-xfce':
self.dxfce()
elif self.arguments.e == 'e-openbox':
self.dopenbox()
def make_build_decision(self):
""" Make a decision on what to build """
desktop_methods = {
'e-gnomefb': self.dgnomefb,
'e-xfce': self.dxfce,
'e-openbox': self.dopenbox,
}
desktop_method = desktop_methods.get(self.arguments.e)
if desktop_method:
desktop_method()
else:
self.logger.critical("Unsupported desktop environment!")
def build_iso(self, builder_class):
""" Common method for building ISOs """
iso_builders = {
'b-deb64': builder_class("deb", "_64"),
'b-deb32': builder_class("deb", "_32"),
'b-dev64': builder_class("dev", "_64"),
'b-dev32': builder_class("dev", "_32"),
'b-debarm': builder_class("deb", "_arm"),
'b-devarm': builder_class("dev", "_arm"),
}
iso_builder = iso_builders.get(self.arguments.b)
if iso_builder:
readybuild()
iso_builder.initialize()
iso_builder.run_build()
else:
self.logger.critical("Unsupported ISO build!")
def dxfce(self): def dxfce(self):
""" Arguments for the XFCE """ """ Arguments for the XFCE """
self.build_iso(BuildXfce) if self.arguments.e == 'e-xfce':
if self.arguments.b == 'b-deb64':
readybuild()
BuildXfce("deb", "_64")
elif self.arguments.b == 'b-deb32':
readybuild()
BuildXfce("deb", "_32")
elif self.arguments.b == 'b-dev64':
readybuild()
BuildXfce("dev", "_64")
elif self.arguments.b == 'b-dev32':
readybuild()
BuildXfce("dev", "_32")
elif self.arguments.b == 'b-debarm':
readybuild()
BuildXfce("deb", "_arm")
elif self.arguments.b == 'b-devarm':
readybuild()
BuildXfce("dev", "_arm")
else:
logger.critical("You have not specified a build to process!")
def dgnomefb(self): def dgnomefb(self):
""" Arguments for the gnomefb """ """ Arguments for the gnomefb """
self.build_iso(BuildGflashback) if self.arguments.e == 'e-gnomefb':
if self.arguments.b == 'b-deb64':
readybuild()
BuildGflashback("deb", "_64")
elif self.arguments.b == 'b-deb32':
readybuild()
BuildGflashback("deb", "_32")
elif self.arguments.b == 'b-debarm':
readybuild()
BuildGflashback("deb", "_arm")
elif self.arguments.b == 'b-dev32':
readybuild()
BuildGflashback("dev", "_32")
elif self.arguments.b == 'b-dev64':
readybuild()
BuildGflashback("dev", "_64")
elif self.arguments.b == 'b-devarm':
readybuild()
BuildGflashback("dev", "_arm")
else:
logger.critical("You have not specified a build to process!")
def dopenbox(self): def dopenbox(self):
""" Arguments for Openbox """ """ Arguments for the openbox """
# Add logic for Openbox if self.arguments.e == 'e-openbox':
if self.arguments.b == 'b-deb64':
readybuild()
print('run openbox builds deb64')
elif self.arguments.b == 'b-deb32':
readybuild()
print('run openbox builds deb32')
elif self.arguments.b == 'b-dev64':
readybuild()
print('run openbox builds dev64')
elif self.arguments.b == 'b-dev32':
readybuild()
print('run openbox builds dev32')
elif self.arguments.b == 'b-debarm':
readybuild()
print('run openbox builds debarm')
elif self.arguments.b == 'b-devarm':
readybuild()
print('run openbox builds devarm')
else:
print('You have not specified a valid '
'build architecture!!')
else:
logger.critical("You have not specified a valid "
"desktop environment!!")
Decsions()
Decisions()