2023-08-24 06:16:56 +00:00
|
|
|
"""
|
|
|
|
* Author: "PeppermintOS Team(peppermintosteam@proton.me)
|
|
|
|
*
|
|
|
|
* License: SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*
|
|
|
|
* Move and copy files as needed
|
|
|
|
"""
|
|
|
|
import os
|
2023-08-25 02:52:30 +00:00
|
|
|
import subprocess
|
2023-08-24 06:16:56 +00:00
|
|
|
import shutil
|
|
|
|
from pathlib import Path
|
|
|
|
import argparse
|
|
|
|
import collections
|
|
|
|
import conf
|
|
|
|
import paths
|
|
|
|
import inflate_bubble
|
|
|
|
import finish_cleanup
|
|
|
|
import infra
|
|
|
|
|
|
|
|
|
|
|
|
# Set the home path used regardless the user logged in
|
|
|
|
BSTRING_ISO_CONFIGS = '~/bubbles/iso_configs'
|
|
|
|
HOME_FOLDER = str(Path(BSTRING_ISO_CONFIGS).expanduser())
|
|
|
|
FUSATO_ROOT = '/fusato'
|
|
|
|
WPCHROOT = '/fusato/config/includes.chroot'
|
2023-08-26 11:58:37 +00:00
|
|
|
term_size = os.get_terminal_size()
|
2023-08-24 06:16:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
class BuildXfce:
|
|
|
|
"""
|
|
|
|
Determine what base to use and then build the ISO
|
|
|
|
"""
|
|
|
|
def __init__(self, sbase, sarch):
|
|
|
|
self.sbase = sbase
|
|
|
|
self.sarch = sarch
|
|
|
|
os.chdir(HOME_FOLDER + FUSATO_ROOT)
|
|
|
|
# Determine what base to build
|
|
|
|
if sbase == "deb":
|
2023-08-27 07:17:45 +00:00
|
|
|
# Run the Debian Build
|
2023-08-24 06:16:56 +00:00
|
|
|
self.debian_build()
|
|
|
|
elif sbase == "dev":
|
|
|
|
self.devuan_build()
|
|
|
|
else:
|
|
|
|
print("No base has been found")
|
|
|
|
|
2023-08-25 04:36:45 +00:00
|
|
|
def run_build(self):
|
2023-08-24 06:16:56 +00:00
|
|
|
""" Run and start the build process"""
|
2023-08-25 03:52:52 +00:00
|
|
|
# run_cmd = 'sudo lb build'
|
2023-08-25 04:36:45 +00:00
|
|
|
current_working_directory = os.getcwd()
|
|
|
|
os.chdir(HOME_FOLDER + FUSATO_ROOT)
|
2023-08-27 07:17:45 +00:00
|
|
|
|
2023-08-25 04:36:45 +00:00
|
|
|
|
|
|
|
|
2023-08-25 03:52:52 +00:00
|
|
|
# os.system(run_cmd)
|
2023-08-25 03:03:27 +00:00
|
|
|
|
2023-08-24 06:16:56 +00:00
|
|
|
|
|
|
|
def debian_build(self):
|
|
|
|
"""
|
|
|
|
Used to build the Debian base XFCE ISO
|
|
|
|
"""
|
|
|
|
if self.sarch == '_64':
|
|
|
|
# livebuild init
|
2023-08-27 07:19:31 +00:00
|
|
|
current_working_directory = os.getcwd()
|
2023-08-26 11:58:37 +00:00
|
|
|
print('=' * term_size.columns)
|
|
|
|
print("INFO: Begin Live Build init")
|
2023-08-27 07:38:22 +00:00
|
|
|
print("INFO: Current working directory" +
|
|
|
|
current_working_directory
|
|
|
|
)
|
2023-08-26 11:58:37 +00:00
|
|
|
print('=' * term_size.columns)
|
2023-08-24 06:16:56 +00:00
|
|
|
lbsetup = conf.lbset_deb64
|
|
|
|
os.system(lbsetup)
|
2023-08-27 07:38:22 +00:00
|
|
|
print("Config tree ready!")
|
|
|
|
# Start with the XFCE stuff
|
2023-08-24 06:16:56 +00:00
|
|
|
cmd_list_64 = collections.deque(conf.build64_xfce_build)
|
|
|
|
list_size_64 = len(cmd_list_64)
|
|
|
|
for _ in range(list_size_64):
|
|
|
|
i = cmd_list_64.popleft()
|
|
|
|
execute = i + '()'
|
2023-08-25 03:03:27 +00:00
|
|
|
exec(execute)
|
2023-08-24 06:16:56 +00:00
|
|
|
# Run the specific classes
|
2023-08-25 03:03:27 +00:00
|
|
|
infra.ChrootFolders("deb", "_64")
|
|
|
|
infra.BinaryFolders("deb", "_64")
|
|
|
|
infra.ArchitectureFiles("deb", "_64")
|
2023-08-24 06:16:56 +00:00
|
|
|
# Run the Build
|
2023-08-26 11:58:37 +00:00
|
|
|
print('=' * term_size.columns)
|
|
|
|
print("INFO: Configs in place start the ISO build process")
|
|
|
|
print('=' * term_size.columns)
|
2023-08-25 04:58:47 +00:00
|
|
|
self.run_build()
|
2023-08-27 07:38:22 +00:00
|
|
|
print('=' * term_size.columns)
|
|
|
|
print("INFO: Current working directory" +
|
|
|
|
current_working_directory
|
|
|
|
)
|
|
|
|
print('=' * term_size.columns)
|
|
|
|
bld_list = collections.deque(conf.shared_run_build)
|
|
|
|
list_size = len(bld_list)
|
|
|
|
for _ in range(list_size):
|
|
|
|
i = bld_list.popleft()
|
2023-08-27 07:39:23 +00:00
|
|
|
execute = i + '()'
|
|
|
|
exec(execute)
|
2023-08-24 06:16:56 +00:00
|
|
|
elif self.sarch == '_32':
|
|
|
|
lbsetup = conf.lbset_deb32
|
|
|
|
os.system(lbsetup)
|
|
|
|
cmd_list_32 = collections.deque(conf.build32_xfce_build)
|
|
|
|
list_size_32 = len(cmd_list_32)
|
|
|
|
for _ in range(list_size_32):
|
|
|
|
i = cmd_list_32.popleft()
|
|
|
|
execute = i + '()'
|
|
|
|
exec(execute)
|
|
|
|
# Run the specific classes
|
|
|
|
infra.ChrootFolders("deb", "_32")
|
|
|
|
infra.BinaryFolders("deb", "_32")
|
|
|
|
infra.ArchitectureFiles("deb", "_31")
|
|
|
|
# Run the Build
|
|
|
|
self.run_build()
|
|
|
|
elif self.sarch == '_arm':
|
|
|
|
lbsetup = conf.lbset_debarm
|
|
|
|
os.system(lbsetup)
|
|
|
|
cmd_list_arm = collections.deque(conf.buildarm_xfce_build)
|
|
|
|
list_size_arm = len(cmd_list_arm)
|
|
|
|
for _ in range(list_size_arm):
|
|
|
|
i = cmd_list_arm.popleft()
|
|
|
|
execute = i + '()'
|
|
|
|
exec(execute)
|
|
|
|
# Run the specific classes
|
|
|
|
infra.ChrootFolders("deb", "_arm")
|
|
|
|
infra.BinaryFolders("deb", "_arm")
|
|
|
|
infra.ArchitectureFiles("deb", "_arm")
|
|
|
|
# Run the Build
|
|
|
|
self.run_build()
|
|
|
|
else:
|
|
|
|
print("No active build specified")
|
|
|
|
|
|
|
|
def devuan_build(self):
|
|
|
|
"""
|
|
|
|
Used to build the Devuan base xfce ISO
|
|
|
|
"""
|
|
|
|
if self.sarch == '_64':
|
|
|
|
lbsetup = conf.lbset_dev64
|
|
|
|
os.system(lbsetup)
|
|
|
|
# Loop though commands
|
|
|
|
cmd_list_64 = collections.deque(conf.build64_xfce_build)
|
|
|
|
list_size_64 = len(cmd_list_64)
|
|
|
|
for _ in range(list_size_64):
|
|
|
|
i = cmd_list_64.popleft()
|
|
|
|
execute = i + '()'
|
|
|
|
exec(execute)
|
|
|
|
# Run the specific classes
|
|
|
|
infra.ChrootFolders("dev", "_64")
|
|
|
|
infra.BinaryFolders("dev", "_64")
|
|
|
|
infra.ArchitectureFiles("dev", "_64")
|
|
|
|
# Run the Build
|
|
|
|
self.run_build()
|
|
|
|
elif self.sarch == '_32':
|
|
|
|
lbsetup = conf.lbset_dev32
|
|
|
|
os.system(lbsetup)
|
|
|
|
cmd_list_32 = collections.deque(conf.build32_xfce_build)
|
|
|
|
list_size_32 = len(cmd_list_32)
|
|
|
|
for _ in range(list_size_32):
|
|
|
|
i = cmd_list_32.popleft()
|
|
|
|
execute = i + '()'
|
|
|
|
exec(execute)
|
|
|
|
# Run the specific classes
|
|
|
|
infra.ChrootFolders("dev", "_32")
|
|
|
|
infra.BinaryFolders("dev", "_32")
|
|
|
|
infra.ArchitectureFiles("dev", "_31")
|
|
|
|
# Run the build
|
|
|
|
self.run_build()
|
|
|
|
else:
|
|
|
|
lbsetup = conf.lbset_devarm
|
|
|
|
os.system(lbsetup)
|
|
|
|
cmd_list_arm = collections.deque(conf.buildarm_xfce_build)
|
|
|
|
list_size_arm = len(cmd_list_arm)
|
|
|
|
for list_size in range(list_size_arm):
|
|
|
|
i = cmd_list_arm.popleft()
|
|
|
|
execute = i + '()'
|
|
|
|
exec(execute)
|
|
|
|
# Run the specific classes
|
|
|
|
infra.ChrootFolders("dev", "_arm")
|
|
|
|
infra.BinaryFolders("dev", "_arm")
|
|
|
|
infra.ArchitectureFiles("dev", "_arm")
|
|
|
|
# Run the Build
|
|
|
|
self.run_build()
|
|
|
|
|
|
|
|
|
|
|
|
def readybuild():
|
|
|
|
"""" Make Ready the bld structure If fusato exists remove it.
|
|
|
|
and recreate it, otherwise just make a new folder named
|
|
|
|
fusato.
|
|
|
|
"""
|
2023-08-27 07:17:45 +00:00
|
|
|
print("INFO: Making ready the fusato build directory")
|
2023-08-24 06:16:56 +00:00
|
|
|
os.chdir(HOME_FOLDER)
|
|
|
|
if os.path.exists('fusato'):
|
|
|
|
rm_cmd = "sudo rm -r -f fusato"
|
|
|
|
os.system(rm_cmd)
|
|
|
|
os.makedirs('fusato')
|
|
|
|
else:
|
|
|
|
os.makedirs('fusato')
|
|
|
|
|
|
|
|
|
|
|
|
class Decsions:
|
|
|
|
"""
|
|
|
|
Aguments used to tell the application what to build
|
|
|
|
"""
|
|
|
|
def __init__(self):
|
|
|
|
# Set up the terminal arguments
|
|
|
|
self.argument_parser = argparse.ArgumentParser()
|
|
|
|
self.argument_parser.add_argument("set",
|
|
|
|
help="set what build to start",
|
|
|
|
type=str
|
|
|
|
)
|
|
|
|
self.argument_parser.add_argument("e",
|
|
|
|
help="identify the desktop"
|
|
|
|
" environment for example"
|
|
|
|
" 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()
|
|
|
|
# Then determine what desktop build to look for
|
|
|
|
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 dxfce(self):
|
|
|
|
""" Arguments for the XFCE """
|
|
|
|
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:
|
|
|
|
print('You have not specified a valid '
|
|
|
|
'build architecture!!'
|
|
|
|
)
|
|
|
|
|
|
|
|
def dgnomefb(self):
|
|
|
|
""" Arguments for the gnomefb """
|
|
|
|
if self.arguments.e == 'e-gnomefb':
|
|
|
|
if self.arguments.b == 'b-deb64':
|
|
|
|
readybuild()
|
|
|
|
print('run gnomefb builds deb64')
|
|
|
|
elif self.arguments.b == 'b-deb32':
|
|
|
|
readybuild()
|
|
|
|
print('run gnomefb builds deb32')
|
|
|
|
elif self.arguments.b == 'b-dev64':
|
|
|
|
readybuild()
|
|
|
|
print('run gnomefb builds dev64')
|
|
|
|
elif self.arguments.b == 'b-dev32':
|
|
|
|
readybuild()
|
|
|
|
print('run gnomefb builds dev32')
|
|
|
|
elif self.arguments.b == 'b-debarm':
|
|
|
|
readybuild()
|
|
|
|
print('run gnomefb builds debarm')
|
|
|
|
elif self.arguments.b == 'b-devarm':
|
|
|
|
readybuild()
|
|
|
|
print('run gnomefb builds devarm')
|
|
|
|
else:
|
|
|
|
print('You have not specified a valid '
|
|
|
|
'build architecture!!')
|
|
|
|
|
|
|
|
def dopenbox(self):
|
|
|
|
""" Arguments for the 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:
|
|
|
|
print('You have not specified a valid '
|
|
|
|
'desktop environment!!')
|
|
|
|
|
|
|
|
|
|
|
|
Decsions()
|