check_updates_dry_run
Check for available system updates on Arch Linux without applying them. Perform a safe read-only operation to view pending updates before installation.
Instructions
[LIFECYCLE] Check for available system updates without applying them. Only works on Arch Linux systems. Requires pacman-contrib package. Safe read-only operation that shows pending updates.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/arch_ops_server/pacman.py:218-290 (handler)Main handler function that runs 'checkupdates' command, parses output, and returns structured update information or error response.async def check_updates_dry_run() -> Dict[str, Any]: """ Check for available system updates without applying them. Only works on Arch Linux systems with checkupdates command. Requires pacman-contrib package. Returns: Dict with list of available updates or error response """ logger.info("Checking for system updates (dry run)") # Only supported on Arch Linux if not IS_ARCH: return create_error_response( "NotSupported", "Update checking is only supported on Arch Linux systems", "This server is not running on Arch Linux" ) # Check if checkupdates command exists if not check_command_exists("checkupdates"): return create_error_response( "CommandNotFound", "checkupdates command not found", "Install pacman-contrib package: pacman -S pacman-contrib" ) try: exit_code, stdout, stderr = await run_command( ["checkupdates"], timeout=30, # Can take longer for sync check=False ) # Exit code 0: updates available # Exit code 2: no updates available # Other: error if exit_code == 2 or not stdout.strip(): logger.info("No updates available") return { "updates_available": False, "count": 0, "packages": [] } if exit_code != 0: logger.error(f"checkupdates failed with code {exit_code}: {stderr}") return create_error_response( "CommandError", f"checkupdates command failed: {stderr}", f"Exit code: {exit_code}" ) # Parse checkupdates output updates = _parse_checkupdates_output(stdout) logger.info(f"Found {len(updates)} available updates") return { "updates_available": True, "count": len(updates), "packages": updates } except Exception as e: logger.error(f"Update check failed: {e}") return create_error_response( "UpdateCheckError", f"Failed to check for updates: {str(e)}" )
- Tool schema definition in list_tools(): no input parameters required, provides description.name="check_updates_dry_run", description="[LIFECYCLE] Check for available system updates without applying them. Only works on Arch Linux systems. Requires pacman-contrib package. Safe read-only operation that shows pending updates.", inputSchema={ "type": "object", "properties": {} } ),
- src/arch_ops_server/server.py:1194-1199 (registration)Registration and dispatch logic in call_tool(): calls the handler when tool name matches.elif name == "check_updates_dry_run": if not IS_ARCH: return [TextContent(type="text", text="Error: check_updates_dry_run only available on Arch Linux systems")] result = await check_updates_dry_run() return [TextContent(type="text", text=json.dumps(result, indent=2))]
- Helper function to parse the output from 'checkupdates' command into structured list of updates.def _parse_checkupdates_output(output: str) -> List[Dict[str, str]]: """ Parse checkupdates command output. Format: "package current_version -> new_version" Args: output: Raw checkupdates output Returns: List of update dicts """ updates = [] for line in output.strip().split('\n'): if not line.strip(): continue # Match pattern: "package old_ver -> new_ver" match = re.match(r'^(\S+)\s+(\S+)\s+->\s+(\S+)$', line) if match: updates.append({ "package": match.group(1), "current_version": match.group(2), "new_version": match.group(3) }) return updates
- src/arch_ops_server/server.py:39-52 (registration)Import statement in server.py that brings the handler into scope for registration.check_updates_dry_run, remove_package, remove_packages_batch, list_orphan_packages, remove_orphans, find_package_owner, list_package_files, search_package_files, verify_package_integrity, list_package_groups, list_group_packages, list_explicit_packages, mark_as_explicit, mark_as_dependency,