refactor(cook): data-driven recipe generation with in-process flatten and lint

Replace the hardcoded TEMPLATES dict and the ksflatten-relative wrapper
with a single data-driven pipeline:

- recipe_templates.yaml becomes the single source of truth with three
  sections: base (always included), choices (exactly-one per category,
  the invariant pykickstart cannot check) and features (additive flags
  or one-of values)
- generate_recipe.py is a pure YAML consumer: it resolves ingredients,
  renders dishes via pykickstart in-process (no ksflatten binary, no
  %include path munging), lints the invariants pykickstart cannot check
  (exactly-one per choice category, known keys, existing fragments,
  unique filenames) and validates every generated dish
- dish names are derived by a generic rule with canonical category order
  from the templates, independent of YAML key order; no committed
  generated files means no name burn-in
- recipes/ and dishes/ become gitignored build products; the 68 tracked
  generated files (already out of sync with the manifest) are removed
- delete dead ingredients (section-data/, validation/, initial-setup/
  desktop/, live/hypervisor.ks, rpmfusion-nonfree.ks), the stale
  all-ingredients.cfg (replaced by 'make inventory') and the
  bin/generate-recipe and bin/ksflatten-relative wrappers
- Makefile: single 'make all' step plus lint, validate, inventory, test
- add 16 pytest tests covering expansion, selection, naming, lint and
  flatten/validate round-trips
This commit is contained in:
Lukas Greve
2026-08-30 12:09:42 +02:00
parent 842f754681
commit ae6eef4045
87 changed files with 686 additions and 6127 deletions
+40 -40
View File
@@ -1,52 +1,52 @@
.PHONY: help generate-recipes validate-recipes clean clean-dishes install-deps flatten-dishes all
.PHONY: help generate lint validate inventory test install-deps clean clean-recipes clean-dishes all
PYTHON ?= python3
default: all
help:
@echo "Phyllome OS Recipe Generator"
@echo ""
@echo "Available targets:"
@echo " generate-recipes - Generate all recipes from manifest"
@echo " validate-recipes - Validate existing recipes"
@echo " all - Generate, validate, and flatten all recipes (default)"
@echo " flatten-dishes - Flatten all recipes to dishes"
@echo " clean-dishes - Remove flattened dishes"
@echo " clean-recipes - Remove generated recipes"
@echo " clean-all - Remove recipes and dishes"
@echo " install-deps - Install Python dependencies"
@echo " all - Generate recipes and dishes, lint, and validate (default)"
@echo " generate - Same as 'all'"
@echo " lint - Lint manifest and templates without writing files"
@echo " validate - Validate existing dishes without regenerating"
@echo " inventory - Print the ingredient inventory derived from recipe_templates.yaml"
@echo " test - Run the pytest test suite"
@echo " install-deps - Install Python dependencies"
@echo " clean - Remove generated recipes and dishes"
@echo " clean-recipes- Remove generated recipes only"
@echo " clean-dishes - Remove generated dishes only"
all: generate-recipes flatten-dishes validate-recipes
@echo "✓ All recipes generated, flattened, and validated"
all: generate
generate:
@$(PYTHON) generate_recipe.py
lint:
@$(PYTHON) generate_recipe.py --no-generate --no-validate
validate:
@$(PYTHON) generate_recipe.py --no-generate --no-lint
inventory:
@$(PYTHON) generate_recipe.py --inventory
test:
@$(PYTHON) -m pytest tests
install-deps:
pip install -r requirements.txt
@pip install -r requirements.txt
generate-recipes:
@rm -f recipes/*.cfg
@python3 generate_recipe.py \
--manifest recipes_manifest.yaml \
--output-dir recipes/
validate-recipes:
@echo "Validating recipes..."
@for f in dishes/*.cfg; do \
if [ -f "$$f" ]; then \
echo " Processing: $$(basename $$f)"; \
ksflatten -c "$$f" -o /dev/null 2>&1 && echo " ✓ OK" || { echo " ✗ FAILED"; exit 1; }; \
fi; \
done
flatten-dishes:
@echo "Flattening recipes to dishes..."
@python bin/ksflatten-relative recipes dishes
clean-dishes:
rm -f dishes/*.cfg
@echo "✓ Flattened dishes removed. Run 'make flatten-dishes' to regenerate."
clean:
@rm -f recipes/*.cfg dishes/*.cfg
@echo "Generated recipes and dishes removed. Run 'make all' to regenerate."
clean-recipes:
rm -f recipes/*.cfg
@echo "Generated recipes removed. Edit recipes_manifest.yaml and run 'make generate-recipes' to regenerate. Run 'make clean-dishes' to remove flattened dishes."
@rm -f recipes/*.cfg
@echo "Generated recipes removed. Run 'make generate' to regenerate."
clean-all:
rm -f dishes/*.cfg
rm -f recipes/*.cfg
@echo "✓ Flattened dishes and generated recipes removed. Run 'make all' to regenerate."
clean-dishes:
@rm -f dishes/*.cfg
@echo "Generated dishes removed. Run 'make generate' to regenerate."