2023-07-11 06:48:53 +00:00
|
|
|
"""
|
|
|
|
* 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
|
2023-09-07 03:44:34 +00:00
|
|
|
import time
|
2023-09-06 10:27:28 +00:00
|
|
|
|
2023-07-11 06:48:53 +00:00
|
|
|
# Set the home path used regardless the user logged in
|
2023-09-05 14:38:55 +00:00
|
|
|
BSTRING_ISO_CONFIGS = '~/bubbles/iso_configs'
|
|
|
|
HOME_FOLDER = str(Path(BSTRING_ISO_CONFIGS).expanduser())
|
|
|
|
FUSATO_ROOT = '/fusato'
|
2023-10-19 04:52:08 +00:00
|
|
|
# Set the base destination location for the final ISO
|
|
|
|
# Default base is /var/www/html/nightly/
|
2023-12-13 13:42:03 -01:00
|
|
|
BASE_DESTINATION = '/var/www/html/nightly/'
|
2023-10-19 04:52:08 +00:00
|
|
|
# Set the base ISO Name
|
|
|
|
BASE_NAME = 'PeppermintOS'
|
|
|
|
|
|
|
|
|
2023-12-13 12:13:51 -01:00
|
|
|
|
2023-07-11 06:48:53 +00:00
|
|
|
def make_check_sum():
|
|
|
|
""" Generate the check sum files """
|
2023-09-05 14:38:55 +00:00
|
|
|
os.chdir(HOME_FOLDER + FUSATO_ROOT)
|
2023-09-07 01:48:15 +00:00
|
|
|
current_working_directory = os.getcwd().replace('/', '/')
|
2023-12-13 11:26:09 -01:00
|
|
|
for _, _, files in os.walk(current_working_directory):
|
2023-07-11 06:48:53 +00:00
|
|
|
for fiso in files:
|
|
|
|
if fiso.endswith('.iso'):
|
|
|
|
sha = "sha512sum "
|
|
|
|
ext = "-sha512.checksum"
|
|
|
|
gen_sum = sha + fiso + ' >' + fiso + ext
|
|
|
|
os.system(gen_sum)
|
|
|
|
|
2023-12-13 10:01:58 -01:00
|
|
|
def process_iso(base, arch, desktop):
|
2023-09-05 14:38:55 +00:00
|
|
|
"""
|
2023-12-13 10:01:58 -01:00
|
|
|
Process the ISO for a given base, architecture, and desktop.
|
2023-10-19 04:52:08 +00:00
|
|
|
"""
|
|
|
|
current_working_directory = os.listdir(".")
|
|
|
|
today = str(date.today())
|
|
|
|
|
|
|
|
for files in current_working_directory:
|
|
|
|
if files.endswith('.iso'):
|
|
|
|
src_iso = files
|
2023-12-13 10:01:58 -01:00
|
|
|
rdes = f"{BASE_NAME}-{base}_{arch}_{desktop.lower()}{today}.iso"
|
2023-12-13 11:30:55 -01:00
|
|
|
des_iso =f"{BASE_DESTINATION}/{base.lower()}{arch}/{desktop.lower()}"
|
2023-10-19 04:52:08 +00:00
|
|
|
os.rename(src_iso, rdes)
|
|
|
|
shutil.copy(rdes, des_iso)
|
|
|
|
|
2023-12-13 10:01:58 -01:00
|
|
|
elif files.endswith('.checksum'):
|
2023-10-19 06:30:49 +00:00
|
|
|
src_sum = files
|
2023-12-13 11:28:41 -01:00
|
|
|
rdes_sum = f"{BASE_NAME}{base.capitalize()}_{arch}_{desktop.lower()}-sha512.checksum"
|
|
|
|
des_sum = f"{BASE_DESTINATION}/{base.lower()}{arch}/{desktop.lower()}"
|
2023-10-19 06:30:49 +00:00
|
|
|
os.rename(src_sum, rdes_sum)
|
|
|
|
shutil.copy(rdes_sum, des_sum)
|
|
|
|
|
|
|
|
|
2023-12-13 10:01:58 -01:00
|
|
|
def check_build_type():
|
|
|
|
""" Decided which ISO needs to be moved for nightly """
|
|
|
|
# Make sure you are in fustao
|
2023-09-05 14:38:55 +00:00
|
|
|
os.chdir(HOME_FOLDER + FUSATO_ROOT)
|
2023-12-13 10:01:58 -01:00
|
|
|
directory_path = HOME_FOLDER + FUSATO_ROOT
|
|
|
|
file_function_mapping = {
|
2023-12-14 02:51:09 -01:00
|
|
|
'DEB.64xfc': ('deb', '64', 'XFCE'),
|
|
|
|
'DEB.32xfc': ('deb', '32', 'XFCE'),
|
|
|
|
'DEB.armxfc': ('deb', 'arm', 'XFCE'),
|
|
|
|
'DEV.64xfc': ('dev', '64', 'XFCE'),
|
|
|
|
'DEV.32xfc': ('dev', '32', 'XFCE'),
|
|
|
|
'DEV.armxfc': ('dev', 'arm', 'XFCE'),
|
|
|
|
'DEB.64gfb': ('deb', '64', 'GFB'),
|
|
|
|
'DEB.32gfb': ('deb', '32', 'GFB'),
|
|
|
|
'DEB.armgfb': ('deb', 'arm', 'GFB'),
|
|
|
|
'DEV.64gfb': ('dev', '64', 'GFB'),
|
|
|
|
'DEV.32gfb': ('dev', '32', 'GFB'),
|
|
|
|
'DEV.armgfb': ('dev', 'arm', 'GFB'),
|
2023-12-13 10:01:58 -01:00
|
|
|
}
|
2023-09-07 13:42:48 +00:00
|
|
|
|
2023-09-05 14:38:55 +00:00
|
|
|
|
2023-12-13 10:01:58 -01:00
|
|
|
def check_build():
|
|
|
|
""" Check what build is there and call the correct process function """
|
|
|
|
for file_name, params in file_function_mapping.items():
|
|
|
|
file_path = os.path.join(directory_path, file_name)
|
|
|
|
if os.path.exists(file_path):
|
|
|
|
print(f"You are building a {params[0]} {params[1]} {params[2]} ISO type")
|
|
|
|
process_iso(*params)
|
|
|
|
else:
|
|
|
|
print(f"File {file_name} you're not building this ISO type!")
|
2023-09-08 13:56:16 +00:00
|
|
|
|
2023-12-13 10:01:58 -01:00
|
|
|
|
|
|
|
check_build()
|
2023-07-11 06:48:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
def kill_old_iso():
|
|
|
|
""" Delete older ISOs"""
|
2023-10-19 04:52:08 +00:00
|
|
|
base_path = BASE_DESTINATION
|
2023-09-06 10:27:28 +00:00
|
|
|
arch_list = ['deb32/', 'deb64/', 'debarm/', 'dev32/', 'dev64/', 'devarm/']
|
|
|
|
de_list = ['gnome-flashback', 'openbox', 'xfce']
|
|
|
|
for archs in arch_list:
|
|
|
|
for desktops in de_list:
|
|
|
|
full_path = []
|
|
|
|
full_path.append(base_path + archs + desktops)
|
|
|
|
for working_paths in full_path:
|
|
|
|
N = 1
|
|
|
|
os.chdir(os.path.join(os.getcwd(), working_paths))
|
|
|
|
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)
|