File size: 2,744 Bytes
7a0c684 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
"""
QEMU Installation Helper Script
This script helps install QEMU and its Python dependencies
"""
import subprocess
import sys
import os
import platform
from pathlib import Path
def check_qemu_installation():
"""Check if QEMU is installed"""
try:
result = subprocess.run(['qemu-system-x86_64', '--version'],
capture_output=True, text=True)
if result.returncode == 0:
print(f"QEMU is installed: {result.stdout.split()[3]}")
return True
except FileNotFoundError:
return False
return False
def install_qemu_windows():
"""Install QEMU on Windows"""
print("Please install QEMU manually on Windows:")
print("1. Download QEMU installer from https://qemu.weilnetz.de/w64/")
print("2. Run the installer")
print("3. Add QEMU to your PATH")
print("\nAfter installation, run this script again to verify the installation")
def install_qemu_linux():
"""Install QEMU on Linux"""
try:
subprocess.run(['sudo', 'apt-get', 'update'], check=True)
subprocess.run(['sudo', 'apt-get', 'install', '-y',
'qemu-system-x86',
'qemu-utils',
'qemu-system-common',
'libvirt-dev'], check=True)
except subprocess.CalledProcessError as e:
print(f"Error installing QEMU: {e}")
sys.exit(1)
def install_python_dependencies():
"""Install Python dependencies"""
requirements_path = Path(__file__).parent / 'requirements.txt'
try:
subprocess.run([sys.executable, '-m', 'pip', 'install', '-r',
str(requirements_path)], check=True)
print("Python dependencies installed successfully")
except subprocess.CalledProcessError as e:
print(f"Error installing Python dependencies: {e}")
sys.exit(1)
def main():
"""Main installation function"""
system = platform.system().lower()
print("Checking QEMU installation...")
if not check_qemu_installation():
print("QEMU is not installed")
if system == 'windows':
install_qemu_windows()
elif system == 'linux':
install_qemu_linux()
else:
print(f"Unsupported system: {system}")
sys.exit(1)
print("\nInstalling Python dependencies...")
install_python_dependencies()
print("\nVerifying installation...")
if check_qemu_installation():
print("QEMU installation verified successfully")
else:
print("QEMU installation verification failed")
sys.exit(1)
if __name__ == '__main__':
main()
|