""" * Author: "PeppermintOS Team(peppermintosteam@proton.me) * * License: SPDX-License-Identifier: GPL-3.0-or-later * * Set the infrastructure for bubbles to begin the ISO build * This copied needed confog files to the binary and chroot * locations, based o the build base and architecture """ import os import sys from io import StringIO import collections from pathlib import Path import shutil import logging import paths # Public Variables used in the classes BSTRING_ISO_CONFIGS = '~/bubbles/iso_configs' HOME_FOLDER = str(Path(BSTRING_ISO_CONFIGS).expanduser()) WPCHROOT = "/fusato/config/includes.chroot" BINARYPTH = "/fusato/config/include.binary" BOOTSTRAP = "/fusato/config/includes.bootstrap" FUSATOCONFIG = "/fusato/config" class Processing(list): def __enter__(self): self._stdout = sys.stdout sys.stdout = self._stringio = StringIO() return self def __exit__(self, *args): self.extend(self._stringio.getvalue().splitlines()) del self._stringio # free up some memory sys.stdout = self._stdout class ChrootFolders: """ Copy all the needed folders to CHROOT Depending on the architecture it will, copy folders as needed """ def __init__(self,sbase,sarch): print("Copy Chroot") self.sbase = sbase self.sarch = sarch src_chroot = ('/osrelease/' + self.sbase + self.sarch, '/osrelease/' + self.sbase + self.sarch, '/grub/'+ self.sbase + self.sarch, '/calamares_settings/' + self.sbase + self.sarch + '/calamares/modules', '/grub/' + self.sbase + '_themes' ) des_chroot =('/usr/lib', '/opt/pepconf', '/etc/default/grub', '/etc/calamares/modules', '/boot/grub/themes' ) # Chroot Folders. chroot_src_q = collections.deque(src_chroot) chroot_des_q = collections.deque(des_chroot) chroot_size_q = len(chroot_src_q) for size_length in range(chroot_size_q): source = chroot_src_q.popleft() des = chroot_des_q.popleft() shutil.copytree(HOME_FOLDER + source, HOME_FOLDER + WPCHROOT + des, dirs_exist_ok = True ) class BinaryFolders: """ Copy all the needed folders to BINARY Depending on the architecture it will, copy folders as needed """ def __init__(self, sbase, sarch): print("Copy Binary") self.sbase = sbase self.sarch = sarch src_binary = ('/splash/' + self.sbase + self.sarch + '/boot', '/splash/' + self.sbase + self.sarch +'/isolinux', '/splash/' + self.sbase + '_live-theme', '/splash/' + self.sbase + '_splash', '/splash/' + self.sbase + '_splash' ) des_binary =('/boot', '/isolinux', '/boot/grub', '/isolinux', '/boot/grub' ) # Binary Folders binary_src_q = collections.deque(src_binary) binary_des_q = collections.deque(des_binary) binary_size_q = len(binary_src_q) for size_length in range(binary_size_q): source = binary_src_q.popleft() des = binary_des_q.popleft() shutil.copytree(HOME_FOLDER + source, HOME_FOLDER + BINARYPTH + des, dirs_exist_ok = True ) class ArchitectureFiles: """ Copy all the needed files to CHROOT Depending on the architecture it will, copy files as needed """ def __init__(self, sbase, sarch): print("Copy Architecture") self.sbase = sbase self.sarch = sarch calamares_path = '/calamares_settings/' sources_path = '/sources/' src_paths = (calamares_path + self.sbase + self.sarch + '/calamares/settings.conf', calamares_path + self.sbase + self.sarch + '/install-peppermint', calamares_path + self.sbase + self.sarch + '/sources-final', calamares_path + self.sbase + self.sarch + '/bootloader-config', calamares_path + 'adddesktopicon/add-calamares-desktop-icon', sources_path + self.sbase + self.sarch + '/sources.list', '/id_files/pep_id' ) des_paths = ('/etc/calamares/settings.conf', '/usr/bin/install-peppermint', '/usr/sbin/sources-final', '/usr/sbin/bootloader-config', '/usr/bin/add-calamares-desktop-icon', '/opt/pepconf/sources.list', '/usr/share/peppermint/pep_id' ) # copy files to thier CHROOT Location src_q = collections.deque(src_paths) des_q = collections.deque(des_paths) size_q = len(src_q) for size_length in range(size_q): source = src_q.popleft() des = des_q.popleft() shutil.copy(HOME_FOLDER + source, HOME_FOLDER + WPCHROOT + des ) def set_symlinks(): """ Set the symliknks that are used for all builds. """ print("Copy symlinks") pep_info = '/usr/share/python-apt/templates/Peppermint.info' pep_mirror = '/usr/share/python-apt/templates/Peppermint.mirrors' pep_csv = '/usr/share/distro-info/peppermint.csv' os.symlink('Debian.info', HOME_FOLDER + WPCHROOT + pep_info) os.symlink('Debian.mirrors', HOME_FOLDER + WPCHROOT + pep_mirror) os.symlink('debian.csv', HOME_FOLDER + WPCHROOT + pep_csv) def shared_folders(): """ This function will get the files that are shared commonly amongst all the builds, """ print("Copy Shared folders") src_paths = ('/plymouth/lines', '/application', '/font', '/hooks/live', '/issue', '/issue', '/polkit', '/database', '/user_config', '/PepProPixMaps', '/wallpaper', '/menu/menus', '/face', '/neofetch/neofetch', '/pmostools', '/autostart', '/pylibraries', '/desktop_base/lines-theme/grub', '/desktop_base/lines-theme/lockscreen', '/desktop_base/lines-theme/login', '/desktop_base/lines-theme/wallpaper' ) des_paths =('/usr/share/plymouth/themes/lines', '/usr/share/applications', '/usr/share/fonts/pepconf', '/usr/lib/live/config', '/etc', '/opt/pepconf', '/usr/share/polkit-1/actions', '/opt/pypep/dbpep', '/etc/live/config.conf.d', '/usr/share/pixmaps', '/usr/share/backgrounds', '/etc/skel/.config/menus', '/etc/skel/', '/etc/skel/.config/neofetch', '/etc/skel/.local/share/pmostools', '/etc/skel/.config/autostart', '/usr/lib/python3/dist-packages', '/usr/share/desktop-base/lines-theme/grub', '/usr/share/desktop-base/lines-theme/lockscreen' '/usr/share/desktop-base/lines-theme/login', '/usr/share/desktop-base/lines-theme/wallpaper' ) src_q = collections.deque(src_paths) des_q = collections.deque(des_paths) size_q = len(des_q) for size_length in range(size_q): source = src_q.popleft() des = des_q.popleft() shutil.copytree(HOME_FOLDER + source, HOME_FOLDER + WPCHROOT + des, dirs_exist_ok = True ) def icons_themes(): """ This function will get the icons and themse that are for all the builds """ print("Copy icons and themes") logging.info('Working in %s' % path) src_paths =('/theme/Marwaita Dark Debian/', '/theme/Marwaita Dark Manjaro/', '/theme/Marwaita Dark Peppermint/', '/theme/Marwaita Debian/', '/theme/Marwaita Manjaro/', '/theme/Marwaita Peppermint/', '/icons/Tela-circle-blue-dark/', '/icons/Tela-circle-green-dark/', '/icons/Tela-circle-red-dark/', '/icons/Tela-circle-blue/', '/icons/Tela-circle-green/', '/icons/Tela-circle-red/', '/icons/Tela-circle/' ) des_paths = ('/usr/share/themes/Marwaita Dark Debian/', '/usr/share/themes/Marwaita Dark Manjaro/', '/usr/share/themes/Marwaita Dark Peppermint/', '/usr/share/themes/Marwaita Debian/', '/usr/share/themes/Marwaita Manjaro/', '/usr/share/themes/Marwaita Peppermint/', '/usr/share/icons/Tela-circle-blue-dark/', '/usr/share/icons/Tela-circle-green-dark/', '/usr/share/icons/Tela-circle-red-dark/', '/usr/share/icons/Tela-circle-blue/', '/usr/share/icons/Tela-circle-green/', '/usr/share/icons/Tela-circle-red/', '/usr/share/icons/Tela-circle/' ) src_q = collections.deque(src_paths) des_q = collections.deque(des_paths) size_q = len(src_q) for size_length in range(size_q): source = src_q.popleft() des = des_q.popleft() shutil.copytree(HOME_FOLDER + source, HOME_FOLDER + WPCHROOT + des, dirs_exist_ok = True ) def shared_files(): """ This silll copy all specific files that a used for all builds. """ print("Copy Shared Files") src_paths = ('/aliases/bash_aliases', '/PepProTools/xDaily', '/PepProTools/hub', '/PepProTools/welcome', '/PepProTools/kumo', '/lightdm/lightdm.conf', '/lightdm/lightdm-gtk-greeter.conf', '/plymouth/plymouthd.conf', '/application/plank.desktop' ) des_paths = ('/etc/skel/.bash_aliases', '/usr/local/bin/xDaily', '/usr/local/bin/hub', '/usr/local/bin/welcome', '/usr/local/bin/kumo', '/etc/lightdm/lightdm.conf', '/etc/lightdm/lightdm-gtk-greeter.conf', '/usr/share/plymouthd.conf', '/etc/skel/.config/autostart/plank.desktop', ) # copy files to thier CHROOT Location src_q = collections.deque(src_paths) des_q = collections.deque(des_paths) size_q = len(src_q) for size_length in range(size_q): source = src_q.popleft() des = des_q.popleft() shutil.copy(HOME_FOLDER + source, HOME_FOLDER + WPCHROOT + des ) def fusato_configs(): """ Copy specific folders in the root of fusato configs """ print("Copy Fusato Configs") src_paths = ('/hooks/normal',) des_paths = ('/hooks/normal',) src_q = collections.deque(src_paths) des_q = collections.deque(des_paths) size_q = len(src_q) for size_length in range(size_q): source = src_q.popleft() des = des_q.popleft() shutil.copytree(HOME_FOLDER + source, HOME_FOLDER + FUSATOCONFIG + des, dirs_exist_ok = True ) def boostrap_shared(): """ Copy specific folders in the boostrap location """ print("Copy Shared BootStrap") src_paths = ('/issue',) des_paths = ('/etc',) src_q = collections.deque(src_paths) des_q = collections.deque(des_paths) size_q = len(src_q) for size_length in range(size_q): source = src_q.popleft() des = des_q.popleft() shutil.copytree(HOME_FOLDER + source, HOME_FOLDER + BOOTSTRAP + des, dirs_exist_ok = True ) def xfce_configs(): """ Copy the xfce files. """ print("Copy xfce4 configs") src_xfce = '/xfce/xfce4' des_xfce = '/etc/skel/.config/xfce4' shutil.copytree(HOME_FOLDER + src_xfce, HOME_FOLDER + WPCHROOT + des_xfce, dirs_exist_ok = True ) src_thunar = '/xfce/Thunar' des_thunar = '/etc/skel/.config/Thunar' shutil.copytree(HOME_FOLDER + src_thunar, HOME_FOLDER + WPCHROOT + des_thunar, dirs_exist_ok = True ) def gnome_flahsbak_configs(): """ Copy the gnome flashback files """ print("Copy Gnome Flashback configs") src_gnomef = '/gnome-flashback' des_gnomef = '/etc/skel/.config/gnome-flashback' shutil.copytree(HOME_FOLDER + src_gnomef, HOME_FOLDER + WPCHROOT + des_gnomef, dirs_exist_ok = True )