Skip to content

fix pacman find package#7084

Merged
waruqi merged 2 commits intoxmake-io:devfrom
choyy:fix_findpackage
Dec 1, 2025
Merged

fix pacman find package#7084
waruqi merged 2 commits intoxmake-io:devfrom
choyy:fix_findpackage

Conversation

@choyy
Copy link
Contributor

@choyy choyy commented Dec 1, 2025

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @choyy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request improves the reliability of package version detection for pacman packages within the xmake build system. By switching to a direct query of the pacman utility, it resolves issues where versions might be incorrectly inferred from .pc files, especially in complex package structures. This change ensures that xmake always reports the correct and consistent version for pacman dependencies.

Highlights

  • Version Resolution Logic: The pull request refactors how package versions are determined for pacman packages, specifically addressing potential inaccuracies when a package contains multiple .pc files.
  • Direct Pacman Query: The system now directly queries the pacman package manager using pacman -Q <package_name> to retrieve the authoritative package version, ensuring greater accuracy.
  • Removed Redundant Version Assignment: The previous logic that assigned result.version directly from pcresult.version within the .pc file processing loop has been removed, as it could lead to incorrect versions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request addresses an issue with pacman package version retrieval, particularly when a package contains multiple .pc files. The previous logic of deriving the version from pcresult.version has been removed, and a new approach is introduced to query the version directly from pacman -Q <package_name>. This change aims to ensure more accurate version reporting. However, the new version parsing logic has a couple of issues that need to be addressed to prevent incorrect version numbers and potential runtime errors.

Comment on lines +241 to +243
local version = try { function() return os.iorunv(pacman.program, {"-Q", name}) end }
version = version:trim():split('%s+')[2]
result.version = version:split('-')[1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The new version parsing logic does not handle package versions that include an epoch, such as 1:1.3.204-1. The _find_package_from_list function (lines 107-109) correctly strips this prefix. Without this, the result.version might be 1:1.3.204 instead of 1.3.204.

Additionally, the version variable might be nil if os.iorunv fails to return any output. Directly calling trim() or split() on a nil value will cause a runtime error. It's important to check if version is valid before attempting string operations on it.

        local version = try { function() return os.iorunv(pacman.program, {"-Q", name}) end }
        if version then
            version = version:trim():split('%s+')[2]
            -- we need strip "1:" prefix, @see https://github.com/xmake-io/xmake/issues/2020
            -- e.g. vulkan-headers 1:1.3.204-1
            if version:startswith("1:") then
                version = version:split(':')[2]
            end
            result.version = version:split('-')[1]
        end

if verstr then
local version = semver.match(verstr)
if version then
result.version = version:rawstr():split('-')[1]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do not use version:rawstr()? it's already a valid semver.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pacman version is pkgver-pkgrel, split('-')[1] is to remove pkgrel to get the original version.

@waruqi waruqi merged commit e87feba into xmake-io:dev Dec 1, 2025
35 checks passed
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.

2 participants