verify_package_integrity
Check if installed package files have been modified, missing, or corrupted. Use after system crashes or disk errors to verify package integrity on Arch Linux.
Instructions
[MAINTENANCE] Verify the integrity of installed package files. Detects modified, missing, or corrupted files. Only works on Arch Linux. When to use: After system crash or disk errors, verify 'linux' package files match expected checksums.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| package_name | Yes | Name of the package to verify | |
| thorough | No | Perform thorough check including file attributes. Default: false |
Implementation Reference
- src/arch_ops_server/pacman.py:1050-1111 (handler)The core implementation of verify_package_integrity. Runs `pacman -Qkk` (thorough) or `pacman -Qk` (standard) to verify installed package files, parses warnings/missing files, and returns results with issues count.
async def verify_package_integrity(package_name: str, thorough: bool = False) -> Dict[str, Any]: """ Verify integrity of an installed package. Args: package_name: Name of package to verify thorough: If True, perform thorough check (pacman -Qkk) Returns: Dict with verification results """ if not IS_ARCH: return create_error_response( "NotSupported", "Package verification is only available on Arch Linux" ) if not check_command_exists("pacman"): return create_error_response( "CommandNotFound", "pacman command not found" ) logger.info(f"Verifying package integrity: {package_name} (thorough={thorough})") try: cmd = ["pacman", "-Qkk" if thorough else "-Qk", package_name] exit_code, stdout, stderr = await run_command( cmd, timeout=30, check=False ) if exit_code != 0 and "was not found" in stderr: return create_error_response( "NotFound", f"Package not installed: {package_name}" ) # Parse verification output issues = [] for line in stdout.strip().split('\n'): if "warning" in line.lower() or "missing" in line.lower(): issues.append(line.strip()) logger.info(f"Found {len(issues)} issues for {package_name}") return { "package": package_name, "thorough": thorough, "issues_found": len(issues), "issues": issues, "all_ok": len(issues) == 0 } except Exception as e: logger.error(f"Package verification failed: {e}") return create_error_response( "CommandError", f"Failed to verify package: {str(e)}" ) - Tool registration with input schema (package_name required, thorough optional) and description for the verify_package_integrity tool.
Tool( name="verify_package_integrity", description="[MAINTENANCE] Verify the integrity of installed package files. Detects modified, missing, or corrupted files. Only works on Arch Linux. When to use: After system crash or disk errors, verify 'linux' package files match expected checksums.", inputSchema={ "type": "object", "properties": { "package_name": { "type": "string", "description": "Name of the package to verify" }, "thorough": { "type": "boolean", "description": "Perform thorough check including file attributes. Default: false", "default": False } }, "required": ["package_name"] }, annotations=ToolAnnotations(readOnlyHint=True) ), - src/arch_ops_server/server.py:1177-1184 (registration)The call_tool dispatcher that routes 'verify_package_integrity' invocations to the actual handler function, including platform check for Arch Linux.
elif name == "verify_package_integrity": if not IS_ARCH: return [TextContent(type="text", text=create_platform_error_message("verify_package_integrity"))] package_name = arguments["package_name"] thorough = arguments.get("thorough", False) result = await verify_package_integrity(package_name, thorough) return [TextContent(type="text", text=json.dumps(result, indent=2))] - src/arch_ops_server/__init__.py:22-41 (registration)Import of verify_package_integrity from pacman module into the package namespace.
from .pacman import ( get_official_package_info, check_updates_dry_run, remove_package, remove_packages_batch, remove_packages, list_orphan_packages, remove_orphans, manage_orphans, find_package_owner, list_package_files, search_package_files, query_file_ownership, verify_package_integrity, list_explicit_packages, mark_as_explicit, mark_as_dependency, manage_install_reason, check_database_freshness, ) - ToolMetadata definition for verify_package_integrity (category: maintenance, platform: arch, permission: read, workflow: verify) with related tools.
"verify_package_integrity": ToolMetadata( name="verify_package_integrity", category="maintenance", platform="arch", permission="read", workflow="verify", related_tools=["query_package_history", "query_file_ownership"], prerequisite_tools=[] ),