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
73 lines
2.3 KiB
Python
73 lines
2.3 KiB
Python
#!/usr/bin/python3
|
|
"""
|
|
Debian-Based Distribution Runner
|
|
Generic runner for Debian-based distributions
|
|
(Linux Mint, Pop!_OS, Elementary OS, etc.)
|
|
"""
|
|
|
|
import subprocess
|
|
import sys
|
|
import os
|
|
|
|
from osbuild import api
|
|
from osbuild.util import runners
|
|
|
|
def detect_distribution():
|
|
"""Detect the specific Debian-based distribution"""
|
|
distribution = "unknown"
|
|
version = "unknown"
|
|
|
|
# Try to detect distribution from various sources
|
|
if os.path.exists('/etc/os-release'):
|
|
with open('/etc/os-release', 'r') as f:
|
|
content = f.read()
|
|
if 'mint' in content.lower():
|
|
distribution = "linux-mint"
|
|
elif 'pop' in content.lower():
|
|
distribution = "pop-os"
|
|
elif 'elementary' in content.lower():
|
|
distribution = "elementary-os"
|
|
elif 'zorin' in content.lower():
|
|
distribution = "zorin-os"
|
|
elif 'kali' in content.lower():
|
|
distribution = "kali-linux"
|
|
elif 'parrot' in content.lower():
|
|
distribution = "parrot-os"
|
|
|
|
return distribution, version
|
|
|
|
def setup_debian_based_environment():
|
|
"""Setup environment for Debian-based distributions"""
|
|
# Set Debian-specific environment variables
|
|
os.environ['DEBIAN_FRONTEND'] = 'noninteractive'
|
|
os.environ['DEBCONF_NONINTERACTIVE_SEEN'] = 'true'
|
|
|
|
# Detect distribution
|
|
dist, version = detect_distribution()
|
|
os.environ['DEBIAN_BASED_DIST'] = dist
|
|
os.environ['DEBIAN_BASED_VERSION'] = version
|
|
|
|
print(f"🔄 Detected Debian-based distribution: {dist}")
|
|
|
|
# Ensure apt is properly configured
|
|
if os.path.exists('/etc/apt/sources.list'):
|
|
# Backup existing sources
|
|
if not os.path.exists('/etc/apt/sources.list.backup'):
|
|
subprocess.run(['cp', '/etc/apt/sources.list', '/etc/apt/sources.list.backup'], check=False)
|
|
|
|
# Update package lists
|
|
subprocess.run(['apt-get', 'update'], check=False)
|
|
|
|
if __name__ == "__main__":
|
|
with api.exception_handler():
|
|
# Debian-based distribution setup
|
|
setup_debian_based_environment()
|
|
|
|
# Standard runner operations
|
|
runners.ldconfig()
|
|
runners.sysusers()
|
|
runners.tmpfiles()
|
|
runners.nsswitch()
|
|
|
|
r = subprocess.run(sys.argv[1:], check=False)
|
|
sys.exit(r.returncode)
|