Skip to content

Commit

Permalink
wpsoffice: switch to autoPatchelfHook, update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
veprbl committed Apr 15, 2020
1 parent f6e2834 commit 593fd37
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 19 deletions.
79 changes: 61 additions & 18 deletions pkgs/applications/office/wpsoffice/default.nix
@@ -1,29 +1,38 @@
{ stdenv
, mkDerivation
, fetchurl
, autoPatchelfHook
, dpkg
, wrapQtAppsHook
, alsaLib
, atk
, bzip2
, cairo
, cups
, dbus
, dpkg
, expat
, ffmpeg_3
, fontconfig
, freetype
, gdk-pixbuf
, glib
, gperftools
, gtk2-x11
, libICE
, libX11
, libXrender
, libpng12
, libtool
, libuuid
, libxml2
, lzma
, nspr
, nss
, openssl
, pango
, qt5
, qt4
, qtbase
, sqlite
, unixODBC
, xorg
, zlib
, zotero
}:

stdenv.mkDerivation rec{
Expand All @@ -37,7 +46,13 @@ stdenv.mkDerivation rec{
unpackCmd = "dpkg -x $src .";
sourceRoot = ".";

nativeBuildInputs = [ qt5.wrapQtAppsHook dpkg ];
postUnpack = stdenv.lib.optionalString (version == "11.1.0.9505") ''
# distribution is missing libjsapiservice.so, so we should not let
# autoPatchelfHook fail on the following dead libraries
rm opt/kingsoft/wps-office/office6/{libjsetapi.so,libjswppapi.so,libjswpsapi.so}
'';

nativeBuildInputs = [ autoPatchelfHook dpkg wrapQtAppsHook ];

meta = {
description = "Office program originally named Kingsoft Office";
Expand All @@ -48,22 +63,24 @@ stdenv.mkDerivation rec{
maintainers = [ stdenv.lib.maintainers.mlatus ];
};

libPath = with xorg; stdenv.lib.makeLibraryPath [
buildInputs = with xorg; [
alsaLib
atk
bzip2
cairo
cups
dbus.daemon.lib
dbus.lib
expat
fontconfig
ffmpeg_3.out
fontconfig.lib
freetype
gdk-pixbuf
glib
gperftools
gtk2-x11
libICE
libSM
libX11
libX11
libXScrnSaver
libXcomposite
libXcursor
Expand All @@ -75,13 +92,20 @@ stdenv.mkDerivation rec{
libXrender
libXtst
libpng12
libtool.lib
libuuid
libxcb
libxml2
lzma
nspr
nss
openssl
pango
qt4
qtbase
sqlite
unixODBC
zlib
zotero
];

dontPatchELF = true;
Expand All @@ -90,18 +114,37 @@ stdenv.mkDerivation rec{
# references to nix own build directory
noAuditTmpdir = true;

unvendoredLibraries = [
# Have to use parts of the vendored qt4
#"Qt"
"SDL2"
"bz2"
"avcodec"
"avdevice"
"avformat"
"avutil"
"swresample"
"swscale"
"jpeg"
"png"
# File saving breaks unless we are using vendored llvmPackages_8.libcxx
#"c++"
"ssl" "crypto"
"nspr"
"nss"
"odbc"
"tcmalloc" # gperftools
];

installPhase = ''
prefix=$out/opt/kingsoft/wps-office
mkdir -p $out
cp -r opt $out
cp -r usr/* $out
# Avoid forbidden reference error due use of patchelf
rm -r *
for lib in $unvendoredLibraries; do
rm -v "$prefix/office6/lib$lib"*.so{,.*}
done
for i in wps wpp et wpspdf; do
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--force-rpath --set-rpath "$(patchelf --print-rpath $prefix/office6/$i):${stdenv.cc.cc.lib}/lib64:${libPath}" \
$prefix/office6/$i
substituteInPlace $out/bin/$i \
--replace /opt/kingsoft/wps-office $prefix
done
Expand Down
2 changes: 1 addition & 1 deletion pkgs/top-level/all-packages.nix
Expand Up @@ -22552,7 +22552,7 @@ in

worldengine-cli = python3Packages.worldengine;

wpsoffice = callPackage ../applications/office/wpsoffice {};
wpsoffice = libsForQt5.callPackage ../applications/office/wpsoffice {};

wrapFirefox = callPackage ../applications/networking/browsers/firefox/wrapper.nix { };

Expand Down

0 comments on commit 593fd37

Please sign in to comment.