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

exiv2: Patch cmake files to correctly locate libs #95112

Closed
wants to merge 1 commit into from

Conversation

callahad
Copy link
Member

Motivation for this change

Exiv2's .so and .a files are placed in the default output, but the cmake file looks for them in the dev output. This causes build failures in at least once case (#77581).

This patch takes the same approach as #33953, which solved a similar issue in the clang derivation.

The two outputs in question (.out and .dev) looks like this:

/nix/store/...-exiv2-0.27.2
|-- bin
|   `-- exiv2
`-- lib
    |-- libexiv2-xmp.a
    |-- libexiv2.so -> libexiv2.so.27
    |-- libexiv2.so.0.27.2
    `-- libexiv2.so.27 -> libexiv2.so.0.27.2

/nix/store/...exiv2-0.27.2-dev
|-- include
|   `-- exiv2
|       |-- *.h
|       `-- *.hpp
|-- lib
|   |-- cmake
|   |   `-- exiv2
|   |       |-- exiv2Config-release.cmake
|   |       |-- exiv2Config.cmake
|   |       `-- exiv2ConfigVersion.cmake
|   `-- pkgconfig
|       `-- exiv2.pc
`-- nix-support
    `-- propagated-build-inputs
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Exiv2's .so and .a files are placed in the default output, but the cmake
file looks for them in the dev output. This causes build failures in at
least once case (NixOS#77581).

This patch takes the same approach as NixOS#33953, which solved a similar
issue in the clang derivation.

The two outputs in question (.out and .dev) looks like this:

    /nix/store/...-exiv2-0.27.2
    |-- bin
    |   `-- exiv2
    `-- lib
        |-- libexiv2-xmp.a
        |-- libexiv2.so -> libexiv2.so.27
        |-- libexiv2.so.0.27.2
        `-- libexiv2.so.27 -> libexiv2.so.0.27.2

    /nix/store/...exiv2-0.27.2-dev
    |-- include
    |   `-- exiv2
    |       |-- *.h
    |       `-- *.hpp
    |-- lib
    |   |-- cmake
    |   |   `-- exiv2
    |   |       |-- exiv2Config-release.cmake
    |   |       |-- exiv2Config.cmake
    |   |       `-- exiv2ConfigVersion.cmake
    |   `-- pkgconfig
    |       `-- exiv2.pc
    `-- nix-support
        `-- propagated-build-inputs
@callahad
Copy link
Member Author

I'm running nixpkgs-review but it might take a while on my laptop. Will comment with results in the morning.

As mentioned in #77581, I have been using this patch locally for a few days to successfully build and run digikam 7. Things seem to work as expected.

@callahad
Copy link
Member Author

Also note that I have zero experience with cmake; if there's a better way to resolve this, I'm all ears. 🙂

@@ -106,6 +106,10 @@ stdenv.mkDerivation rec {
rm *
mv .exiv2 exiv2
)

# Tell cmake to look in the default output to find exiv2's .so and .a files
substituteInPlace $out/lib/cmake/exiv2/exiv2Config-release.cmake \
Copy link
Contributor

Choose a reason for hiding this comment

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

Huh? Should not this file be in dev output?

Copy link
Member Author

Choose a reason for hiding this comment

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

Should it? Just the libexiv2-xmp.a, right? I could change the derivation to move that to the dev output instead, if you think that'd be a better solution. Was trying to be minimally invasive here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean the lib/cmake directory.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, right! Attempting to do that (substituteInPlace $dev/lib/cmake/...) gives me an error that file '/nix/store/...-exiv2-0.27.2-dev/lib/cmake/exiv2/exiv2Config-release.cmake' does not exist. Seems like that tree is still inside $out during postInstall? (I'm not entirely sure how multiple output packages work, and skimming the nixpkgs manual isn't clarifying it for me.)

Copy link
Contributor

@jtojnar jtojnar Aug 11, 2020

Choose a reason for hiding this comment

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

Oh, right it is moved during preFixup by the setup hook:

preFixupHooks+=(_multioutDevs)

_multioutDevs() {
if [ "$outputs" = "out" ] || [ -z "${moveToDev-1}" ]; then return; fi;
moveToOutput include "${!outputInclude}"
# these files are sometimes provided even without using the corresponding tool
moveToOutput lib/pkgconfig "${!outputDev}"
moveToOutput share/pkgconfig "${!outputDev}"
moveToOutput lib/cmake "${!outputDev}"

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like lib/cmake gets moved to the dev output during preFixup phase, which comes after this postInstall script.

So is this OK, or does a change need to be made?

(Cite: https://github.com/NixOS/nixpkgs/blob/20.03/pkgs/build-support/setup-hooks/multiple-outputs.sh#L4)

Copy link
Contributor

Choose a reason for hiding this comment

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

Should be fine. Could you include a link to #95232 in the comment, though?

@jtojnar
Copy link
Contributor

jtojnar commented Aug 10, 2020

Ideally someone would make a pull request against the upstream repository to support absolute GNUInstallDirs variables. See https://github.com/jtojnar/cmake-snips

@callahad
Copy link
Member Author

I believe nixpkgs-review is fine:

Result of nixpkgs-review 1

8 packages failed to build:
- calligra
- gimpPlugins.focusblur
- gimpPlugins.texturize
- photivo
- photoflow
- python27Packages.pyexiv2
- python37Packages.py3exiv2
- python38Packages.py3exiv2
110 packages built:
- cataract
- cataract-unstable
- darktable
- deja-dup
- digikam (digikam5)
- dolphin
- doodle
- dragon
- dropbox-cli
- elisa
- empathy
- exiv2
- geeqie
- gegl_0_4
- gexiv2
- gimp
- gimp-with-plugins
- gimpPlugins.exposureBlend
- gimpPlugins.fourier
- gimpPlugins.gap
- gimpPlugins.gimplensfun
- gimpPlugins.gmic
- gimpPlugins.lightning
- gimpPlugins.lqrPlugin
- gimpPlugins.resynthesizer
- gimpPlugins.ufraw
- gimpPlugins.waveletSharpen
- gmic-qt-krita (gmic_krita_qt)
- gnome-photos
- gnome3.cheese
- gnome3.file-roller
- gnome3.gnome-books
- gnome3.gnome-boxes
- gnome3.gnome-color-manager
- gnome3.gnome-contacts
- gnome3.gnome-control-center
- gnome3.gnome-documents
- gnome3.gnome-terminal
- gnome3.gnome-tweak-tool
- gnome3.gnome-user-share
- gnome3.nautilus
- gnome3.nautilus-python
- gnome3.shotwell
- gnome3.totem
- gnome3.tracker-miners
- gnomeExtensions.gsconnect
- gnunet
- gnunet-gtk
- gnunet_git
- gpscorrelate
- gramps
- gthumb
- gwenview
- hugin
- k3b
- kde-cli-tools
- kdeApplications.baloo-widgets
- kdeApplications.dolphin-plugins
- kdeApplications.kdegraphics-thumbnailers
- kdeApplications.kdenlive
- kdeApplications.kfind
- kdeApplications.kio-extras
- kdeApplications.kolourpaint
- libsForQt5.libkexiv2 (kdeApplications.libkexiv2)
- kdeApplications.okular
- libsForQt5.baloo (kdeFrameworks.baloo)
- libsForQt5.kfilemetadata (kdeFrameworks.kfilemetadata)
- kdeplasma-addons
- kdev-php
- kdev-python
- kdevelop
- kdevelop-unwrapped
- kile
- kmenuedit
- krename (krename-qt5)
- krita
- krohnkite
- kwin-tiling
- libextractor
- plasma5.khotkeys (libsForQt5.khotkeys)
- luminanceHDR
- mythtv
- nomacs
- pantheon.elementary-greeter
- pantheon.elementary-photos
- pantheon.extra-elementary-contracts
- pantheon.switchboard-plug-pantheon-shell
- pantheon.switchboard-with-plugs
- pantheon.wingpanel-with-indicators
- pdf2djvu
- peruse
- photoqt
- phototonic
- plasma-browser-integration
- plasma-desktop
- plasma-workspace
- plasma5.powerdevil
- plasma5.systemsettings
- qgis
- qgis-unwrapped
- qimgv
- rapid-photo-downloader
- strigi
- tellico
- ufraw
- variety
- vdrPlugins.xineliboutput
- viewnior
- viking
- wacomtablet

The packages that failed to build also failed to build locally without this pull request, so I don't think the failures are related.

@jtojnar jtojnar added this to In progress in CMake breakage via automation Aug 12, 2020
@jtojnar
Copy link
Contributor

jtojnar commented Aug 12, 2020

Hmm, this does not seem necessary on master: #95232 (comment)

But I do not see why.

@jtojnar
Copy link
Contributor

jtojnar commented Aug 12, 2020

Oh, it was walked around by f1a58ab.

@jtojnar jtojnar closed this Aug 12, 2020
CMake breakage automation moved this from In progress to Done Aug 12, 2020
@callahad
Copy link
Member Author

Oh, great! Thank you for investigating.

@callahad callahad deleted the exiv2-fixup branch August 12, 2020 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants