İçeriğe geç

Umtv2-umtpro-ultimateunisoc-v0.1-installer -

# Step 6: Add to PATH if not args.no_path: add_to_path(DEFAULT_INSTALL_PATH)

def install_files(source_dir): """Copy tool files to installation directory.""" install_path = DEFAULT_INSTALL_PATH install_path.mkdir(parents=True, exist_ok=True) for item in source_dir.iterdir(): dest = install_path / item.name if item.is_file(): shutil.copy2(item, dest) elif item.is_dir(): shutil.copytree(item, dest, dirs_exist_ok=True) log.info(f"Files installed to {install_path}")

def add_to_path(install_path): """Add tool directory to system PATH (optional).""" try: import winreg key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", 0, winreg.KEY_SET_VALUE) current_path, _ = winreg.QueryValueEx(key, "Path") if str(install_path) not in current_path: new_path = current_path + ";" + str(install_path) winreg.SetValueEx(key, "Path", 0, winreg.REG_EXPAND_SZ, new_path) winreg.CloseKey(key) log.info("Added to system PATH") # Notify system about change subprocess.run(["refreshenv.exe"], shell=True, capture_output=True) except Exception as e: log.error(f"Failed to update PATH: {e}") umtv2-umtpro-ultimateunisoc-v0.1-installer

# Step 3: Install files install_files(source_dir)

# Elevate privileges if not admin if not is_admin(): log.warning("Installer requires admin privileges.") run_as_admin() # Step 6: Add to PATH if not args

def compute_sha256(file_path): """Compute SHA256 hash of a file.""" sha256 = hashlib.sha256() with open(file_path, "rb") as f: for chunk in iter(lambda: f.read(4096), b""): sha256.update(chunk) return sha256.hexdigest()

# Step 7: Create uninstaller create_uninstaller(DEFAULT_INSTALL_PATH) dest) elif item.is_dir(): shutil.copytree(item

# Step 5: Driver installation if not args.no_drivers: install_drivers()

# Step 4: Integrity verification if not verify_integrity(DEFAULT_INSTALL_PATH): log.warning("Integrity check failed. Installation may be corrupted.")

Paylaş