Files
RetroDebian/features/sample-feature/entry.py
2026-03-27 23:21:55 +01:00

51 lines
1.8 KiB
Python

#!/usr/bin/env python3
from __future__ import annotations
import sys
from pathlib import Path
THIS_FILE = Path(__file__).resolve()
PROJECT_ROOT = THIS_FILE.parents[2]
PY_ROOT = PROJECT_ROOT / 'builder' / 'py'
if str(PY_ROOT) not in sys.path:
sys.path.insert(0, str(PY_ROOT))
from retrobuilder.context import BuildContext
from retrobuilder.entrypoints import FeatureEntry, cli_dispatch
from retrobuilder.model import FeatureSpec
SPEC = FeatureSpec(
description='Sample feature used to validate the V2 builder flow.',
docker_overrides={
# 'pre-gen': {'image': 'python:3.11-alpine'},
# 'post-gen': {'dockerfile': 'features/sample-feature/Dockerfile.python'},
# 'pre-inj': {'image': 'retrodebian/custom-lenny:latest'},
},
)
class Entry(FeatureEntry):
def _marker(self, ctx: BuildContext, name: str) -> Path:
ctx.current_module_artifact_dir.mkdir(parents=True, exist_ok=True)
return ctx.current_module_artifact_dir / name
def pre_gen(self, ctx: BuildContext) -> None:
self._marker(ctx, 'pre-gen.txt').write_text('sample-feature pre-gen\n', encoding='utf-8')
def post_gen(self, ctx: BuildContext) -> None:
self._marker(ctx, 'post-gen.txt').write_text('sample-feature post-gen\n', encoding='utf-8')
def pre_inj(self, ctx: BuildContext) -> None:
notes = ctx.live_dir / 'builder-notes'
notes.mkdir(parents=True, exist_ok=True)
(notes / 'feature-pre-inj.txt').write_text('sample-feature pre-inj\n', encoding='utf-8')
def post_inj(self, ctx: BuildContext) -> None:
notes = ctx.live_dir / 'builder-notes'
notes.mkdir(parents=True, exist_ok=True)
(notes / 'feature-post-inj.txt').write_text('sample-feature post-inj\n', encoding='utf-8')
if __name__ == '__main__':
raise SystemExit(cli_dispatch(SPEC, Entry))