sweethome3d: fix impurity
The sweethome3d program ships pre-compiled shared libraries for graphics that need to be `patchelf`ed to work properly. Once the libraries are compressed into the final .jar, Nix can no longer see the path references so they are not declared a runtime dependency and the program won't run on a system that didn't build it and doesn't happen to have the right paths already present on it by chance. This patch switches to autoPatchelfHook to ensure the libraries get patched correctly, then scans the libraries to make a plain-text file with the same paths so that Nix can see the references and account for them. I suspect this problem might be lurking in other Java programs in nixpkgs. Fixes #66471.
This commit is contained in:
parent
ccb9c0e537
commit
1dcc140d7f
@ -10,6 +10,7 @@
|
||||
, gtk3
|
||||
, gsettings-desktop-schemas
|
||||
, p7zip
|
||||
, autoPatchelfHook
|
||||
, libXxf86vm
|
||||
, unzip
|
||||
}:
|
||||
@ -41,14 +42,17 @@ let
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
patchelf --set-rpath ${libXxf86vm}/lib lib/java3d-1.6/linux/amd64/libnativewindow_awt.so
|
||||
patchelf --set-rpath ${libXxf86vm}/lib lib/java3d-1.6/linux/amd64/libnativewindow_x11.so
|
||||
patchelf --set-rpath ${libXxf86vm}/lib lib/java3d-1.6/linux/i586/libnativewindow_awt.so
|
||||
patchelf --set-rpath ${libXxf86vm}/lib lib/java3d-1.6/linux/i586/libnativewindow_x11.so
|
||||
addAutoPatchelfSearchPath ${jre8}/lib/openjdk/jre/lib/
|
||||
autoPatchelf lib
|
||||
|
||||
# Nix cannot see the runtime references to the paths we just patched in
|
||||
# once they've been compressed into the .jar. Scan for and remember them
|
||||
# as plain text so they don't get overlooked.
|
||||
find . -name '*.so' | xargs strings | { grep '/nix/store' || :; } >> ./.jar-paths
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [ makeWrapper unzip ];
|
||||
buildInputs = [ ant jdk8 p7zip gtk3 gsettings-desktop-schemas ];
|
||||
nativeBuildInputs = [ makeWrapper unzip autoPatchelfHook ];
|
||||
buildInputs = [ ant jdk8 p7zip gtk3 gsettings-desktop-schemas libXxf86vm ];
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
@ -80,6 +84,13 @@ let
|
||||
--prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:${gtk3.out}/share:${gsettings-desktop-schemas}/share:$out/share:$GSETTINGS_SCHEMAS_PATH" \
|
||||
--add-flags "-Dsun.java2d.opengl=true -jar $out/share/java/${module}-${version}.jar -cp $out/share/java/Furniture.jar:$out/share/java/Textures.jar:$out/share/java/Help.jar -d${toString stdenv.hostPlatform.parsed.cpu.bits}"
|
||||
|
||||
|
||||
# remember the store paths found inside the .jar libraries. note that
|
||||
# which file they are in does not matter in particular, just that some
|
||||
# file somewhere lists them in plain-text
|
||||
mkdir -p $out/nix-support
|
||||
cp .jar-paths $out/nix-support/depends
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user