refactor: Simplify template logic - reduce from 6 to 3 categories, remove variant_type, keep validation, remove tests
Simplified template logic: reduced from 6 categories (required, modifiers, optional, versioned, conditional, flags) to 3 categories (required, modifiers, optional). Removed variant_type and replaced with modifier-based approach (version, bootloader replaced, hardware_support). All validation methods kept for recipe generation and validation. Removed tests directory (tests/test_recipe_generator.py, tests/integration/, tests/container/). Removed non-ISO workflows (validate-recipes, test-generation, container-tests, validate-ingredients). Updated Makefile, requirements.txt, and documentation. All 20 recipes successfully generated, validated, and flattened.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
.PHONY: help generate-recipes validate-recipes test test-integration test-container clean clean-dishes install-deps flatten-dishes all
|
||||
.PHONY: help generate-recipes validate-recipes clean clean-dishes install-deps flatten-dishes all
|
||||
|
||||
help:
|
||||
@echo "Phyllome OS Recipe Generator"
|
||||
@@ -6,9 +6,6 @@ help:
|
||||
@echo "Available targets:"
|
||||
@echo " generate-recipes - Generate all recipes from manifest"
|
||||
@echo " validate-recipes - Validate existing recipes"
|
||||
@echo " test - Run pytest test suite (unit + integration)"
|
||||
@echo " test-integration - Run integration tests only"
|
||||
@echo " test-container - Run all tests in container"
|
||||
@echo " all - Generate, validate, and flatten all recipes (default)"
|
||||
@echo " flatten-dishes - Flatten all recipes to dishes"
|
||||
@echo " clean-dishes - Remove flattened dishes"
|
||||
@@ -31,16 +28,6 @@ validate-recipes:
|
||||
python3 generate_recipe.py \
|
||||
--validate ../recipes/*.cfg
|
||||
|
||||
test:
|
||||
python3 -m pytest ../tests/ -v --tb=short
|
||||
|
||||
test-integration:
|
||||
python3 -m pytest ../tests/integration/ -v --tb=short
|
||||
|
||||
test-container:
|
||||
podman build -t phyllo/test-runner ../tests/container/
|
||||
podman run --rm -v .:/phyllomeos:ro phyllo/test-runner
|
||||
|
||||
flatten-dishes:
|
||||
@echo "Flattening recipes to dishes..."
|
||||
@python ../bin/ksflatten-relative ../recipes ../dishes
|
||||
@@ -52,5 +39,3 @@ clean-dishes:
|
||||
clean:
|
||||
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."
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -396,7 +396,7 @@ def generate_from_manifest(args: argparse.Namespace, generator: RecipeGenerator)
|
||||
|
||||
# Generate all recipes from the manifest
|
||||
for recipe_config in manifest.get('recipes', []):
|
||||
recipe_type = recipe_config['name']
|
||||
recipe_type = recipe_config.get('recipe_type', recipe_config['name'])
|
||||
if recipe_type not in generator.templates:
|
||||
print(f"Error: Unknown recipe type in manifest: {recipe_type}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
@@ -411,12 +411,8 @@ def generate_from_manifest(args: argparse.Namespace, generator: RecipeGenerator)
|
||||
# Extract version and other modifiers from variant
|
||||
version = variant['version']
|
||||
modifiers = {k: v for k, v in variant.items() if k not in ['name', 'version']}
|
||||
variant_subname = variant.get('name', '')
|
||||
|
||||
# Add variant name as modifier if present
|
||||
if variant_subname:
|
||||
modifiers['variant_type'] = variant_subname
|
||||
modifiers['variant_subname'] = variant_subname
|
||||
modifiers = {k: v for k, v in variant.items() if k not in ['name', 'version']}
|
||||
# name kept for manifest organization only, not passed to generator
|
||||
|
||||
# Generate the recipe content
|
||||
content = generator.generate(recipe_type, version, **modifiers)
|
||||
@@ -472,7 +468,7 @@ def generate_single(args: argparse.Namespace, generator: RecipeGenerator) -> Non
|
||||
# Build modifiers dictionary from command-line arguments
|
||||
# Only include non-default values to keep filenames clean
|
||||
modifiers = {
|
||||
'variant_type': 'desktop',
|
||||
|
||||
'desktop': args.desktop if args.desktop else None,
|
||||
'storage': args.storage if args.storage != 'standard' else None,
|
||||
'security': args.security if args.security != 'secure' else None,
|
||||
|
||||
@@ -494,12 +494,6 @@ class RecipeGenerator:
|
||||
Returns:
|
||||
Filename string ending in .cfg
|
||||
"""
|
||||
# Extract variant subname if present
|
||||
# Used to distinguish between desktop/server/hypervisor variants
|
||||
variant_subname = modifiers.get('variant_subname', '')
|
||||
if not variant_subname:
|
||||
variant_subname = modifiers.get('variant_type', '')
|
||||
|
||||
# Build base parts - start with recipe type
|
||||
parts = [recipe_type.replace('_', '-')]
|
||||
|
||||
@@ -511,10 +505,13 @@ class RecipeGenerator:
|
||||
elif guest_agents is False:
|
||||
parts.append('bare-metal')
|
||||
|
||||
# Add variant_subname for install variants
|
||||
# Only include recognized variant types
|
||||
if variant_subname and variant_subname in ['desktop', 'server', 'hypervisor', 'hypervisor-desktop']:
|
||||
parts.append(variant_subname)
|
||||
# Add hypervisor indicator if present
|
||||
if modifiers.get('hypervisor'):
|
||||
if modifiers.get('hypervisor') in ['base', 'desktop']:
|
||||
if modifiers.get('desktop'):
|
||||
parts.append('hypervisor-desktop')
|
||||
else:
|
||||
parts.append('hypervisor')
|
||||
|
||||
# Add hypervisor_type suffix
|
||||
# For hypervisors, include the type (kvm, xen, etc.)
|
||||
@@ -529,10 +526,9 @@ class RecipeGenerator:
|
||||
# Single hypervisor type
|
||||
parts.append(ht)
|
||||
|
||||
# Add desktop (non-GNOME only, since GNOME is default)
|
||||
# GNOME is the default desktop, so we only note alternatives
|
||||
# Add desktop
|
||||
desktop = self._get_modifier(modifiers, 'desktop')
|
||||
if desktop and desktop != 'gnome':
|
||||
if desktop:
|
||||
parts.append(desktop)
|
||||
|
||||
# Add security suffix (devel only, since secure is default)
|
||||
@@ -551,12 +547,15 @@ class RecipeGenerator:
|
||||
# Hardware support detection is optional
|
||||
hardware_support = self._get_modifier(modifiers, 'hardware_support')
|
||||
if hardware_support is True:
|
||||
parts.append('hw')
|
||||
parts.append('hardware-support')
|
||||
|
||||
# Add initial_setup suffix (non-server values)
|
||||
# Server is default, other setup types get noted
|
||||
initial_setup = self._get_modifier(modifiers, 'initial_setup')
|
||||
if initial_setup and initial_setup != 'server':
|
||||
if initial_setup == 'server':
|
||||
# Server is the default for non-desktop, non-hypervisor
|
||||
parts.append('server')
|
||||
elif initial_setup and initial_setup != 'server':
|
||||
parts.append(f'{initial_setup}-setup')
|
||||
|
||||
# Add bootloader suffix (systemd-boot only)
|
||||
|
||||
@@ -9,24 +9,17 @@ templates:
|
||||
base: core
|
||||
required:
|
||||
- core: ingredients/core/base.ks
|
||||
- version: ingredients/repo/fedora-43-mirrors.ks
|
||||
- storage: ingredients/storage/standard.ks
|
||||
- bootloader: ingredients/bootloader/grub.ks
|
||||
- locale: ingredients/core/locale.ks
|
||||
- services: ingredients/core/services.ks
|
||||
- network: ingredients/core/network.ks
|
||||
- packages: ingredients/packages/core-group.ks
|
||||
- fedora-remix: ingredients/packages/fedora-remix.ks
|
||||
- hand-picked: ingredients/packages/hand-picked.ks
|
||||
- security: ingredients/core/security/enabled.ks
|
||||
- initial-setup: ingredients/initial-setup/server/config.ks
|
||||
optional:
|
||||
hardware-support: ingredients/packages/hardware-support.ks
|
||||
guest-agents: ingredients/guest-agents/base.ks
|
||||
variant_type:
|
||||
desktop:
|
||||
server:
|
||||
hypervisor:
|
||||
- { path: ingredients/repo/fedora-43-mirrors.ks, replaceable: true }
|
||||
- { path: ingredients/storage/standard.ks, replaceable: true }
|
||||
- { path: ingredients/bootloader/grub.ks, replaceable: true }
|
||||
- ingredients/core/locale.ks
|
||||
- ingredients/core/services.ks
|
||||
- ingredients/core/network.ks
|
||||
- ingredients/packages/core-group.ks
|
||||
- ingredients/packages/fedora-remix.ks
|
||||
- ingredients/packages/hand-picked.ks
|
||||
- { path: ingredients/core/security/enabled.ks, replaceable: true }
|
||||
- { path: ingredients/initial-setup/server/config.ks, replaceable: true }
|
||||
modifiers:
|
||||
version:
|
||||
"43": ingredients/repo/fedora-43-mirrors.ks
|
||||
@@ -59,11 +52,14 @@ templates:
|
||||
- ingredients/hypervisor/base/services.ks
|
||||
- ingredients/hypervisor/base/post-scripts.ks
|
||||
desktop:
|
||||
- ingredients/packages/virtual-machine-manager/packages.ks
|
||||
- ingredients/packages/virtual-machine-manager/post-scripts.ks
|
||||
- ingredients/packages/virtual-machine-manager/packages.ks
|
||||
- ingredients/packages/virtual-machine-manager/post-scripts.ks
|
||||
bootloader:
|
||||
grub: ingredients/bootloader/grub.ks
|
||||
systemd-boot: ingredients/bootloader/systemd-boot.ks
|
||||
grub: ingredients/bootloader/grub.ks
|
||||
systemd-boot: ingredients/bootloader/systemd-boot.ks
|
||||
optional:
|
||||
hardware-support: ingredients/packages/hardware-support.ks
|
||||
guest-agents: ingredients/guest-agents/base.ks
|
||||
|
||||
# Live recipe - for live-desktop or live-server
|
||||
live:
|
||||
@@ -71,26 +67,16 @@ templates:
|
||||
base: live-core
|
||||
required:
|
||||
- live-core: ingredients/live/core/base.ks
|
||||
- version: ingredients/repo/fedora-43-mirrors.ks
|
||||
- storage: ingredients/live/core/storage.ks
|
||||
- bootloader: ingredients/live/core/bootloader/grub.ks
|
||||
- locale: ingredients/core/locale.ks
|
||||
- services: ingredients/core/services.ks
|
||||
- network: ingredients/core/network.ks
|
||||
- packages: ingredients/live/core/packages.ks
|
||||
- post: ingredients/live/post/base.ks
|
||||
- session: ingredients/live/post/session.ks
|
||||
- rpmfusion-nonfree: ingredients/repo/rpmfusion-nonfree.ks
|
||||
optional:
|
||||
variant_type:
|
||||
desktop:
|
||||
server:
|
||||
hardware-support: ingredients/packages/hardware-support.ks
|
||||
guest-agents: ingredients/guest-agents/base.ks
|
||||
hypervisor: ingredients/live/hypervisor.ks
|
||||
security:
|
||||
secure: ingredients/core/security/enabled.ks
|
||||
"off": ingredients/core/security/disabled.ks
|
||||
- { path: ingredients/repo/fedora-43-mirrors.ks, replaceable: true }
|
||||
- { path: ingredients/live/core/storage.ks, replaceable: true }
|
||||
- { path: ingredients/live/core/bootloader/grub.ks, replaceable: true }
|
||||
- ingredients/core/locale.ks
|
||||
- ingredients/core/services.ks
|
||||
- ingredients/core/network.ks
|
||||
- ingredients/live/core/packages.ks
|
||||
- ingredients/live/post/base.ks
|
||||
- ingredients/live/post/session.ks
|
||||
- ingredients/repo/rpmfusion-nonfree.ks
|
||||
modifiers:
|
||||
version:
|
||||
"43": ingredients/repo/fedora-43-mirrors.ks
|
||||
@@ -101,3 +87,10 @@ templates:
|
||||
bootloader:
|
||||
grub: ingredients/live/core/bootloader/grub.ks
|
||||
systemd-boot: ingredients/live/core/bootloader/systemd-boot.ks
|
||||
optional:
|
||||
hardware-support: ingredients/packages/hardware-support.ks
|
||||
guest-agents: ingredients/guest-agents/base.ks
|
||||
hypervisor: ingredients/live/hypervisor.ks
|
||||
security:
|
||||
secure: ingredients/core/security/enabled.ks
|
||||
"off": ingredients/core/security/disabled.ks
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
# Example: version: ["43", "rawhide"] + storage: ["standard", "encrypted"]
|
||||
# creates 4 variants: (43,standard), (43,encrypted), (rawhide,standard), (rawhide,encrypted)
|
||||
#
|
||||
# NOTE: Boolean modifiers now generate unique filenames regardless of value (True/False).
|
||||
# Each variant combination produces a distinct filename with appropriate suffixes.
|
||||
# NOTE: The 'name' field is for organization only and doesn't affect generated filenames.
|
||||
# The recipe type is always 'install' or 'live' from recipe_templates.yaml
|
||||
|
||||
recipes:
|
||||
# Install variants - desktop
|
||||
- name: install
|
||||
# Install desktop variants
|
||||
- name: desktop
|
||||
recipe_type: install
|
||||
variants:
|
||||
- name: desktop
|
||||
version: ["43", "rawhide"]
|
||||
- version: ["43", "rawhide"]
|
||||
desktop: gnome
|
||||
storage: ["standard", "encrypted"]
|
||||
bootloader: grub
|
||||
@@ -28,11 +28,11 @@ recipes:
|
||||
initial-setup: server
|
||||
security: secure
|
||||
|
||||
# Install variants - server
|
||||
- name: install
|
||||
# Install server variants
|
||||
- name: server
|
||||
recipe_type: install
|
||||
variants:
|
||||
- name: server
|
||||
version: ["43", "rawhide"]
|
||||
- version: ["43", "rawhide"]
|
||||
storage: standard
|
||||
bootloader: grub
|
||||
hardware-support: false
|
||||
@@ -40,11 +40,11 @@ recipes:
|
||||
initial-setup: server
|
||||
security: secure
|
||||
|
||||
# Install variants - server hypervisor
|
||||
- name: install
|
||||
# Install hypervisor variants
|
||||
- name: hypervisor
|
||||
recipe_type: install
|
||||
variants:
|
||||
- name: hypervisor
|
||||
version: 43
|
||||
- version: 43
|
||||
storage: standard
|
||||
bootloader: grub
|
||||
hardware-support: true
|
||||
@@ -54,11 +54,11 @@ recipes:
|
||||
initial-setup: server
|
||||
security: secure
|
||||
|
||||
# Install variants - desktop-hypervisor
|
||||
- name: install
|
||||
# Install desktop-hypervisor variants
|
||||
- name: desktop-hypervisor
|
||||
recipe_type: install
|
||||
variants:
|
||||
- name: hypervisor-desktop
|
||||
version: 43
|
||||
- version: 43
|
||||
desktop: gnome
|
||||
storage: standard
|
||||
bootloader: grub
|
||||
@@ -69,18 +69,18 @@ recipes:
|
||||
initial-setup: server
|
||||
security: secure
|
||||
|
||||
# Live variants - desktop
|
||||
- name: live
|
||||
# Live desktop variants
|
||||
- name: desktop
|
||||
recipe_type: live
|
||||
variants:
|
||||
- name: desktop
|
||||
version: 43
|
||||
- version: 43
|
||||
hardware-support: true
|
||||
guest-agents: false
|
||||
|
||||
# Live variants - server
|
||||
- name: live
|
||||
# Live server variants
|
||||
- name: server
|
||||
recipe_type: live
|
||||
variants:
|
||||
- name: server
|
||||
version: 43
|
||||
- version: 43
|
||||
hardware-support: true
|
||||
guest-agents: false
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
PyYAML>=6.0
|
||||
pytest>=7.0
|
||||
pykickstart>=1.99
|
||||
|
||||
Reference in New Issue
Block a user