IPMIView: fix iKVM console

This commit fixes #26650

The main problem was that the iKVM related libraries are always loaded
from the current working directory. The bundled wrapper script makes
sure to CD to the package root folder. This is a no-go in nix as the
application writes its settings in the current working directory and the
store is read-only.

Workaround: create a directory in the users home, where the required
binaries are symlinked and is writable for the current user.

There was an additional issue that for some BMCs IPMIView relies on
the bundled `stunnel` binary to wrap the iKVM traffic in a TLS tunnel.
Therefore it has to be patched to make it executable and the `killall`
command is needed on the PATH because it is used to terminate the
`stunnel` process upon exit.
This commit is contained in:
László Vaskó 2019-09-25 09:10:41 +02:00
parent 13cd9e1bf3
commit 15b8478211

View file

@ -1,4 +1,14 @@
{ stdenv, fetchurl, patchelf, makeWrapper, xorg, fontconfig, freetype, gcc, gcc-unwrapped }:
{ stdenv
, fetchurl
, makeWrapper
, patchelf
, fontconfig
, freetype
, gcc
, gcc-unwrapped
, iputils
, psmisc
, xorg }:
stdenv.mkDerivation rec {
pname = "IPMIView";
@ -11,12 +21,18 @@ stdenv.mkDerivation rec {
};
nativeBuildInputs = [ patchelf makeWrapper ];
buildPhase = with xorg; ''
buildPhase = with xorg;
let
stunnelBinary = if stdenv.hostPlatform.system == "x86_64-linux" then "linux/stunnel64"
else if stdenv.hostPlatform.system == "i686-linux" then "linux/stunnel32"
else throw "IPMIView is not supported on this platform";
in
''
patchelf --set-rpath "${stdenv.lib.makeLibraryPath [ libX11 libXext libXrender libXtst libXi ]}" ./jre/lib/amd64/libawt_xawt.so
patchelf --set-rpath "${stdenv.lib.makeLibraryPath [ freetype ]}" ./jre/lib/amd64/libfontmanager.so
patchelf --set-rpath "${gcc-unwrapped.lib}/lib" ./libiKVM64.so
patchelf --set-rpath "${gcc.cc}/lib:$out/jre/lib/amd64/jli" --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" ./jre/bin/java
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" ./BMCSecurity/${stunnelBinary}
'';
installPhase = ''
@ -24,14 +40,22 @@ stdenv.mkDerivation rec {
cp -R . $out/
# LD_LIBRARY_PATH: fontconfig is used from java code
# PATH: iputils is used for ping, and psmisc is for killall
# WORK_DIR: unfortunately the ikvm related binaries are loaded from
# and user configuration is written to files in the CWD
makeWrapper $out/jre/bin/java $out/bin/IPMIView \
--set LD_LIBRARY_PATH "${stdenv.lib.makeLibraryPath [ fontconfig ]}" \
--prefix PATH : "$out/jre/bin" \
--prefix PATH : "$out/jre/bin:${iputils}/bin:${psmisc}/bin" \
--add-flags "-jar $out/IPMIView20.jar" \
--run 'WORK_DIR=''${XDG_DATA_HOME:-~/.local/share}/ipmiview
mkdir -p $WORK_DIR
ln -snf '$out'/iKVM.jar '$out'/libiKVM* '$out'/libSharedLibrary* $WORK_DIR
cd $WORK_DIR'
'';
meta = with stdenv.lib; {
license = licenses.unfree;
maintainers = with maintainers; [ vlaci ];
platforms = [ "x86_64-linux" "i686-linux" ];
};
}