Skip to content

Commit

Permalink
IPMIView: fix iKVM console
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
László Vaskó committed Sep 25, 2019
1 parent 13cd9e1 commit 15b8478
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions pkgs/applications/misc/ipmiview/default.nix
@@ -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";
Expand All @@ -11,27 +21,41 @@ 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 = ''
mkdir -p $out/bin
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" ];
};
}

0 comments on commit 15b8478

Please sign in to comment.