Files
phyllomeos/cook/python-update-package-names.py
T
Lukas Greve 3ffb079981 refactor: Move recipe generator to cook/ directory and fix flattening bugs
- Move recipe-generator/ to cook/ for cleaner structure

- Fix ksflatten-relative path conversion to handle all %include paths

- Fix validation exit code to only fail on actual errors

- All recipes now generate and flatten successfully via make all
2026-03-27 14:02:59 +01:00

43 lines
1.5 KiB
Python

import subprocess
import re
# Get all package names from your config file
packages = []
with open('core-packages-hardware-support.cfg', 'r') as f:
for line in f:
if line.strip() and not line.startswith('#') and '#' not in line:
# Extract package name (everything before the first space or #)
package = line.strip().split('#')[0].strip()
if package and not package.startswith('%'):
packages.append(package)
# Get summaries using dnf info
summaries = {}
for package in packages:
try:
result = subprocess.run(['dnf', 'info', package],
capture_output=True, text=True, timeout=30)
if result.returncode == 0:
# Extract summary line
summary_match = re.search(r'Summary\s*:\s*(.+)', result.stdout)
if summary_match:
summaries[package] = summary_match.group(1).strip()
except Exception as e:
print(f"Error getting info for {package}: {e}")
# Now you can generate your updated package list with summaries
with open('core-packages-hardware-support.cfg', 'r') as f:
lines = f.readlines()
new_lines = []
for line in lines:
if line.strip() and not line.startswith('#') and not line.startswith('%'):
package = line.strip().split('#')[0].strip()
if package in summaries:
line = f"{package} # {summaries[package]}\n"
new_lines.append(line)
# Write back to file (or save as new file)
with open('updated-packages.cfg', 'w') as f:
f.writelines(new_lines)