""" * Author: "PeppermintOS Team(peppermintosteam@proton.me) * * License: SPDX-License-Identifier: GPL-3.0-or-later * * Clean up the working folder and move ISO and other files """ import os import shutil from pathlib import Path from datetime import date import paths import time # Set the home path used regardless the user logged in bstring = '~/bubbles/iso_configs/fusato' home_folder = Path( bstring ).expanduser() string_home = str(home_folder) def make_check_sum(): """ Generate the check sum files """ current_dir = os.getcwd().replace('/', '/') for root, dirs, files in os.walk(current_dir): for fiso in files: if fiso.endswith('.iso'): sha = "sha512sum " ext = "-sha512.checksum" gen_sum = sha + fiso + ' >' + fiso + ext os.system(gen_sum) def copy_iso_file_nightly_deb32(): """ Copy the new ISO to the Nightly folder""" # Set the home path used regardless the user logged in bstring = '/home/pepadmin/bubbles/iso_configs/fusato' home_folder = Path( bstring ).expanduser() string_home = str(home_folder) today = str(date.today()) os.chdir(home_folder) for root, dirs, files in os.walk(home_folder): for fiso in files: if fiso.endswith('.iso'): src_iso = string_home + '/' + fiso rdes = string_home + '/PeppermintOS-Debian_32_' + today + '.iso' des_iso = '/var/www/html/nightly/deb32' os.rename(src_iso, rdes) shutil.copy(rdes, des_iso) for fsum in files: if fsum.endswith('.checksum'): src_sum = string_home + '/' + fsum rdes_sum = string_home + '/PeppermintOS-Debian_32-sha512.checksum' des_sum = '/var/www/html/nightly/deb32' os.rename(src_sum, rdes_sum) shutil.copy(rdes_sum, des_sum) def copy_iso_file_nightly_deb64(): """ Copy the new ISO to the Nightly folder""" # Set the home path used regardless the user logged in bstring = '/home/pepadmin/bubbles/iso_configs/fusato' home_folder = Path( bstring ).expanduser() string_home = str(home_folder) today = str(date.today()) os.chdir(home_folder) for root, dirs, files in os.walk(home_folder): for fiso in files: if fiso.endswith('.iso'): src_iso = string_home + '/' + fiso rdes = string_home + '/PeppermintOS-Debian_64_' + today + '.iso' des_iso = '/var/www/html/nightly/deb64' os.rename(src_iso, rdes) shutil.copy(rdes, des_iso) for fsum in files: if fsum.endswith('.checksum'): src_sum = string_home + '/' + fsum rdes_sum = string_home + '/PeppermintOS-Debian_64-sha512.checksum' des_sum = '/var/www/html/nightly/deb64' os.rename(src_sum, rdes_sum) shutil.copy(rdes_sum, des_sum) def copy_iso_file_nightly_dev32(): """ Copy the new ISO to the Nightly folder""" # Set the home path used regardless the user logged in bstring = '/home/pepadmin/bubbles/iso_configs/fusato' home_folder = Path( bstring ).expanduser() string_home = str(home_folder) today = str(date.today()) os.chdir(home_folder) for root, dirs, files in os.walk(home_folder): for fiso in files: if fiso.endswith('.iso'): src_iso = string_home + '/' + fiso rdes = string_home + '/PeppermintOS-Devuan_32_' + today + '.iso' des_iso = '/var/www/html/nightly/dev32' os.rename(src_iso, rdes) shutil.copy(rdes, des_iso) for fsum in files: if fsum.endswith('.checksum'): src_sum = string_home + '/' + fsum rdes_sum = string_home + '/PeppermintOS-Devuan_32-sha512.checksum' des_sum = '/var/www/html/nightly/dev32' os.rename(src_sum, rdes_sum) shutil.copy(rdes_sum, des_sum) def copy_iso_file_nightly_dev64(): """ Copy the new ISO to the Nightly folder""" # Set the home path used regardless the user logged in bstring = '/home/pepadmin/bubbles/iso_configs/fusato' home_folder = Path( bstring ).expanduser() string_home = str(home_folder) today = str(date.today()) os.chdir(home_folder) for root, dirs, files in os.walk(home_folder): for fiso in files: if fiso.endswith('.iso'): src_iso = string_home + '/' + fiso rdes = string_home + '/PeppermintOS-Devuan_64_' + today + '.iso' des_iso = '/var/www/html/nightly/dev64' os.rename(src_iso, rdes) shutil.copy(rdes, des_iso) for fsum in files: if fsum.endswith('.checksum'): src_sum = string_home + '/' + fsum rdes_sum = string_home + '/PeppermintOS-Devuan_64-sha512.checksum' des_sum = '/var/www/html/nightly/dev64' os.rename(src_sum, rdes_sum) shutil.copy(rdes_sum, des_sum) def copy_iso_file_prod_deb64(): """ Copy the pro nightly and prep it for production push""" today = str(date.today()) nstring = '/var/www/html/nightly/deb64' nightly_folder = Path( nstring ).expanduser() string_nightly = str(nightly_folder) pstring= '/var/www/html/prod' production_folder = Path( pstring ).expanduser() string_production = str(production_folder) src_iso = string_nightly + '/PeppermintOS-Debian_64_' + today + '.iso' src_checksum = string_nightly + '/PeppermintOS-Debian_64-sha512.checksum' rdes = string_nightly + '/PeppermintOS-Debian-64.iso' des_iso = pstring os.rename(src_iso, rdes) shutil.copy(rdes, des_iso) shutil.copy(src_checksum, des_iso) os.remove(rdes) os.remove(src_checksum) def copy_iso_file_nightly_debarm(): """ Copy the new ISO to the Nightly folder""" # Set the home path used regardless the user logged in bstring = '/home/pepadmin/bubbles/iso_configs/fusato' home_folder = Path( bstring ).expanduser() string_home = str(home_folder) today = str(date.today()) os.chdir(home_folder) for root, dirs, files in os.walk(home_folder): for fiso in files: if fiso.endswith('.iso'): src_iso = string_home + '/' + fiso rdes = string_home + '/PeppermintOS-Debian_arm_' + today + '.iso' des_iso = '/var/www/html/nightly/debarm' os.rename(src_iso, rdes) shutil.copy(rdes, des_iso) for fsum in files: if fsum.endswith('.checksum'): src_sum = string_home + '/' + fsum rdes_sum = string_home + '/PeppermintOS-Debian_arm-sha512.checksum' des_sum = '/var/www/html/nightly/debarm' os.rename(src_sum, rdes_sum) shutil.copy(rdes_sum, des_sum) def copy_iso_file_nightly_devarm(): """ Copy the new ISO to the Nightly folder""" # Set the home path used regardless the user logged in bstring = '/home/pepadmin/bubbles/iso_configs/fusato' home_folder = Path( bstring ).expanduser() string_home = str(home_folder) today = str(date.today()) os.chdir(home_folder) for root, dirs, files in os.walk(home_folder): for fiso in files: if fiso.endswith('.iso'): src_iso = string_home + '/' + fiso rdes = string_home + '/PeppermintOS-Devuan_arm_' + today + '.iso' des_iso = '/var/www/html/nightly/devarm' os.rename(src_iso, rdes) shutil.copy(rdes, des_iso) for fsum in files: if fsum.endswith('.checksum'): src_sum = string_home + '/' + fsum rdes_sum = string_home + '/PeppermintOS-Devuan_arm-sha512.checksum' des_sum = '/var/www/html/nightly/devarm' os.rename(src_sum, rdes_sum) shutil.copy(rdes_sum, des_sum) def kill_fusato(): """ Delete the fusato folder as it is no longer needed""" icstring ='~/bubbles/iso_configs/' ic_root = Path( icstring ).expanduser() os.chdir(ic_root) current_dir = os.getcwd().replace('/', '/') del_fldr = "fusato" del_path = os.path.join(current_dir, del_fldr) os.rmdir(del_path) def kill_old_iso(): """ Delete older ISOs""" for p in paths.nightly_paths: N = 1 os.chdir(os.path.join(os.getcwd(), p)) list_of_files = os.listdir() current_time = time.time() day = 86400 for fls in list_of_files: file_location = os.path.join(os.getcwd(), fls) file_time = os.stat(file_location).st_mtime if file_time < current_time - day*N: print(f" Delete : {fls}") os.remove(file_location)