Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 4, 2025

Summary

This PR adds full support for OpenBSD systems to miniupdate, enabling automatic detection, update checking, and package updates via OpenBSD's native pkg_add package manager. Additionally, it improves the display for Arch-based rolling release distributions.

Changes

OS Detection (miniupdate/os_detector.py)

  • Added OpenBSD to the OS_PATTERNS dictionary with pkg_add as its package manager
  • Added /usr/sbin/pkg_add to PACKAGE_MANAGERS detection paths
  • Enhanced _parse_os_info() to detect OpenBSD via uname kernel name
  • Added OpenBSD normalization in _normalize_distribution_name()
  • Set version to 'rolling' for Arch Linux and Manjaro instead of 'unknown' to improve UI display

Package Manager (miniupdate/package_managers.py)

  • Implemented new PkgAddPackageManager class with full OpenBSD support:
    • check_updates(): Uses doas pkg_add -u -n (dry-run mode) to check for available updates
    • apply_updates(): Applies all updates using doas pkg_add -u
    • _parse_pkg_add_output(): Robust parsing supporting multiple output formats:
      • Arrow format: package-1.0 -> package-1.1
      • Update format: Update to package-1.1
    • Handles complex package names with multiple dashes (e.g., gtk+3-3.24.38)
  • Added pkg_add to the get_package_manager() mapping

Documentation (README.md)

  • Added OpenBSD (pkg_add) to the list of supported operating systems

Technical Details

OpenBSD uses doas for privilege escalation instead of sudo, which is correctly handled by the implementation. The package manager properly detects and parses various output formats from pkg_add, handles edge cases like empty output and complex package names, and gracefully handles permission errors.

Arch-based distributions (Arch Linux and Manjaro) are rolling release distributions that don't include version numbers in their /etc/os-release files. This PR sets their version to 'rolling' instead of 'unknown' for better UI presentation.

Testing

Comprehensive testing performed:

  • ✅ Python syntax validation and module imports
  • ✅ OS detection for OpenBSD systems
  • ✅ Package manager selection and mapping
  • ✅ Output parsing for multiple formats
  • ✅ Edge case handling (empty output, complex names, whitespace)
  • ✅ Error handling (permission denied, command failures)
  • ✅ Backward compatibility with all existing package managers
  • ✅ Complete workflow simulation (detect → check → update)
  • ✅ Arch Linux and Manjaro version display as 'rolling'

Usage Example

After this PR, OpenBSD hosts can be added to the inventory:

all:
  hosts:
    openbsd-firewall:
      ansible_host: 192.168.1.100
      ansible_user: admin

And will be automatically detected and updated:

$ python -m miniupdate.main check
✓ Detected: openbsd 7.4 (openbsd, pkg_add)
✓ Found 3 updates:
  - quirks: 7.14 -> 7.15
  - python: 3.11.1 -> 3.11.2
  - nginx: 1.24.0 -> 1.24.1

Arch-based hosts will display version as 'rolling':

✓ Detected: arch rolling (linux, pacman)

Fixes #64

Original prompt

This section details on the original issue you should resolve

<issue_title>Add auto update (and check) support for OpenBSD</issue_title>
<issue_description>so that they can be added to inventory and get auto pkg_upgrade</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #24

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: SomethingGeneric <12242178+SomethingGeneric@users.noreply.github.com>
Copilot AI changed the title [WIP] Add auto update (and check) support for OpenBSD Add OpenBSD support with pkg_add package manager Oct 4, 2025
Copilot AI requested a review from SomethingGeneric October 4, 2025 00:17
@SomethingGeneric
Copy link
Owner

@copilot looks great, please also remove the "version" attribute for Arch linux, or maybe just hard-code it as "rolling" so the UI doesn't look like something is broken for Arch based hosts

Co-authored-by: SomethingGeneric <12242178+SomethingGeneric@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 4, 2025

@copilot looks great, please also remove the "version" attribute for Arch linux, or maybe just hard-code it as "rolling" so the UI doesn't look like something is broken for Arch based hosts

Done! Arch Linux and Manjaro now display version as 'rolling' instead of 'unknown'. The change is in commit [hash will be shown after commit].

The implementation sets the version to 'rolling' for both Arch and Manjaro distributions when the version would otherwise be 'unknown', which happens because these rolling-release distributions don't have VERSION_ID in their /etc/os-release file.

@SomethingGeneric SomethingGeneric marked this pull request as ready for review October 4, 2025 00:34
@SomethingGeneric SomethingGeneric merged commit 960287b into main Oct 4, 2025
@SomethingGeneric SomethingGeneric deleted the copilot/fix-64b98d26-40d2-4576-bde5-fb633e37a92d branch October 4, 2025 00:34
@coderabbitai
Copy link

coderabbitai bot commented Oct 4, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add auto update (and check) support for OpenBSD

2 participants