From d26b239493dffa04cd9524b395c5d1143e5f0b70 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Sun, 26 Mar 2023 16:09:20 +0300 Subject: libreoffice/wrapper: Don't --chdir Use lndir and replace it's relevant symlinks with wrappers. --- pkgs/applications/office/libreoffice/wrapper.nix | 30 +++++++++++++++--------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'pkgs/applications/office/libreoffice/wrapper.nix') diff --git a/pkgs/applications/office/libreoffice/wrapper.nix b/pkgs/applications/office/libreoffice/wrapper.nix index 13819a0fb5ecd..1f4059b2adfc6 100644 --- a/pkgs/applications/office/libreoffice/wrapper.nix +++ b/pkgs/applications/office/libreoffice/wrapper.nix @@ -3,6 +3,7 @@ # The unwrapped libreoffice derivation , unwrapped , makeWrapper +, xorg # for lndir , runCommand , substituteAll # For Emulating wrapGAppsHook @@ -72,14 +73,13 @@ let fi '') ] ++ [ - "--chdir" "${unwrapped}/lib/libreoffice/program" "--inherit-argv0" ] ++ extraMakeWrapperArgs ); in runCommand "${unwrapped.name}-wrapped" { inherit (unwrapped) meta; paths = [ unwrapped ]; - nativeBuildInputs = [ makeWrapper ]; + nativeBuildInputs = [ makeWrapper xorg.lndir ]; passthru = { inherit unwrapped; # For backwards compatibility: @@ -87,8 +87,7 @@ in runCommand "${unwrapped.name}-wrapped" { inherit (unwrapped) kdeIntegration; }; } ('' - mkdir -p "$out/bin" - mkdir -p "$out/share" + mkdir -p $out/share for dir in ${unwrapped}/share/*; do dirname="''${dir##*/}" if [[ $dirname == "applications" ]]; then @@ -97,21 +96,30 @@ in runCommand "${unwrapped.name}-wrapped" { ln -s $dir $out/share/ fi done - - ln -s ${unwrapped}/lib $out/lib for f in $out/share/applications/*.desktop; do substituteInPlace "$f" \ --replace "Exec=libreoffice${major}.${minor}" "Exec=soffice" done + mkdir -p $out/bin + mkdir -p $out/lib/libreoffice/program + lndir -silent ${unwrapped}/lib/libreoffice/program $out/lib/libreoffice/program for i in sbase scalc sdraw smath swriter simpress soffice unopkg; do - makeWrapper ${unwrapped}/lib/libreoffice/program/$i $out/bin/$i ${makeWrapperArgs} + # Delete the symlink created by lndir, and replace it by our wrapper + rm $out/lib/libreoffice/program/$i + makeWrapper \ + ${unwrapped}/lib/libreoffice/program/$i \ + $out/lib/libreoffice/program/$i \ + ${makeWrapperArgs} '' + lib.optionalString dbusVerify '' # Delete the dbus socket directory after libreoffice quits - sed -i 's/^exec -a "$0" //g' $out/bin/"$i" - echo 'code="$?"' >> $out/bin/$i - echo 'test -n "$dbus_socket_dir" && { rm -rf "$dbus_socket_dir"; kill $dbus_pid; }' >> $out/bin/$i - echo 'exit "$code"' >> $out/bin/$i + sed -i 's/^exec -a "$0" //g' $out/lib/libreoffice/program/$i + echo 'code="$?"' >> $out/lib/libreoffice/program/$i + echo 'test -n "$dbus_socket_dir" && { rm -rf "$dbus_socket_dir"; kill $dbus_pid; }' >> $out/lib/libreoffice/program/$i + echo 'exit "$code"' >> $out/lib/libreoffice/program/$i '' + '' + ln -s $out/lib/libreoffice/program/$i $out/bin/$i done + # A symlink many users rely upon + ln -s $out/bin/soffice $out/bin/libreoffice '') -- cgit 1.4.1