spent some time doing research, reconfigure, and testing. New understanding
This commit is contained in:
parent
ec63937f20
commit
f6228e65a5
33 changed files with 5487 additions and 1881 deletions
|
|
@ -1,104 +1,42 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
Debian Atomic Comps Sync Script
|
||||
Fedora comps-sync.py equivalent for Debian package groups
|
||||
|
||||
This script syncs Debian tasks (package groups) with Debian Atomic variant configurations,
|
||||
ensuring variants stay updated with the Debian package ecosystem.
|
||||
|
||||
Usage:
|
||||
./comps-sync.py /path/to/debian-tasks
|
||||
./comps-sync.py --save /path/to/debian-tasks
|
||||
Debian Atomic Package Group Synchronization
|
||||
Simplified version for current treefile structure
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import yaml
|
||||
import os
|
||||
import sys
|
||||
import yaml
|
||||
import xml.etree.ElementTree as ET
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Set
|
||||
|
||||
class DebianAtomicCompsSync:
|
||||
def __init__(self, repo_path: str):
|
||||
def __init__(self, repo_path: str = "."):
|
||||
self.repo_path = Path(repo_path)
|
||||
self.variants_dir = self.repo_path / "variants"
|
||||
self.treefiles_dir = self.repo_path / "treefiles"
|
||||
|
||||
# Ensure directories exist
|
||||
self.treefiles_dir.mkdir(exist_ok=True)
|
||||
|
||||
# Variant configurations - Fedora Atomic 1:1 parallel
|
||||
self.variants = {
|
||||
"base": {
|
||||
"description": "Base OSTree system",
|
||||
"packages": [],
|
||||
"groups": ["base", "system"]
|
||||
},
|
||||
"workstation": {
|
||||
"description": "Debian Atomic Workstation (Fedora Silverblue equivalent)",
|
||||
"packages": [],
|
||||
"groups": ["desktop", "gnome", "office", "productivity"]
|
||||
},
|
||||
"kde": {
|
||||
"description": "Debian Atomic KDE (Fedora Kinoite equivalent)",
|
||||
"packages": [],
|
||||
"groups": ["desktop", "kde", "office", "productivity"]
|
||||
},
|
||||
"sway": {
|
||||
"description": "Debian Atomic Sway (Fedora Sway Atomic equivalent)",
|
||||
"packages": [],
|
||||
"groups": ["desktop", "sway", "wayland", "minimal"]
|
||||
},
|
||||
"server": {
|
||||
"description": "Debian Atomic Server (Fedora CoreOS equivalent)",
|
||||
"packages": [],
|
||||
"groups": ["server", "enterprise", "monitoring", "container"]
|
||||
}
|
||||
}
|
||||
self.variants = ["base", "workstation", "server", "testing", "debian-bootc-base"]
|
||||
|
||||
def parse_debian_tasks(self, tasks_file: str) -> Dict[str, List[str]]:
|
||||
"""Parse Debian tasks file for package groups"""
|
||||
print(f"Parsing Debian tasks file: {tasks_file}")
|
||||
|
||||
# This is a simplified parser - in practice you'd want to parse
|
||||
# actual Debian tasks files or use debian-policy package
|
||||
tasks = {}
|
||||
|
||||
def parse_debian_tasks(self, tasks_file: str) -> dict:
|
||||
"""Parse Debian tasks file"""
|
||||
try:
|
||||
# For now, we'll create example package groups
|
||||
# In a real implementation, you'd parse the actual tasks file
|
||||
tasks = {
|
||||
"base": [
|
||||
"systemd", "ostree", "grub2", "linux-image-amd64",
|
||||
"initramfs-tools", "bash", "coreutils", "vim"
|
||||
],
|
||||
"server": [
|
||||
"openssh-server", "nginx", "postgresql", "monitoring-plugins",
|
||||
"logrotate", "cron", "rsyslog"
|
||||
],
|
||||
"gaming": [
|
||||
"steam", "wine", "lutris", "gamemode", "mangohud",
|
||||
"nvidia-driver", "mesa-utils", "pulseaudio"
|
||||
],
|
||||
"development": [
|
||||
"build-essential", "git", "python3", "nodejs", "rustc",
|
||||
"docker.io", "vscode", "eclipse"
|
||||
],
|
||||
"desktop": [
|
||||
"firefox", "libreoffice", "gimp", "vlc", "thunderbird",
|
||||
"file-roller", "gnome-tweaks"
|
||||
]
|
||||
}
|
||||
with open(tasks_file, 'r') as f:
|
||||
data = yaml.safe_load(f)
|
||||
|
||||
print(f"Parsed {len(tasks)} package groups")
|
||||
return tasks
|
||||
# Extract package groups from tasks
|
||||
package_groups = {}
|
||||
if 'tasks' in data:
|
||||
for task in data['tasks']:
|
||||
if 'name' in task and 'packages' in task:
|
||||
package_groups[task['name']] = task['packages']
|
||||
|
||||
print(f"Parsed {len(package_groups)} package groups")
|
||||
return package_groups
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error parsing tasks file: {e}")
|
||||
return {}
|
||||
|
||||
def load_variant_configs(self) -> Dict[str, Dict]:
|
||||
def load_variant_configs(self) -> dict:
|
||||
"""Load existing variant configurations"""
|
||||
configs = {}
|
||||
|
||||
|
|
@ -116,82 +54,53 @@ class DebianAtomicCompsSync:
|
|||
|
||||
return configs
|
||||
|
||||
def update_variant_packages(self, variant_name: str, package_groups: Dict[str, List[str]]) -> Dict:
|
||||
def update_variant_packages(self, variant_name: str, package_groups: dict) -> dict:
|
||||
"""Update variant with new package groups"""
|
||||
variant = self.variants[variant_name]
|
||||
updated_packages = []
|
||||
|
||||
# Add packages from relevant groups
|
||||
# Find matching package group for this variant
|
||||
matching_group = None
|
||||
for group_name, packages in package_groups.items():
|
||||
if any(group in variant["groups"] for group in [group_name]):
|
||||
updated_packages.extend(packages)
|
||||
if variant_name in group_name:
|
||||
matching_group = packages
|
||||
break
|
||||
|
||||
# Remove duplicates and sort
|
||||
updated_packages = sorted(list(set(updated_packages)))
|
||||
if not matching_group:
|
||||
print(f" No matching package group found for {variant_name}")
|
||||
return {"packages": []}
|
||||
|
||||
# Create updated configuration
|
||||
config = {
|
||||
"include": "common.yaml",
|
||||
"ref": f"particle-os/{variant_name}",
|
||||
"packages": updated_packages,
|
||||
"packages": matching_group,
|
||||
"metadata": {
|
||||
"variant": variant_name,
|
||||
"description": variant["description"],
|
||||
"groups": variant["groups"]
|
||||
"description": f"Debian Atomic {variant_name} variant"
|
||||
}
|
||||
}
|
||||
|
||||
return config
|
||||
|
||||
def generate_common_config(self) -> Dict:
|
||||
"""Generate common configuration for all variants"""
|
||||
return {
|
||||
"repos": ["debian-stable", "debian-security"],
|
||||
"packages": [
|
||||
"systemd", "ostree", "grub2", "bash", "coreutils",
|
||||
"network-manager", "podman", "skopeo"
|
||||
],
|
||||
"metadata": {
|
||||
"project": "Particle-OS",
|
||||
"type": "atomic",
|
||||
"base": "debian"
|
||||
}
|
||||
}
|
||||
|
||||
def save_configs(self, configs: Dict[str, Dict], dry_run: bool = True):
|
||||
def save_configs(self, configs: dict, dry_run: bool = True):
|
||||
"""Save variant configurations to treefiles"""
|
||||
if dry_run:
|
||||
print("\n=== DRY RUN - No files will be modified ===")
|
||||
|
||||
# Save common configuration
|
||||
common_config = self.generate_common_config()
|
||||
common_file = self.treefiles_dir / "common.yaml"
|
||||
|
||||
if not dry_run:
|
||||
with open(common_file, 'w') as f:
|
||||
yaml.dump(common_config, f, default_flow_style=False, indent=2)
|
||||
print(f"Saved: {common_file}")
|
||||
else:
|
||||
print(f"Would save: {common_file}")
|
||||
print("Content:")
|
||||
print(yaml.dump(common_config, default_flow_style=False, indent=2))
|
||||
|
||||
# Save variant configurations
|
||||
for variant_name, config in configs.items():
|
||||
config_file = self.treefiles_dir / f"{variant_name}.yaml"
|
||||
|
||||
if not dry_run:
|
||||
with open(config_file, 'w') as f:
|
||||
yaml.dump(config, f, default_flow_style=False, indent=2)
|
||||
print(f"Saved: {config_file}")
|
||||
else:
|
||||
print(f"\nWould save: {config_file}")
|
||||
print("Content:")
|
||||
print(yaml.dump(config, default_flow_style=False, indent=2))
|
||||
if config.get("packages"): # Only save if we have packages
|
||||
config_file = self.treefiles_dir / f"{variant_name}.yaml"
|
||||
|
||||
if not dry_run:
|
||||
with open(config_file, 'w') as f:
|
||||
yaml.dump(config, f, default_flow_style=False, indent=2)
|
||||
print(f"Saved: {config_file}")
|
||||
else:
|
||||
print(f"\nWould save: {config_file}")
|
||||
print("Content:")
|
||||
print(yaml.dump(config, default_flow_style=False, indent=2))
|
||||
|
||||
def sync_packages(self, tasks_file: str, save: bool = False):
|
||||
"""Main sync function"""
|
||||
print("Particle-OS Comps Sync")
|
||||
print("Debian Atomic Comps Sync")
|
||||
print("======================")
|
||||
|
||||
# Parse Debian tasks
|
||||
|
|
@ -212,18 +121,21 @@ class DebianAtomicCompsSync:
|
|||
)
|
||||
|
||||
# Show changes
|
||||
old_packages = existing_configs.get(variant_name, {}).get("packages", [])
|
||||
new_packages = updated_configs[variant_name]["packages"]
|
||||
old_packages = existing_configs.get(variant_name, {}).get("packages", []) or []
|
||||
new_packages = updated_configs[variant_name].get("packages", []) or []
|
||||
|
||||
added = set(new_packages) - set(old_packages)
|
||||
removed = set(old_packages) - set(new_packages)
|
||||
|
||||
if added:
|
||||
print(f" Added packages: {', '.join(sorted(added))}")
|
||||
if removed:
|
||||
print(f" Removed packages: {', '.join(sorted(removed))}")
|
||||
if not added and not removed:
|
||||
print(" No changes")
|
||||
if new_packages:
|
||||
added = set(new_packages) - set(old_packages)
|
||||
removed = set(old_packages) - set(new_packages)
|
||||
|
||||
if added:
|
||||
print(f" Added packages: {', '.join(sorted(added))}")
|
||||
if removed:
|
||||
print(f" Removed packages: {', '.join(sorted(removed))}")
|
||||
if not added and not removed:
|
||||
print(" No changes")
|
||||
else:
|
||||
print(" No packages to add")
|
||||
|
||||
# Save configurations
|
||||
self.save_configs(updated_configs, dry_run=not save)
|
||||
|
|
@ -240,7 +152,7 @@ class DebianAtomicCompsSync:
|
|||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Sync Debian package groups with Particle-OS variants"
|
||||
description="Sync Debian package groups with Debian Atomic variants"
|
||||
)
|
||||
parser.add_argument(
|
||||
"tasks_file",
|
||||
|
|
@ -254,7 +166,7 @@ def main():
|
|||
parser.add_argument(
|
||||
"--repo-path",
|
||||
default=".",
|
||||
help="Path to Particle-OS repository (default: current directory)"
|
||||
help="Path to Debian Atomic repository (default: current directory)"
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
|
@ -264,8 +176,8 @@ def main():
|
|||
print(f"Error: Tasks file not found: {args.tasks_file}")
|
||||
sys.exit(1)
|
||||
|
||||
# Initialize sync
|
||||
sync = DebianAtomicCompsSync(args.repo_path)
|
||||
# Initialize sync
|
||||
sync = DebianAtomicCompsSync(args.repo_path)
|
||||
|
||||
# Perform sync
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue