Testing: Module Testing
Signed-off-by: debianpepper <pdpdebdevuan@protonmail.com>
This commit is contained in:
parent
7abceec209
commit
321f6a615e
|
@ -41,75 +41,53 @@ BUILD_COMPLETED = "ISO build has completed successfully"
|
|||
BUILD_COMPLETED = "ISO is ready for usage."
|
||||
|
||||
|
||||
class BuildXfce:
|
||||
"""
|
||||
Determine what base to use and then build the ISO
|
||||
"""
|
||||
def __init__(self, sbase, sarch):
|
||||
class BaseBuilder:
|
||||
def __init__(self, sbase, sarch, desktop_helper, build_list):
|
||||
self.sbase = sbase
|
||||
self.sarch = sarch
|
||||
|
||||
|
||||
def initialize(self):
|
||||
self.desktop_helper = desktop_helper
|
||||
self.build_list = build_list
|
||||
# Change to the root of Fusato
|
||||
# then run the build
|
||||
os.chdir(HOME_FOLDER + FUSATO_ROOT)
|
||||
|
||||
|
||||
def run_build(self):
|
||||
self.build_system()
|
||||
|
||||
|
||||
|
||||
|
||||
def lb_helper(self):
|
||||
"""Helper for the lb setup shared for all builds"""
|
||||
# Define a dictionary to map sbase and sarch[1:] to lbsetup values
|
||||
lbsetups = {
|
||||
("deb", "64"): conf.LBSET_DEB64,
|
||||
("deb", "32"): conf.LBSET_DEB32,
|
||||
("deb", "arm"): conf.LBSET_DEBARM,
|
||||
("dev", "64"): conf.LBSET_DEV64,
|
||||
("dev", "32"): conf.LBSET_DEV32,
|
||||
("dev", "arm"): conf.LBSET_DEVARM,
|
||||
}
|
||||
# Get lbsetup based on sbase and sarch[1:]
|
||||
lbsetup = lbsetups.get((self.sbase, self.sarch[1:]))
|
||||
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:
|
||||
os.system(lbsetup)
|
||||
else:
|
||||
# Handle unsupported cases, e.g., raise an exception
|
||||
raise ValueError(f"Unsupported combination: sbase={self.sbase}, sarch={self.sarch[1:]}")
|
||||
|
||||
|
||||
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 xfce_helper(self):
|
||||
"""
|
||||
Helper for the xfce desktop shared for all builds
|
||||
"""
|
||||
def desktop_helper(self):
|
||||
if self.sarch[1:] == "64":
|
||||
cmd_list = collections.deque(conf.build64_xfce_build)
|
||||
cmd_list = collections.deque(self.build_list)
|
||||
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)
|
||||
cmd_list = collections.deque(self.build_list)
|
||||
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)
|
||||
cmd_list = collections.deque(self.build_list)
|
||||
list_size = len(cmd_list)
|
||||
for _ in range(list_size):
|
||||
i = cmd_list.popleft()
|
||||
|
@ -118,162 +96,26 @@ class BuildXfce:
|
|||
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 XFCE Depending on the Arch"""
|
||||
current_working_directory = os.getcwd()
|
||||
dir_current = WRKING_DIR + current_working_directory
|
||||
logger.info(f"Building a {self.sbase}{self.sarch[1:]} bit ISO")
|
||||
logger.info(dir_current)
|
||||
# Set the config tree
|
||||
self.lb_helper()
|
||||
# Start with the XFCE stuff
|
||||
self.xfce_helper()
|
||||
# Run the specific classes
|
||||
self.desktop_helper()
|
||||
self.infra_helper()
|
||||
# Run the Build
|
||||
logger.info(CFG_READY)
|
||||
logger.info(START_LIVEBUILD)
|
||||
logger.info(dir_current)
|
||||
# Build the ISO
|
||||
self.run_iso_build()
|
||||
# Cleanup after build
|
||||
self.cleanup_helper()
|
||||
|
||||
|
||||
def run_iso_build(self):
|
||||
"""Run the ISO build process"""
|
||||
self.lb_helper()
|
||||
run_cmd = 'sudo lb build'
|
||||
current_working_directory = os.getcwd()
|
||||
os.chdir(HOME_FOLDER + FUSATO_ROOT)
|
||||
# Set the build indicator
|
||||
inflate_bubble.make_bld_xfce(self.sbase, self.sarch[1:])
|
||||
logger.info(current_working_directory)
|
||||
# Execute the build command
|
||||
os.system(run_cmd)
|
||||
logger.info(BUILD_COMPLETED)
|
||||
logger.info(current_working_directory)
|
||||
|
||||
|
||||
|
||||
class BuildGflashback:
|
||||
"""
|
||||
Determine what base to use and then build the ISO
|
||||
"""
|
||||
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()
|
||||
|
||||
|
||||
def lb_helper(self):
|
||||
"""
|
||||
Helper for the lb setup this is shared for all builds
|
||||
"""
|
||||
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):
|
||||
"""
|
||||
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)
|
||||
|
@ -282,6 +124,21 @@ class BuildGflashback:
|
|||
logger.info(BUILD_COMPLETED)
|
||||
|
||||
|
||||
class BuildXfce(BaseBuilder):
|
||||
def __init__(self, sbase, sarch):
|
||||
build_list = conf.build64_xfce_build if sarch[1:] == "64" else (
|
||||
conf.build32_xfce_build if sarch[1:] == "32" else conf.buildarm_xfce_build
|
||||
)
|
||||
super().__init__(sbase, sarch, self.xfce_helper, build_list)
|
||||
|
||||
|
||||
class BuildGflashback(BaseBuilder):
|
||||
def __init__(self, sbase, sarch):
|
||||
build_list = conf.build64_gfb_build if sarch[1:] == "64" else (
|
||||
conf.build32_gfb_build if sarch[1:] == "32" else conf.buildarm_gfb_build
|
||||
)
|
||||
super().__init__(sbase, sarch, self.gfb_helper, build_list)
|
||||
|
||||
def readybuild():
|
||||
"""" Make Ready the bld structure If fusato exists remove it.
|
||||
and recreate it, otherwise just make a new folder named
|
||||
|
|
Loading…
Reference in New Issue