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

policy: add pkgconfig rule #317

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

policy: add pkgconfig rule #317

wants to merge 1 commit into from

Conversation

X547
Copy link

@X547 X547 commented Jan 26, 2025

pkgconfig entries in develop/lib[<arch>]/pkgconfig/*.pc must be declared as pc:*[_<arch>].

This allow to easily install build dependencies for projects that use pkgconfig for locating dependencies.

@jmairboeck
Copy link
Member

Aren't these (mostly) redundant with the existing devel: entries?

@X547
Copy link
Author

X547 commented Jan 26, 2025

No, devel: entries often do not match pkgconfig names. Single devel package may also provide multiple pkgconfig entries.

It is a pain to search package names that match build requirements.

devel: entry names are OS/distro specific, but pkgconfig names are universal and the same for all distros.

pkgconfig entries in `develop/lib[<arch>]/pkgconfig` must be declared as
`pc:*[_<arch>]`.
@pulkomandy
Copy link
Member

pulkomandy commented Jan 26, 2025 via email

@X547
Copy link
Author

X547 commented Jan 26, 2025

As can be seen in code above changed part, devel: matches library name in develop/lib directory. But pkgconfig names don't necessary match library names. It can be header-only library that have no any libraries in develop/lib directory. It may be pkgconfig entry that refer multiple libraries. pkgconfig names are arbitrary and may be not consistent (may have or not have "lib" prefix etc.).

so, adding more provides makes the package repo much larger.

By this logic we should also avoid long package descriptions or porting too much software, that is bad idea. Also without actually trying, we can't know how larger repo file will become, maybe not so much.

It may be good idea to implement some kind of delta updates of repo file instead of fully downloading it on each run. Most of packages stay the same after repo update.

@pulkomandy
Copy link
Member

pulkomandy commented Jan 26, 2025 via email

@waddlesplash
Copy link
Member

I would be interested in examples of this.

IMO we should not add more provides just for pkg-config files, at least in general (maybe there are specific cases where it makes sense). If the pkg-config file is just some other abbreviated form of the name then let's just make sure that abbreviated form appears in the package summary/description so pkgman search picks it up. Otherwise, maybe what we want/need is a "files database" that collects all files from all packages in some central place and lists them, separately from the repo file of course as we don't want to make it any larger.

@X547
Copy link
Author

X547 commented Jan 27, 2025

I would be interested in examples of this.

Use case would be something like:

  1. meson introspect --scan-dependencies meson.build
  2. pkgman install pc:dep1 pc:dep2 pc:dep3 pc:dep4 pc:dep5
  3. mkdir build; cd build; meson setup ..; ninja

@X547
Copy link
Author

X547 commented Jan 27, 2025

  • Why do "devel:" entry have to match library names? Is that useful?

devel: entries are actually not very useful for projects that use pkgconfig. Just specifying library names are often not enough, additional include paths and defines are often needed to compile program that use library.

It will be better to specify pc: entries in recipe build requires instead of devel: entries because this is how build process is actually works.

@waddlesplash
Copy link
Member

No, I meant, what actually existing software has such .pc files that don't match either the software (package) name, or the library name?

@X547
Copy link
Author

X547 commented Jan 27, 2025

@waddlesplash
Copy link
Member

The only one of those where the package name doesn't correspond to either the pkg-config name or library name is glvnd, and that does provide a libGL. So I don't see where the disconnect is here. All of those would be obvious.

@pulkomandy
Copy link
Member

x512 explained very clearly why this is needed:

  • Header only libraries may have only a pkg-config file and no libraries
  • Library name may not match pkg-config name (this is the case for example for Lua)

"freetext" data in the description won't do it. First of all, it's clumsy (forcing people to write some specific words in the description, while we have metadata for it). Secondly, it's harder to parse and so would prevent making scripts or tools that automate things. For example, think of how Debugger can autoinstall needed debuginfo package. Surely an IDE may want to do the same, by scanning a buildsystem file or buildtool output, and automatically offering to install the needed development packages. For this to work, there has to be a predictable name related to what the buildsystem is looking for. This can be either a library name (if looking directly at -lxxx parameters in the linker command line), or a pkgconfig filename.

For the same reason, storing that outside the repository file makes little sense: providing that information is exactly the job of the repository file.

Another idea would be to rename the pkgconfig files. Unfortunately, doing so defeats their purpose, which is to have a predictable name to look for, no matter what platform you're in. So it's important that upstream pkgconfig names are kept.

So the remaining options are:

  • Separate devel: and pc: namespaces, cleaner but potentially a lot of duplication,
  • Using the same devel: namespace, less explicit, opens room for conflict if a pkgconfig file in one package has the same name as a library in another package, but avoids having two entries when the lib and pkgconfig file have the same name.

@jmairboeck
Copy link
Member

The third option would be to not require a devel: entry if there is a pc: entry which covers it. But that would maybe be too much of a breaking change.

@waddlesplash
Copy link
Member

Header only libraries may have only a pkg-config file and no libraries

In that case I would expect a devel: entry for the pkg-config file.

Library name may not match pkg-config name (this is the case for example for Lua)

In that case (but only in that case) it may make sense to have a separate provide. So, the policy check would then be that there is some provide matching the pkg-config name, or the pkg-config name with lib on the front.

But if there are only a very small number of applications that fit that paradigm, like Lua, then a full policy check may not make sense and we should just add the provides for the particular packages as special cases.

@X547
Copy link
Author

X547 commented Jan 27, 2025

In that case (but only in that case) it may make sense to have a separate provide

How it will work? Add some expressions support to pkgman like pkgman install (devel:dep1 || pc:dep1) (devel:dep2 || pc:dep2) (devel:dep3 || pc:dep3)? Without it, it will be not possible to automatically install pkgconfig dependencies.

@waddlesplash
Copy link
Member

pkgman search should be used regardless because multiple packages may provide the same library already (e.g. ICU 74 vs 75) and the user should be offered a choice of what to install (or not to install), one shouldn't just blindly run pkgman install in most cases.

@X547
Copy link
Author

X547 commented Jan 27, 2025

multiple packages may provide the same library already (e.g. ICU 74 vs 75)

Dependency solver support specifying resolvable versions.

@X547
Copy link
Author

X547 commented Jan 29, 2025

Found pkgconfig files installed to wrong location while working on this: haikuports/haikuports#11694.

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

Successfully merging this pull request may close these issues.

4 participants