Add: First packages build
This commit is contained in:
parent
c26fcdc1db
commit
db9b597878
3 changed files with 112 additions and 9 deletions
|
|
@ -16,27 +16,26 @@ check_root
|
|||
check_user_exists("pak")
|
||||
|
||||
|
||||
@run_as_user("pak")
|
||||
def run_build_function(pakva_path, name, version):
|
||||
def run_pakva_function(pakva_path, name, version, func_name):
|
||||
"""
|
||||
Exécute la fonction build() du fichier Pakva donné.
|
||||
Exécute une fonction d’un fichier Pakva donné (ex: build, pak).
|
||||
"""
|
||||
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)
|
||||
|
||||
try:
|
||||
result = subprocess.run(
|
||||
f"""
|
||||
set -e
|
||||
source "{pakva_path}"
|
||||
build
|
||||
{func_name}
|
||||
""",
|
||||
shell=True,
|
||||
check=True,
|
||||
|
|
@ -46,10 +45,19 @@ def run_build_function(pakva_path, name, version):
|
|||
text=True,
|
||||
env=env,
|
||||
)
|
||||
print(f"[BUILD] Succès : {pakva_path.name}")
|
||||
print(f"[{func_name.upper()}] Succès : {pakva_path.name}")
|
||||
print(result.stdout)
|
||||
return True
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"[BUILD] Échec : {pakva_path.name}")
|
||||
print(f"[{func_name.upper()}] Échec : {pakva_path.name}")
|
||||
print(e.stderr)
|
||||
return False
|
||||
|
||||
|
||||
@run_as_user("pak")
|
||||
def run_build_function(pakva_path, name, version):
|
||||
return run_pakva_function(pakva_path, name, version, "build")
|
||||
|
||||
|
||||
def run_pak_function(pakva_path, name, version):
|
||||
return run_pakva_function(pakva_path, name, version, "pak")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue