teams: fix absolute path usages

There are some references to absolute paths in the Teams application
code:

  * /usr/share/pixmaps - The application icon.
  * /usr/bin/xdg-mime - Uses absolute path to invoke.
  * /usr/bin/teams - Uses absolute path in the autostart file if
                     configured to start automatically at login.

Though the paths are hardcoded they can be easily changed within
the application’s main JavaScript code bundle and so we’ll do just
that.

This should at least fix auto-start not working, even when enabled.
This commit is contained in:
Olli Helenius 2021-06-26 17:31:30 +03:00
parent ff5542ccef
commit cce2b65151
No known key found for this signature in database
GPG key ID: 65B7BEC581BD1DD1

View file

@ -13,6 +13,7 @@
, gawk
, xdg-utils
, systemd
, nodePackages
, enableRectOverlay ? false }:
stdenv.mkDerivation rec {
@ -24,7 +25,7 @@ stdenv.mkDerivation rec {
sha256 = "1kx4j837fd344zy90nl0j3r8cdvihy6i6gf56wd5n56zngx1fhjv";
};
nativeBuildInputs = [ dpkg autoPatchelfHook wrapGAppsHook ];
nativeBuildInputs = [ dpkg autoPatchelfHook wrapGAppsHook nodePackages.asar ];
unpackCmd = "dpkg -x $curSrc .";
@ -40,11 +41,27 @@ stdenv.mkDerivation rec {
];
preFixup = ''
gappsWrapperArgs+=(--prefix PATH : "${coreutils}/bin:${gawk}/bin:${xdg-utils}/bin")
gappsWrapperArgs+=(--prefix PATH : "${coreutils}/bin:${gawk}/bin")
gappsWrapperArgs+=(--add-flags --disable-namespace-sandbox)
gappsWrapperArgs+=(--add-flags --disable-setuid-sandbox)
'';
buildPhase = ''
runHook preBuild
asar extract share/teams/resources/app.asar "$TMP/work"
substituteInPlace $TMP/work/main.bundle.js \
--replace "/usr/share/pixmaps/" "$out/share/pixmaps" \
--replace "/usr/bin/xdg-mime" "${xdg-utils}/bin/xdg-mime" \
--replace "Exec=/usr/bin/" "Exec=" # Remove usage of absolute path in autostart.
asar pack --unpack='{*.node,*.ftz,rect-overlay}' "$TMP/work" share/teams/resources/app.asar
runHook postBuild
'';
preferLocalBuild = true;
installPhase = ''
runHook preInstall