2025-04-29 17:35:21 +02:00
|
|
|
|
#
|
|
|
|
|
|
# Erminig - Lancement de la construction du paquet
|
|
|
|
|
|
# Copyright (C) 2025 L0m1g
|
|
|
|
|
|
# Sous licence DOUARN - Voir le fichier LICENCE pour les détails
|
|
|
|
|
|
#
|
|
|
|
|
|
# Ce fichier fait partie du projet Erminig.
|
|
|
|
|
|
# Libre comme l’air, stable comme un menhir, et salé comme le beurre.
|
|
|
|
|
|
#
|
|
|
|
|
|
|
2025-05-03 18:33:53 +02:00
|
|
|
|
import os
|
2025-04-29 17:15:19 +02:00
|
|
|
|
import subprocess
|
2025-05-03 18:33:53 +02:00
|
|
|
|
from erminig.core.config import Config
|
|
|
|
|
|
from erminig.core.security import check_root, check_user_exists, run_as_user
|
2025-04-29 17:15:19 +02:00
|
|
|
|
|
|
|
|
|
|
check_root
|
|
|
|
|
|
check_user_exists("pak")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@run_as_user("pak")
|
2025-05-03 18:33:53 +02:00
|
|
|
|
def run_build_function(pakva_path, name, version):
|
2025-04-29 17:15:19 +02:00
|
|
|
|
"""
|
|
|
|
|
|
Exécute la fonction build() du fichier Pakva donné.
|
|
|
|
|
|
"""
|
2025-05-03 18:33:53 +02:00
|
|
|
|
build_root = Config.BUILD_DIR / f"{name}-{version}"
|
|
|
|
|
|
src_dir = build_root / "src"
|
|
|
|
|
|
tmp_dir = build_root / "tmp"
|
|
|
|
|
|
|
|
|
|
|
|
os.makedirs(src_dir, exist_ok=True)
|
|
|
|
|
|
os.makedirs(tmp_dir, exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
env = os.environ.copy()
|
|
|
|
|
|
env["SRC"] = str(src_dir)
|
|
|
|
|
|
env["TMP"] = str(tmp_dir)
|
2025-04-29 17:15:19 +02:00
|
|
|
|
try:
|
|
|
|
|
|
result = subprocess.run(
|
|
|
|
|
|
f"""
|
|
|
|
|
|
set -e
|
|
|
|
|
|
source "{pakva_path}"
|
|
|
|
|
|
build
|
|
|
|
|
|
""",
|
|
|
|
|
|
shell=True,
|
|
|
|
|
|
check=True,
|
|
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
|
|
stderr=subprocess.PIPE,
|
|
|
|
|
|
executable="/bin/bash",
|
|
|
|
|
|
text=True,
|
2025-05-03 18:33:53 +02:00
|
|
|
|
env=env,
|
2025-04-29 17:15:19 +02:00
|
|
|
|
)
|
|
|
|
|
|
print(f"[BUILD] Succès : {pakva_path.name}")
|
|
|
|
|
|
print(result.stdout)
|
|
|
|
|
|
return True
|
|
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
|
|
print(f"[BUILD] Échec : {pakva_path.name}")
|
|
|
|
|
|
print(e.stderr)
|
|
|
|
|
|
return False
|