bubbles/python_modules/finish_cleanup.py

463 lines
21 KiB
Python

"""
* 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
# 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'
def make_check_sum():
""" Generate the check sum files """
os.chdir(HOME_FOLDER + FUSATO_ROOT)
current_working_directory = os.getcwd()
for files in os.walk(current_working_directory):
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_debian_xfce_based():
""" Copy the new ISO debian baseto its Nightly folder
XFCE
"""
os.chdir(HOME_FOLDER + FUSATO_ROOT)
current_working_directory = os.getcwd()
today = str(date.today())
for files in os.walk(current_working_directory):
for f_v in files:
if f_v.endswith('.64xfc'):
if f_v.endswith('.iso'):
src_iso = current_working_directory + '/' + f_v
rdes = (current_working_directory +
'/PeppermintOS-Debian_64_xfce'
+ today +
'.iso'
)
des_iso = '/var/www/html/nightly/deb64/xfce'
os.rename(src_iso, rdes)
shutil.copy(rdes, des_iso)
if f_v.endswith('.checksum'):
src_sum = current_working_directory + '/' + f_v
rdes_sum = (current_working_directory +
'/PeppermintOS-Debian_64-sha512.checksum'
)
des_sum = '/var/www/html/nightly/deb64/xfce'
os.rename(src_sum, rdes_sum)
shutil.copy(rdes_sum, des_sum)
elif f_v.endswith('.32xfc'):
if f_v.endswith('.iso'):
src_iso = current_working_directory + '/' + f_v
rdes = (current_working_directory +
'/PeppermintOS-Debian_32_xfce'
+ today +
'.iso'
)
des_iso = '/var/www/html/nightly/deb32/xfce'
os.rename(src_iso, rdes)
shutil.copy(rdes, des_iso)
if f_v.endswith('.checksum'):
src_sum = current_working_directory + '/' + f_v
rdes_sum = (current_working_directory +
'/PeppermintOS-Debian_32-sha512.checksum'
)
des_sum = '/var/www/html/nightly/deb32/xfce'
os.rename(src_sum, rdes_sum)
shutil.copy(rdes_sum, des_sum)
elif f_v.endswith('.armxfc'):
if f_v.endswith('.iso'):
src_iso = current_working_directory + '/' + f_v
rdes = (current_working_directory +
'/PeppermintOS-Debian_arm_xfce'
+ today +
'.iso'
)
des_iso = '/var/www/html/nightly/debarm/xfce'
os.rename(src_iso, rdes)
shutil.copy(rdes, des_iso)
if f_v.endswith('.checksum'):
src_sum = current_working_directory + '/' + f_v
rdes_sum = (current_working_directory +
'/PeppermintOS-Debian_arm-sha512.checksum'
)
des_sum = '/var/www/html/nightly/debarm/xfce'
os.rename(src_sum, rdes_sum)
shutil.copy(rdes_sum, des_sum)
def copy_debian_gfb_based():
""" Copy the new ISO debian base to its Nightly folder
Gnome Flashback
"""
os.chdir(HOME_FOLDER + FUSATO_ROOT)
current_working_directory = os.getcwd()
today = str(date.today())
for files in os.walk(current_working_directory):
for f_v in files:
if f_v.endswith('.64gfb'):
if f_v.endswith('.iso'):
src_iso = current_working_directory + '/' + f_v
rdes = (current_working_directory +
'/PeppermintOS-Debian_64_gfb'
+ today +
'.iso'
)
des_iso = '/var/www/html/nightly/deb64/gnome-flashback'
os.rename(src_iso, rdes)
shutil.copy(rdes, des_iso)
if f_v.endswith('.checksum'):
src_sum = current_working_directory + '/' + f_v
rdes_sum = (current_working_directory +
'/PeppermintOS-Debian_64-sha512.checksum'
)
des_sum = '/var/www/html/nightly/deb64/gnome-flashback'
os.rename(src_sum, rdes_sum)
shutil.copy(rdes_sum, des_sum)
elif f_v.endswith('.32gfb'):
if f_v.endswith('.iso'):
src_iso = current_working_directory + '/' + f_v
rdes = (current_working_directory +
'/PeppermintOS-Debian_32_gfb'
+ today +
'.iso'
)
des_iso = '/var/www/html/nightly/deb32/gnome-flashback'
os.rename(src_iso, rdes)
shutil.copy(rdes, des_iso)
if f_v.endswith('.checksum'):
src_sum = current_working_directory + '/' + f_v
rdes_sum = (current_working_directory +
'/PeppermintOS-Debian_32-sha512.checksum'
)
des_sum = '/var/www/html/nightly/deb32/gnome-flashback'
os.rename(src_sum, rdes_sum)
shutil.copy(rdes_sum, des_sum)
elif f_v.endswith('.armgfb'):
if f_v.endswith('.iso'):
src_iso = current_working_directory + '/' + f_v
rdes = (current_working_directory +
'/PeppermintOS-Debian_arm_gfb'
+ today +
'.iso'
)
des_iso = '/var/www/html/nightly/debarm/gnome-flashback'
os.rename(src_iso, rdes)
shutil.copy(rdes, des_iso)
if f_v.endswith('.checksum'):
src_sum = current_working_directory + '/' + f_v
rdes_sum = (current_working_directory +
'/PeppermintOS-Debian_arm-sha512.checksum'
)
des_sum = '/var/www/html/nightly/debarm/gnome-flashback'
os.rename(src_sum, rdes_sum)
shutil.copy(rdes_sum, des_sum)
def copy_debian_opb_based():
""" Copy the new ISO debian base to its Nightly folder
OpenBox
"""
os.chdir(HOME_FOLDER + FUSATO_ROOT)
current_working_directory = os.getcwd()
today = str(date.today())
for files in os.walk(current_working_directory):
for f_v in files:
if f_v.endswith('.64opb'):
if f_v.endswith('.iso'):
src_iso = current_working_directory + '/' + f_v
rdes = (current_working_directory +
'/PeppermintOS-Debian_64_opb'
+ today +
'.iso'
)
des_iso = '/var/www/html/nightly/deb64/openbox'
os.rename(src_iso, rdes)
shutil.copy(rdes, des_iso)
if f_v.endswith('.checksum'):
src_sum = current_working_directory + '/' + f_v
rdes_sum = (current_working_directory +
'/PeppermintOS-Debian_64-sha512.checksum'
)
des_sum = '/var/www/html/nightly/deb64/openbox'
os.rename(src_sum, rdes_sum)
shutil.copy(rdes_sum, des_sum)
elif f_v.endswith('.32opb'):
if f_v.endswith('.iso'):
src_iso = current_working_directory + '/' + f_v
rdes = (current_working_directory +
'/PeppermintOS-Debian_32_opb'
+ today +
'.iso'
)
des_iso = '/var/www/html/nightly/deb32/openbox'
os.rename(src_iso, rdes)
shutil.copy(rdes, des_iso)
if f_v.endswith('.checksum'):
src_sum = current_working_directory + '/' + f_v
rdes_sum = (current_working_directory +
'/PeppermintOS-Debian_32-sha512.checksum'
)
des_sum = '/var/www/html/nightly/deb32/openbox'
os.rename(src_sum, rdes_sum)
shutil.copy(rdes_sum, des_sum)
elif f_v.endswith('.armopb'):
if f_v.endswith('.iso'):
src_iso = current_working_directory + '/' + f_v
rdes = (current_working_directory +
'/PeppermintOS-Debian_arm_opb'
+ today +
'.iso'
)
des_iso = '/var/www/html/nightly/debarm/openbox'
os.rename(src_iso, rdes)
shutil.copy(rdes, des_iso)
if f_v.endswith('.checksum'):
src_sum = current_working_directory + '/' + f_v
rdes_sum = (current_working_directory +
'/PeppermintOS-Debian_arm-sha512.checksum'
)
des_sum = '/var/www/html/nightly/debarm/openbox'
os.rename(src_sum, rdes_sum)
shutil.copy(rdes_sum, des_sum)
def copy_devuan_xfce_based():
""" Copy the new ISO Devuan baseto its Nightly folder
XFCE
"""
os.chdir(HOME_FOLDER + FUSATO_ROOT)
current_working_directory = os.getcwd()
today = str(date.today())
for files in os.walk(current_working_directory):
for f_v in files:
if f_v.endswith('.64xfc'):
if f_v.endswith('.iso'):
src_iso = current_working_directory + '/' + f_v
rdes = (current_working_directory +
'/PeppermintOS-Devuan_64_xfce'
+ today +
'.iso'
)
des_iso = '/var/www/html/nightly/dev64/xfce'
os.rename(src_iso, rdes)
shutil.copy(rdes, des_iso)
if f_v.endswith('.checksum'):
src_sum = current_working_directory + '/' + f_v
rdes_sum = (current_working_directory +
'/PeppermintOS-Devuan_64-sha512.checksum'
)
des_sum = '/var/www/html/nightly/dev64/xfce'
os.rename(src_sum, rdes_sum)
shutil.copy(rdes_sum, des_sum)
elif f_v.endswith('.32xfc'):
if f_v.endswith('.iso'):
src_iso = current_working_directory + '/' + f_v
rdes = (current_working_directory +
'/PeppermintOS-Devuan_32_xfce'
+ today +
'.iso'
)
des_iso = '/var/www/html/nightly/dev32/xfce'
os.rename(src_iso, rdes)
shutil.copy(rdes, des_iso)
if f_v.endswith('.checksum'):
src_sum = current_working_directory + '/' + f_v
rdes_sum = (current_working_directory +
'/PeppermintOS-Devuan_32-sha512.checksum'
)
des_sum = '/var/www/html/nightly/dev32/xfce'
os.rename(src_sum, rdes_sum)
shutil.copy(rdes_sum, des_sum)
elif f_v.endswith('.armxfc'):
if f_v.endswith('.iso'):
src_iso = current_working_directory + '/' + f_v
rdes = (current_working_directory +
'/PeppermintOS-Devuan_arm_xfce'
+ today +
'.iso'
)
des_iso = '/var/www/html/nightly/devarm/xfce'
os.rename(src_iso, rdes)
shutil.copy(rdes, des_iso)
if f_v.endswith('.checksum'):
src_sum = current_working_directory + '/' + f_v
rdes_sum = (current_working_directory +
'/PeppermintOS-Devuan_arm-sha512.checksum'
)
des_sum = '/var/www/html/nightly/devarm/xfce'
os.rename(src_sum, rdes_sum)
shutil.copy(rdes_sum, des_sum)
def copy_devuan_gfb_based():
""" Copy the new ISO Devuan base to its Nightly folder
Gnome Flashback
"""
os.chdir(HOME_FOLDER + FUSATO_ROOT)
current_working_directory = os.getcwd()
today = str(date.today())
for files in os.walk(current_working_directory):
for f_v in files:
if f_v.endswith('.64gfb'):
if f_v.endswith('.iso'):
src_iso = current_working_directory + '/' + f_v
rdes = (current_working_directory +
'/PeppermintOS-Devuan_64_gfb'
+ today +
'.iso'
)
des_iso = '/var/www/html/nightly/dev64/gnome-flashback'
os.rename(src_iso, rdes)
shutil.copy(rdes, des_iso)
if f_v.endswith('.checksum'):
src_sum = current_working_directory + '/' + f_v
rdes_sum = (current_working_directory +
'/PeppermintOS-Devuan_64-sha512.checksum'
)
des_sum = '/var/www/html/nightly/dev64/gnome-flashback'
os.rename(src_sum, rdes_sum)
shutil.copy(rdes_sum, des_sum)
elif f_v.endswith('.32gfb'):
if f_v.endswith('.iso'):
src_iso = current_working_directory + '/' + f_v
rdes = (current_working_directory +
'/PeppermintOS-Devuan_32_gfb'
+ today +
'.iso'
)
des_iso = '/var/www/html/nightly/dev32/gnome-flashback'
os.rename(src_iso, rdes)
shutil.copy(rdes, des_iso)
if f_v.endswith('.checksum'):
src_sum = current_working_directory + '/' + f_v
rdes_sum = (current_working_directory +
'/PeppermintOS-Devuan_32-sha512.checksum'
)
des_sum = '/var/www/html/nightly/dev32/gnome-flashback'
os.rename(src_sum, rdes_sum)
shutil.copy(rdes_sum, des_sum)
elif f_v.endswith('.armgfb'):
if f_v.endswith('.iso'):
src_iso = current_working_directory + '/' + f_v
rdes = (current_working_directory +
'/PeppermintOS-Devuan_arm_gfb'
+ today +
'.iso'
)
des_iso = '/var/www/html/nightly/devarm/gnome-flashback'
os.rename(src_iso, rdes)
shutil.copy(rdes, des_iso)
if f_v.endswith('.checksum'):
src_sum = current_working_directory + '/' + f_v
rdes_sum = (current_working_directory +
'/PeppermintOS-Devuan_arm-sha512.checksum'
)
des_sum = '/var/www/html/nightly/devarm/gnome-flashback'
os.rename(src_sum, rdes_sum)
shutil.copy(rdes_sum, des_sum)
def copy_devuan_opb_based():
""" Copy the new ISO Devuan base to its Nightly folder
OpenBox
"""
os.chdir(HOME_FOLDER + FUSATO_ROOT)
current_working_directory = os.getcwd()
today = str(date.today())
for files in os.walk(current_working_directory):
for f_v in files:
if f_v.endswith('.64opb'):
if f_v.endswith('.iso'):
src_iso = current_working_directory + '/' + f_v
rdes = (current_working_directory +
'/PeppermintOS-Devuan_64_opb'
+ today +
'.iso'
)
des_iso = '/var/www/html/nightly/dev64/openbox'
os.rename(src_iso, rdes)
shutil.copy(rdes, des_iso)
if f_v.endswith('.checksum'):
src_sum = current_working_directory + '/' + f_v
rdes_sum = (current_working_directory +
'/PeppermintOS-Devuan_64-sha512.checksum'
)
des_sum = '/var/www/html/nightly/dev64/openbox'
os.rename(src_sum, rdes_sum)
shutil.copy(rdes_sum, des_sum)
elif f_v.endswith('.32opb'):
if f_v.endswith('.iso'):
src_iso = current_working_directory + '/' + f_v
rdes = (current_working_directory +
'/PeppermintOS-Devuan_32_opb'
+ today +
'.iso'
)
des_iso = '/var/www/html/nightly/dev32/openbox'
os.rename(src_iso, rdes)
shutil.copy(rdes, des_iso)
if f_v.endswith('.checksum'):
src_sum = current_working_directory + '/' + f_v
rdes_sum = (current_working_directory +
'/PeppermintOS-Devuan_32-sha512.checksum'
)
des_sum = '/var/www/html/nightly/dev32/openbox'
os.rename(src_sum, rdes_sum)
shutil.copy(rdes_sum, des_sum)
elif f_v.endswith('.armopb'):
if f_v.endswith('.iso'):
src_iso = current_working_directory + '/' + f_v
rdes = (current_working_directory +
'/PeppermintOS-Devuan_arm_opb'
+ today +
'.iso'
)
des_iso = '/var/www/html/nightly/devarm/openbox'
os.rename(src_iso, rdes)
shutil.copy(rdes, des_iso)
if f_v.endswith('.checksum'):
src_sum = current_working_directory + '/' + f_v
rdes_sum = (current_working_directory +
'/PeppermintOS-Devuan_arm-sha512.checksum'
)
des_sum = '/var/www/html/nightly/devarm/openbox'
os.rename(src_sum, rdes_sum)
shutil.copy(rdes_sum, des_sum)
def kill_old_iso():
""" Delete older ISOs"""
base_path = '/var/www/html/nightly/'
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)