Skip to content

pkg-config: Relative paths#344

Merged
scop merged 2 commits intoscop:masterfrom
inigomartinez:fix-pkg-config
Nov 11, 2019
Merged

pkg-config: Relative paths#344
scop merged 2 commits intoscop:masterfrom
inigomartinez:fix-pkg-config

Conversation

@inigomartinez
Copy link
Contributor

Using pkg-config options the user has the possibility to redefine key values present in the .pc files.

Due to this compatdir, completionsdir and helpersdir that are defined in the generated pkg-config .pc file should be relative paths.

This helps any pkg-config user to set these variables to proper directories by using the define-variable command line argument.

@inigomartinez
Copy link
Contributor Author

This was already tried to be handled in #198 but it has gotten worse.

@inigomartinez
Copy link
Contributor Author

As stated in #71662, this approach solves the issue regarding setting variables present in the pkg-config file in compile and install time.

At the moment the pkg-config file is generated with absolute paths on it and this doesn't allow the use of the define-variable option present in pkg-config program. As also stated in the previous MR, to be able to do this, datadir and sysconfdir variables must be present in the .pc file, and compatdir, completionsdir and helpersdir be relative to this variables, so earlier variables can be redefined modifying the final destination of the latter variables.

The MR has been rebased with newer changes to ease its application.

scop pushed a commit that referenced this pull request Nov 8, 2019
Copy link
Owner

@scop scop left a comment

Choose a reason for hiding this comment

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

Sorry for having overlooked this. I find it ugly that some systems are (ab)using these variables to do staged installs (for autotools there's DESTDIR which is a better solution to the problem), but I suppose that bird's already out of the cage and even autotools' distcheck does something similar itself, see e.g. jpmens/jo#102

So I suppose we need to cater for those usage patterns. The patch looks ok in principle, but as now we're no longer using pkgdatadir everywhere, I think we should not use it anywhere. After your patch, there are still references to it in these files:

  • Makefile.am
  • completions/Makefile.am
  • helpers/Makefile.am

@scop
Copy link
Owner

scop commented Nov 8, 2019

Oh, and I "borrowed" theName: @PACKAGE@ change from here already, because it's not really related to the issue at hand and applied it as 32369a0, so there's a small conflict to be resolved as well.

@inigomartinez
Copy link
Contributor Author

@scop thank you for reviewing this. I have rebased again the branch with the latest changes.

So I suppose we need to cater for those usage patterns. The patch looks ok in principle, but as now we're no longer using pkgdatadir everywhere, I think we should not use it anywhere. After your patch, there are still references to it in these files:

This looks sensible to me. I have checked the "allow maintainers" check and is enabled so you will be able to also made these changes.

@scop
Copy link
Owner

scop commented Nov 9, 2019

Sure, I'll quite likely get to it sometime, but I believe you'd beat me to it ;)

@inigomartinez
Copy link
Contributor Author

I have split the changes in two commits. The first one applies the original changes and the second one replaces pkgdatadir with datadir/PACKAGE in required places.

set (BASH_COMPLETION_HELPERSDIR "@pkgdatadir@/helpers")
set (BASH_COMPLETION_DATADIR "@datadir@")
set (BASH_COMPLETION_SYSCONFDIR "@sysconfdir@")

Copy link
Owner

Choose a reason for hiding this comment

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

I wonder if this does what it intends to do. It introduces BASH_COMPLETION_DATADIR and BASH_COMPLETION_SYSCONFDIR, but they're not used for anything that I can tell, one cannot use them to override install locations because the definitions below don't use them; they have similarly hardwired/expanded paths as they used to.

Could you clarify the intent here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally my fault sorry due to my lack of knowledge of cmake. I thought that it was related to the bash-completion.pc.in file and that it also needed to have these two variables defined. I have removed these two lines from the commit.

Define our completion and helper dirs using the standard data and sysconf
dirs. Enables 3rd party package staged installs by overriding these two
dirs, in addition to the already existing mechanisms.
`pkgdatadir` has been replaced in some cases when adding support for
variable redefinition in `pkg-config` files.

These changes removes all use of `pkgdatadir` to add consistency.
@scop scop merged commit 0cc34e8 into scop:master Nov 11, 2019
@scop
Copy link
Owner

scop commented Nov 11, 2019

Applied, thanks. I took the liberty to modify the extended commentary of the first commit, because it used wording like "proper" which kind of suggests that users are expected to set them which isn't the case except in some specific scenarios.

gnomesysadmins pushed a commit to GNOME/gnome-shell that referenced this pull request Apr 9, 2020
It is a good practice to install files relative to our own variables

https://www.bassi.io/articles/2018/03/15/pkg-config-and-paths/

and it is required on systems like NixOS.

Thanks to Iñigo, bash-completion support that since 2.10:

scop/bash-completion#344
gnomesysadmins pushed a commit to GNOME/gnome-shell that referenced this pull request Apr 9, 2020
gnomesysadmins pushed a commit to GNOME/dconf that referenced this pull request Apr 16, 2020
Since bash-completion 2.9, it was no longer possible to override
the completionsdir through prefix. [1] In 2.10, the overridability
was re-estabilished but this time through datadir variable. [2]

This should not really matter except for developers installing the project
into a custom prefix or distros using per-package prefixes like NixOS.

[1]: scop/bash-completion@81ba2c7
[2]: scop/bash-completion#344

Co-Authored-By: Iñigo Martínez <[email protected]>
jtojnar added a commit to jtojnar/fwupd that referenced this pull request Apr 16, 2020
Since bash-completion 2.9, it was no longer possible to override
the completionsdir through prefix. [1] In 2.10, the overridability
was re-estabilished but this time through datadir variable. [2]

This should not really matter except for developers installing the project
into a custom prefix or distros using per-package prefixes like NixOS.

[1]: scop/bash-completion@81ba2c7
[2]: scop/bash-completion#344
superm1 pushed a commit to fwupd/fwupd that referenced this pull request Apr 16, 2020
Since bash-completion 2.9, it was no longer possible to override
the completionsdir through prefix. [1] In 2.10, the overridability
was re-estabilished but this time through datadir variable. [2]

This should not really matter except for developers installing the project
into a custom prefix or distros using per-package prefixes like NixOS.

[1]: scop/bash-completion@81ba2c7
[2]: scop/bash-completion#344
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