55 lines
2.0 KiB
Python
55 lines
2.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
SPDX-FileCopyrightText: 2023-2025 PeppermintOS Team
|
|
(peppermintosteam@proton.me)
|
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
This module provides a function to clean up the build environment by removing the 'fusato' directory,
|
|
which is used during the PeppermintOS build process.
|
|
|
|
Credits:
|
|
- PeppermintOS Team (peppermintosteam@proton.me) - Development and maintenance of the project.
|
|
|
|
License:
|
|
This code is distributed under the GNU General Public License version 3 or later (GPL-3.0-or-later).
|
|
For more details, please refer to the LICENSE file included in the project or visit:
|
|
https://www.gnu.org/licenses/gpl-3.0.html
|
|
"""
|
|
|
|
import shutil
|
|
import os
|
|
import sys
|
|
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
sys.path.insert(0, BASE_DIR)
|
|
|
|
try:
|
|
from builder.configs import logger_config
|
|
from builder.core.bootstrap.paths import paths
|
|
|
|
logger = logger_config.setup_logger('cleanup')
|
|
except ImportError as e:
|
|
print(f"Error importing necessary modules: {e}. Ensure your environment is set up correctly.")
|
|
sys.exit(1)
|
|
|
|
def remove_fusato_directory():
|
|
"""
|
|
Removes the 'fusato' directory and all its contents.
|
|
The path to 'fusato' is obtained from the 'paths' module.
|
|
"""
|
|
fusato_path = paths.get('BUILDDIR')
|
|
if fusato_path:
|
|
logger.info(f"=> Removing the 'fusato' directory: {fusato_path}")
|
|
try:
|
|
if os.path.exists(fusato_path):
|
|
shutil.rmtree(fusato_path)
|
|
logger.info(f"=> 'fusato' directory removed successfully.")
|
|
else:
|
|
logger.warning(f"=> 'fusato' directory not found at: {fusato_path}. Nothing to remove.")
|
|
except FileNotFoundError:
|
|
logger.warning(f"=> 'fusato' directory not found at: {fusato_path}. Nothing to remove.")
|
|
except OSError as e:
|
|
logger.error(f"=> Error removing the 'fusato' directory: {e}")
|
|
else:
|
|
logger.warning("=> 'BUILDDIR' variable not defined in the 'paths' module. Cannot remove the 'fusato' directory.") |