Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better recognition of depexts on Gentoo, NetBSD, OpenBSD #5065

Merged
merged 1 commit into from
Feb 24, 2022

Conversation

mndrix
Copy link
Contributor

@mndrix mndrix commented Feb 22, 2022

Gentoo, NetBSD, and OpenBSD name packages in a /-separated
hierarchy. For example, libgmp is available as "dev-libs/gmp"
(on Gentoo[1]) or "devel/gmp" (on NetBSD[2] and OpenBSD[3]).

The first fix in this commit (the change to the short_name function)
removes the leading "/" from the package's short name. Prior to this
commit, if pkg were "dev-libs/gmp", then short_name would be
"/gmp". That doesn't match the depext name of "gmp" so opam thought
the package wasn't installed.

OpenBSD also uses flavors and subpackages[4] in some of its package
names. For example, OpenBSD has two subpackages for the "devel/gmp"
package: main and cxx. That means that the full name for libgmp on
OpenBSD is likely to be "devel/gmp,-main". Prior to this commit,
short_name for this package was "gmp,-main". This commit introduces
no_flavor which removes the flavors and subpackages from package
names, if present. That causes "devel/gmp,-main" on OpenBSD to have a
no_flavor name of "gmp". This name matches the depext name, so that
opam can recognize that libgmp is installed.

1: https://packages.gentoo.org/packages/dev-libs/gmp
2: https://cdn.netbsd.org/pub/pkgsrc/current/pkgsrc/devel/gmp/index.html
3: https://github.com/openbsd/ports/tree/b12d29201e832eb5a230d54449ff2a13502c9fbb/devel/gmp
4: https://man.openbsd.org/OpenBSD-7.0/pkgpath.7

Please update master_changes.md file with your changes.

@mndrix
Copy link
Contributor Author

mndrix commented Feb 22, 2022

I just realized that this wasn't explicit in my comments above: this patch fixes a problem I encounter on OpenBSD where opam install always thinks that conf-gmp needs me to reinstall the libgmp package on my system, even when it's already installed.

Copy link
Member

@kit-ty-kate kit-ty-kate left a comment

Choose a reason for hiding this comment

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

LGTM

@kit-ty-kate
Copy link
Member

Could you add an entry to master_changes.md ?

@kit-ty-kate kit-ty-kate added this to PR in progress in Opam 2.2.0 via automation Feb 22, 2022
@kit-ty-kate kit-ty-kate added this to the 2.2.0~alpha milestone Feb 22, 2022
@kit-ty-kate kit-ty-kate moved this from PR in progress to PR to review in Opam 2.2.0 Feb 22, 2022
Gentoo, NetBSD, and OpenBSD name packages in a /-separated
hierarchy.  For example, libgmp is available as "dev-libs/gmp"
(on Gentoo[1]) or "devel/gmp" (on NetBSD[2], or OpenBSD[3]).

The first fix in this commit (the change to the `short_name` function)
removes the leading "/" from the package's short name.  Prior to this
commit, if `pkg` were "dev-libs/gmp", then `short_name` would be
"/gmp". That doesn't match the depext name of "gmp" so opam thought
the package wasn't installed.

OpenBSD also uses flavors and subpackages[4] in some of its package
names.  For example, OpenBSD has two subpackages for the "devel/gmp"
package: main and cxx. That means that the full name for libgmp on
OpenBSD is likely to be "devel/gmp,-main".  Prior to this commit,
`short_name` for this package was "gmp,-main".  This commit introduces
`no_flavor` which removes the flavors and subpackages from package
names, if present.  That causes "devel/gmp,-main" on OpenBSD to have a
`no_flavor` name of "gmp".  This name matches the depext name, so that
opam recognizes that libgmp is installed.

1: https://packages.gentoo.org/packages/dev-libs/gmp
2: https://cdn.netbsd.org/pub/pkgsrc/current/pkgsrc/devel/gmp/index.html
3: https://github.com/openbsd/ports/tree/b12d29201e832eb5a230d54449ff2a13502c9fbb/devel/gmp
4: https://man.openbsd.org/OpenBSD-7.0/pkgpath.7
@mndrix
Copy link
Contributor Author

mndrix commented Feb 22, 2022

Could you add an entry to master_changes.md ?

Done.

@rjbou
Copy link
Collaborator

rjbou commented Feb 22, 2022

LGTM too!
I guess that you tested locally to validate the fix? There is no *bsd ci test yet

@mndrix
Copy link
Contributor Author

mndrix commented Feb 22, 2022

I guess that you tested locally to validate the fix?

Yup. At least, I tested it on my OpenBSD machine and it works. I don't have Gentoo or NetBSD available.

@rjbou
Copy link
Collaborator

rjbou commented Feb 24, 2022

thanks!

@avsm
Copy link
Member

avsm commented Feb 24, 2022

This looks good to me on OpenBSD. I somehow hadn't twigged that we use the pkgpath for opam-repository, and not the binary package name. I suspect we're inconsistent there -- PRs welcome if you run across any such issues @mndrix.

@rjbou rjbou merged commit cca28c1 into ocaml:master Feb 24, 2022
Opam 2.2.0 automation moved this from PR to review to Done Feb 24, 2022
@kit-ty-kate kit-ty-kate mentioned this pull request Mar 19, 2024
4 tasks
@rjbou rjbou modified the milestones: 2.2.0~alpha, 2.1.6 May 7, 2024
@rjbou rjbou added this to PR in Progress in Opam 2.1.x via automation May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Opam 2.1.x
  
PR in Progress
Opam 2.2.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants