Add dynamic Debian version detection system (Fedora-style)
Some checks are pending
Checks / Spelling (push) Waiting to run
Checks / Python Linters (push) Waiting to run
Checks / Shell Linters (push) Waiting to run
Checks / 📦 Packit config lint (push) Waiting to run
Checks / 🔍 Check for valid snapshot urls (push) Waiting to run
Checks / 🔍 Check JSON files for formatting consistency (push) Waiting to run
Generate / Documentation (push) Waiting to run
Generate / Test Data (push) Waiting to run
Tests / Unittest (push) Waiting to run
Tests / Assembler test (legacy) (push) Waiting to run
Tests / Smoke run: unittest as normal user on default runner (push) Waiting to run
Some checks are pending
Checks / Spelling (push) Waiting to run
Checks / Python Linters (push) Waiting to run
Checks / Shell Linters (push) Waiting to run
Checks / 📦 Packit config lint (push) Waiting to run
Checks / 🔍 Check for valid snapshot urls (push) Waiting to run
Checks / 🔍 Check JSON files for formatting consistency (push) Waiting to run
Generate / Documentation (push) Waiting to run
Generate / Test Data (push) Waiting to run
Tests / Unittest (push) Waiting to run
Tests / Assembler test (legacy) (push) Waiting to run
Tests / Smoke run: unittest as normal user on default runner (push) Waiting to run
This commit is contained in:
parent
0e9754eec1
commit
f93e3a447c
4 changed files with 420 additions and 1 deletions
|
|
@ -9,6 +9,28 @@ import configparser
|
|||
from pathlib import Path
|
||||
from typing import Optional, Dict, Any
|
||||
|
||||
# Import version detector
|
||||
try:
|
||||
from .version_detector import (
|
||||
get_recommended_suite as _get_recommended_suite,
|
||||
get_mirror_url as _get_mirror_url,
|
||||
is_version_supported as _is_version_supported,
|
||||
print_version_info as _print_version_info
|
||||
)
|
||||
except ImportError:
|
||||
# Fallback if version detector is not available
|
||||
def _get_recommended_suite():
|
||||
return "trixie"
|
||||
|
||||
def _get_mirror_url():
|
||||
return "http://deb.debian.org/debian"
|
||||
|
||||
def _is_version_supported():
|
||||
return True
|
||||
|
||||
def _print_version_info():
|
||||
print("Version detector not available")
|
||||
|
||||
|
||||
class DebianForgeConfig:
|
||||
"""Configuration manager for Debian Forge settings"""
|
||||
|
|
@ -17,6 +39,7 @@ class DebianForgeConfig:
|
|||
self.config_dir = Path(config_dir)
|
||||
self.config = configparser.ConfigParser()
|
||||
self._load_config()
|
||||
self._apply_version_detection()
|
||||
|
||||
def _load_config(self):
|
||||
"""Load configuration from multiple sources with priority order"""
|
||||
|
|
@ -60,6 +83,26 @@ class DebianForgeConfig:
|
|||
self.config.add_section("build")
|
||||
self.config["build"]["default_arch"] = env_arch
|
||||
|
||||
def _apply_version_detection(self):
|
||||
"""Apply automatic version detection like Fedora does"""
|
||||
# Check if version detection is available
|
||||
if not _is_version_supported():
|
||||
print("⚠️ Warning: Current Debian version is not officially supported")
|
||||
print(" Debian Forge supports Debian 13+ (Trixie and newer)")
|
||||
print(" Consider upgrading or using a supported version")
|
||||
|
||||
# Auto-detect recommended suite if not explicitly set
|
||||
try:
|
||||
current_suite = self.get_build_setting("default_suite")
|
||||
if not current_suite or current_suite == "bookworm": # Legacy default
|
||||
recommended_suite = _get_recommended_suite()
|
||||
if "build" not in self.config:
|
||||
self.config.add_section("build")
|
||||
self.config["build"]["default_suite"] = recommended_suite
|
||||
print(f"🔄 Auto-detected recommended suite: {recommended_suite}")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def get_apt_proxy(self) -> Optional[str]:
|
||||
"""Get apt-cacher-ng proxy URL if configured"""
|
||||
try:
|
||||
|
|
@ -93,6 +136,18 @@ class DebianForgeConfig:
|
|||
"""Check if apt-cacher-ng proxy is enabled"""
|
||||
return self.get_apt_proxy() is not None
|
||||
|
||||
def get_recommended_suite(self) -> str:
|
||||
"""Get the recommended Debian suite for this system"""
|
||||
return _get_recommended_suite()
|
||||
|
||||
def get_mirror_url(self) -> str:
|
||||
"""Get appropriate Debian mirror URL"""
|
||||
return _get_mirror_url()
|
||||
|
||||
def is_version_supported(self) -> bool:
|
||||
"""Check if current Debian version is supported"""
|
||||
return _is_version_supported()
|
||||
|
||||
def get_all_settings(self) -> Dict[str, Dict[str, Any]]:
|
||||
"""Get all configuration settings as a dictionary"""
|
||||
result = {}
|
||||
|
|
@ -104,6 +159,12 @@ class DebianForgeConfig:
|
|||
"""Print current configuration for debugging"""
|
||||
print("Debian Forge Configuration:")
|
||||
print("=" * 40)
|
||||
|
||||
# Show version detection info
|
||||
_print_version_info()
|
||||
print()
|
||||
|
||||
# Show configuration settings
|
||||
for section, settings in self.get_all_settings().items():
|
||||
print(f"\n[{section}]")
|
||||
for key, value in settings.items():
|
||||
|
|
@ -114,6 +175,12 @@ class DebianForgeConfig:
|
|||
if env_proxy:
|
||||
print(f"\nEnvironment Override:")
|
||||
print(f" DEBIAN_FORGE_APT_PROXY = {env_proxy}")
|
||||
|
||||
# Show auto-detected values
|
||||
print(f"\nAuto-detected:")
|
||||
print(f" Recommended suite = {self.get_recommended_suite()}")
|
||||
print(f" Mirror URL = {self.get_mirror_url()}")
|
||||
print(f" Version supported = {self.is_version_supported()}")
|
||||
|
||||
|
||||
# Global configuration instance
|
||||
|
|
@ -138,3 +205,18 @@ def get_build_setting(key: str, default: Any = None) -> Any:
|
|||
def get_stage_setting(key: str, default: Any = None) -> Any:
|
||||
"""Get a stage setting (convenience function)"""
|
||||
return config.get_stage_setting(key, default)
|
||||
|
||||
|
||||
def get_recommended_suite() -> str:
|
||||
"""Get recommended Debian suite (convenience function)"""
|
||||
return config.get_recommended_suite()
|
||||
|
||||
|
||||
def get_mirror_url() -> str:
|
||||
"""Get appropriate Debian mirror URL (convenience function)"""
|
||||
return config.get_mirror_url()
|
||||
|
||||
|
||||
def is_version_supported() -> bool:
|
||||
"""Check if current Debian version is supported (convenience function)"""
|
||||
return config.is_version_supported()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue