Skip to content

Add better support of portage packages in "add_requires" #7323

Open

Description

@F3llFr0mTh3Sky

Is your feature request related to a problem? Please describe.

Hello @waruqi
I'm so glad you added support for portage packages in version 2.5.4 of the ebuild:
https://xmake.io/posts/xmake-update-v2.5.4.html#add-gentoo-portage-dependency-package
To me, the ability to support looking for dependencies from different package managers is one of the best features of XMake compared to CMake.

However, portage unlike other package managers like apt, yum and pacman can:

  1. Have multiple packages with the same name if they're in different categories, for e.g.:
    acct-user/git, acct-group/git and dev-vcs/git; dev-vcs/git being the main one to lookup.

  2. Install multiple versions of the same category/package on the system, if those versions are in different slots, for e.g.:
    [dev-lang/python-3.14.3:3.14](https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-lang/python/python-3.14.3.ebuild)
    [dev-lang/python-3.13.2:3.13](https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-lang/python/python-3.13.2.ebuild)
    dev-lang/python being the category/package, -3.13.2 being the version and 3.13 being the slot.
    Slot 0 being for packages that can only have one version installed at the same time on the same system.
    Packages like with slot/subslot like 0/12 or 3/14 can only have one version per slot installed at the same time on the same system.

  3. Support virtual packages for installing one package and/or another one, but only require on only one of them for e.g.:
    virtual/jdk
    virtual/jdk/jdk-25-r1.ebuild
    In which both dev-java/openjdk-bin and dev-java/openjdk of the same version can be installed at the same time on the same system, but only a single one of them is actually required.

  4. Support alternative packages so for e.g. only one of many packages can have its executable symlinked to the same name in /usr/bin at the same time on the same system, for e.g.:
    app-alternatives/ninja/
    In this case, both dev-build/ninja and dev-build/samurai can be installed at the same time on the same system, but only one of them can symlink to /usr/bin/ninja.

  5. Support packages sets like @my-beautiful-package-set, for which all of the packages of this set must be installed at the same time on the same system. Those sets are usually user-defined, but there's also sets installed on all system like @world or @System, see:
    https://wiki.gentoo.org/wiki/Package_sets

  6. Support enabling or disabling certain features of what a package can provide by using USE flags:
    https://wiki.gentoo.org/wiki/USE_flag

Describe the solution you'd like

I don't think xmake should support all of the portage features in add_requires.
However, it should at least support the right way:

  1. Packages and sets are named in ebuilds, i.e. category/name-version:slot, the category/, -version, :slot being sometimes optional but still very useful for finding exactly the package or package version you want to install.

Some examples:

Good *: firefox
Bad: firefox:rapid
Good: www-client/firefox
Good: =www-client/firefox-147.0.3
Bad: =www-client/firefox
Good: =www-client/firefox-147.0.3:rapid
Good: www-client/firefox:rapid
Bad: =www-client/firefox:rapid
Good: =www-client/firefox-140.7.1:esr
*only if there is no other packages in other categories with the same name

So packages with -version must always be prefixed by = < > >=, <= or !.

Slot can be names or slot_version  slot_version/subslot_version, e.g.:

0
15
15/12

You can find all of the categories here:
https://packages.gentoo.org/categories

  1. Sets are named, i.e. @my-beautiful-package-set
    See:
    https://wiki.gentoo.org/wiki/Package_sets

In all cases, refer to:
https://devmanual.gentoo.org/ebuild-writing/index.html

Describe alternatives you've considered

If you don't want to support the portage package naming and versioning convention manually, you should make xmake call portage to check if the naming and versioning are correct.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions