Add: Start govel build packages

This commit is contained in:
L0m1g 2025-05-03 18:33:53 +02:00
parent 865ec5def5
commit c26fcdc1db
18 changed files with 37 additions and 26 deletions

View file

@ -1,7 +1,7 @@
FROM fedora:42
RUN dnf -y update && \
dnf -y install python3 python3-pip sqlite tar zstd git bash && \
dnf -y install python3 python3-pip sqlite tar zstd git bash vim && \
dnf clean all
RUN useradd -r -s /sbin/nologin -d /var/lib/erminig pak && \

View file

@ -8,7 +8,8 @@
#
import argparse
from erminig.config import Config
from pathlib import Path
from erminig.core.config import Config
from erminig.controllers.govel.pakva import Pakva
from erminig.controllers.govel.build import run_build_function
@ -24,17 +25,15 @@ def main():
if args.command == "build":
if args.name:
pakva = Pakva(name=args.name, version=None, archive=None)
pakva.read()
pakva = Pakva.load_from_name(args.name)
else:
if not Config.PAKVA_DIR.exists():
print("[GOVEL] Erreur : Aucun Pakva trouvé ici.")
pakva_path = Path.cwd() / "Pakva"
if not pakva_path.exists():
print("[GOVEL] Erreur : Aucun Pakva trouvé dans le dossier courant.")
return
pakva = Pakva(name="local", version=None, archive=None)
pakva.path = Config.PAKVA_DIR
pakva.read()
pakva = Pakva.read(pakva_path)
build_success = run_build_function(pakva.path)
build_success = run_build_function(pakva.path, pakva.name, pakva.version)
if build_success:
print(f"[GOVEL] Build réussi pour {pakva.name}")

View file

@ -11,8 +11,8 @@ import os
import subprocess
import sys
from pathlib import Path
from erminig.system.security import check_root, check_user_exists
from erminig.config import Config # Voilà la différence clé !
from erminig.core.security import check_root, check_user_exists
from erminig.core.config import Config
PAK_USER = Config.PAK_USER

View file

@ -7,7 +7,6 @@
# Libre comme lair, stable comme un menhir, et salé comme le beurre.
#
from abc import ABC, abstractmethod

View file

@ -11,7 +11,6 @@ import json
from pathlib import Path
import yaml
from erminig.controllers.evezh.parsers.github import GitHubSource
from erminig.controllers.evezh.parsers.http import HttpSource
from erminig.controllers.evezh.parsers.sourceforge import SourceForgeRSS

View file

@ -9,9 +9,9 @@
import re
import requests
from erminig.config import Config
from erminig.core.config import Config
from erminig.controllers.evezh.abstract import UpstreamSource
from erminig.system.retry import retry_on_failure
from erminig.core.retry import retry_on_failure
class GitHubSource(UpstreamSource):

View file

@ -10,7 +10,7 @@
import re
import requests
from erminig.controllers.evezh.abstract import UpstreamSource
from erminig.system.retry import retry_on_failure
from erminig.core.retry import retry_on_failure
class HttpSource(UpstreamSource):

View file

@ -11,7 +11,7 @@ import re
import requests
import xml.etree.ElementTree as ET
from erminig.controllers.evezh.abstract import UpstreamSource
from erminig.system.retry import retry_on_failure
from erminig.core.retry import retry_on_failure
class SourceForgeRSS(UpstreamSource):

View file

@ -7,18 +7,30 @@
# Libre comme lair, stable comme un menhir, et salé comme le beurre.
#
import os
import subprocess
from erminig.system.security import check_root, check_user_exists, run_as_user
from erminig.core.config import Config
from erminig.core.security import check_root, check_user_exists, run_as_user
check_root
check_user_exists("pak")
@run_as_user("pak")
def run_build_function(pakva_path):
def run_build_function(pakva_path, name, version):
"""
Exécute la fonction build() du fichier Pakva donné.
"""
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"""
@ -32,6 +44,7 @@ def run_build_function(pakva_path):
stderr=subprocess.PIPE,
executable="/bin/bash",
text=True,
env=env,
)
print(f"[BUILD] Succès : {pakva_path.name}")
print(result.stdout)

View file

@ -8,8 +8,8 @@
#
from pathlib import Path
from erminig.config import Config
from erminig.system.security import run_as_user
from erminig.core.config import Config
from erminig.core.security import run_as_user
class Pakva:

View file

@ -19,6 +19,7 @@ class Config:
PAKVA_DIR = LIB_DIR / "pakva"
GOVEL_DIR = LIB_DIR / "govel"
REPO_DIR = LIB_DIR / "keo"
BUILD_DIR = Path("/tmp/erminig/build")
PAK_USER = "pak"
GITHUB_TOKEN = os.environ.get("GITHUB_TOKEN")

0
erminig/core/package.py Normal file
View file

View file

@ -10,7 +10,7 @@
import time
import requests
from erminig.config import Config
from erminig.core.config import Config
def retry_on_failure():

View file

@ -10,7 +10,7 @@
import os
import pwd
import sqlite3
from erminig.config import Config
from erminig.core.config import Config
def init_db():

View file

@ -7,7 +7,7 @@
# Libre comme lair, stable comme un menhir, et salé comme le beurre.
#
from erminig.config import Config
from erminig.core.config import Config
def test_db_path():

View file

@ -13,7 +13,7 @@ from unittest.mock import patch
# PATCH directement le décorateur run_as_user pour les tests
@patch("erminig.system.security.run_as_user", lambda x=None: (lambda f: f))
@patch("erminig.core.security.run_as_user", lambda x=None: (lambda f: f))
def test_pakva_save_and_read(tmp_path):
from erminig.controllers.govel.pakva import Pakva # Importer après patch !