diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2022-06-01 00:02:36 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-01 00:02:36 +0000 |
commit | d8ae99a0c9791273667c88ee492443df58dcdde4 (patch) | |
tree | b0b81c6ebe08e1dfddf54a207fe0fd3556b3fa5d /pkgs/applications/office | |
parent | d6ede66f6a6f0542b58b7a7d50265fa111de1b27 (diff) | |
parent | 3e3d3ce0a3736a2796fddbeea5cf53ce9bd2b98f (diff) |
Merge master into staging-next
Diffstat (limited to 'pkgs/applications/office')
6 files changed, 201 insertions, 53 deletions
diff --git a/pkgs/applications/office/libreoffice/darwin.nix b/pkgs/applications/office/libreoffice/darwin.nix deleted file mode 100644 index 765cbcd43024b..0000000000000 --- a/pkgs/applications/office/libreoffice/darwin.nix +++ /dev/null @@ -1,51 +0,0 @@ -{ stdenv -, lib -, fetchurl -, undmg -}: - -let - appName = "LibreOffice.app"; - version = "7.2.5"; - dist = { - aarch64-darwin = { - arch = "aarch64"; - sha256 = "bdbcb9a98211f866ca089d440aebcd1d313aa99e8ab4104aae4e65ea3cee74ca"; - }; - - x86_64-darwin = { - arch = "x86_64"; - sha256 = "0b7ef18ed08341ac6c15339fe9a161ad17f6b469009d987cfc7d50c628d12a4e"; - }; - }."${stdenv.hostPlatform.system}"; -in -stdenv.mkDerivation { - inherit version; - pname = "libreoffice"; - src = fetchurl { - url = "https://download.documentfoundation.org/libreoffice/stable/${version}/mac/${dist.arch}/LibreOffice_${version}_MacOS_${dist.arch}.dmg"; - inherit (dist) sha256; - }; - - nativeBuildInputs = [ undmg ]; - sourceRoot = "${appName}"; - dontPatch = true; - dontConfigure = true; - dontBuild = true; - - installPhase = '' - runHook preInstallPhase - mkdir -p $out/{Applications/${appName},bin} - cp -R . $out/Applications/${appName} - ln -s $out/Applications/${appName}/Contents/MacOS/soffice $out/bin - runHook postInstallPhase - ''; - - meta = with lib; { - description = "Comprehensive, professional-quality productivity suite, a variant of openoffice.org"; - homepage = "https://libreoffice.org/"; - license = licenses.lgpl3; - maintainers = with maintainers; [ tricktron ]; - platforms = [ "aarch64-darwin" "x86_64-darwin" ]; - }; -} diff --git a/pkgs/applications/office/libreoffice/darwin/default.nix b/pkgs/applications/office/libreoffice/darwin/default.nix new file mode 100644 index 0000000000000..ddfaf584021cb --- /dev/null +++ b/pkgs/applications/office/libreoffice/darwin/default.nix @@ -0,0 +1,80 @@ +{ stdenvNoCC +, lib +, fetchurl +, undmg +, writeScript +, callPackage +}: + +let + appName = "LibreOffice.app"; + scriptName = "soffice"; + version = "7.3.3"; + + dist = { + aarch64-darwin = rec { + arch = "aarch64"; + archSuffix = arch; + url = "https://download.documentfoundation.org/libreoffice/stable/${version}/mac/${arch}/LibreOffice_${version}_MacOS_${archSuffix}.dmg"; + sha256 = "50ed3deb8d9c987516e2687ebb865bca15486c69da79f1b6d74381e43f2ec863"; + }; + + x86_64-darwin = rec { + arch = "x86_64"; + archSuffix = "x86-64"; + url = "https://download.documentfoundation.org/libreoffice/stable/${version}/mac/${arch}/LibreOffice_${version}_MacOS_${archSuffix}.dmg"; + sha256 = "fb2f9bb90eee34a22af3a2bf2854ef5b76098302b3c41d13d4f543f0d72b994f"; + }; + }; +in +stdenvNoCC.mkDerivation { + inherit version; + pname = "libreoffice"; + src = fetchurl { + inherit (dist.${stdenvNoCC.hostPlatform.system} or + (throw "Unsupported system: ${stdenvNoCC.hostPlatform.system}")) url sha256; + }; + + nativeBuildInputs = [ undmg ]; + sourceRoot = "${appName}"; + + installPhase = '' + runHook preInstall + mkdir -p $out/{Applications/${appName},bin} + cp -R . $out/Applications/${appName} + cat > $out/bin/${scriptName} << EOF + #!${stdenvNoCC.shell} + open -na $out/Applications/${appName} --args "$@" + EOF + chmod +x $out/bin/${scriptName} + runHook postInstall + ''; + + passthru.updateScript = + let + defaultNixFile = builtins.toString ./default.nix; + updateNix = builtins.toString ./update.nix; + aarch64Url = dist."aarch64-darwin".url; + x86_64Url = dist."x86_64-darwin".url; + in + writeScript "update-libreoffice.sh" + '' + #!/usr/bin/env nix-shell + #!nix-shell -i bash --argstr aarch64Url ${aarch64Url} --argstr x86_64Url ${x86_64Url} --argstr version ${version} ${updateNix} + set -eou pipefail + + # reset version first so that both platforms are always updated and in sync + update-source-version libreoffice-bin 0 ${lib.fakeSha256} --file=${defaultNixFile} --system=aarch64-darwin + update-source-version libreoffice-bin $newVersion $newAarch64Sha256 --file=${defaultNixFile} --system=aarch64-darwin + update-source-version libreoffice-bin 0 ${lib.fakeSha256} --file=${defaultNixFile} --system=x86_64-darwin + update-source-version libreoffice-bin $newVersion $newX86_64Sha256 --file=${defaultNixFile} --system=x86_64-darwin + ''; + + meta = with lib; { + description = "Comprehensive, professional-quality productivity suite, a variant of openoffice.org"; + homepage = "https://libreoffice.org/"; + license = licenses.lgpl3; + maintainers = with maintainers; [ tricktron ]; + platforms = [ "x86_64-darwin" "aarch64-darwin" ]; + }; +} diff --git a/pkgs/applications/office/libreoffice/darwin/update-test.nix b/pkgs/applications/office/libreoffice/darwin/update-test.nix new file mode 100644 index 0000000000000..994a923c556dc --- /dev/null +++ b/pkgs/applications/office/libreoffice/darwin/update-test.nix @@ -0,0 +1,50 @@ +# run the tests with nixt <absolutePath to parent dir> -v + +{ pkgs ? import <nixpkgs> { }, nixt }: +let + inherit (import ./update-utils.nix { inherit (pkgs) lib; }) + extractLatestVersionFromHtml + extractSha256FromHtml + getLatestStableVersion; +in +nixt.mkSuite "LibreOffice Updater" +{ + "should extract latest stable version from html" = + let + latestVersionHtmlMock = + '' + <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + <html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>Index of /libreoffice/stable</title> + <link rel="stylesheet" href="/mirrorbrain.css" type="text/css" /> + </head> + <body> + <h1>Index of /libreoffice/stable</h1> + <table><tr><th> </th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th>Metadata</th></tr><tr><th colspan="5"><hr /></th></tr> + <tr><td valign="top"> </td><td><a href="/libreoffice/">Parent Directory</a></td><td> </td><td align="right"> - </td><td> </td></tr> + <tr><td valign="top"> </td><td><a href="7.2.7/">7.2.7/</a></td><td align="right">10-Mar-2022 11:12 </td><td align="right"> - </td><td> </td></tr> + <tr><td valign="top"> </td><td><a href="7.3.3/">7.3.3/</a></td><td align="right">12-May-2022 10:06 </td><td align="right"> - </td><td> </td></tr> + <tr><td valign="top"> </td><td><a href="7.2.6/">7.2.6/</a></td><td align="right">05-May-2022 07:57 </td><td align="right"> - </td><td> </td></tr> + <tr><th colspan="5"><hr /></th></tr> + </table> + <address>Apache Server at <a href="mailto:hostmaster@documentfoundation.org">download.documentfoundation.org</a> Port 80</address> + <br/><address><a href="http://mirrorbrain.org/">MirrorBrain</a> powered by <a href="http://httpd.apache.org/">Apache</a></address> + </body></html> + ''; + + actual = extractLatestVersionFromHtml latestVersionHtmlMock; + + in + "7.3.3" == actual; + + "should extract latest stable version from website" = (builtins.compareVersions getLatestStableVersion "7.3.3") >= 0; + + "should extract sha256 from html" = + let + sha256Html = "50ed3deb8d9c987516e2687ebb865bca15486c69da79f1b6d74381e43f2ec863 LibreOffice_7.3.3_MacOS_aarch64.dmg\n"; + actual = extractSha256FromHtml sha256Html; + in + "50ed3deb8d9c987516e2687ebb865bca15486c69da79f1b6d74381e43f2ec863" == actual; +} diff --git a/pkgs/applications/office/libreoffice/darwin/update-utils.nix b/pkgs/applications/office/libreoffice/darwin/update-utils.nix new file mode 100644 index 0000000000000..766e858e33e2c --- /dev/null +++ b/pkgs/applications/office/libreoffice/darwin/update-utils.nix @@ -0,0 +1,51 @@ +{ lib }: +let + # extractLatestVersionFromHtml :: String -> String + extractLatestVersionFromHtml = htmlString: + let + majorMinorPatchGroup = "([0-9]+\\.[0-9]+\\.[0-9]+)"; + splittedVersions = builtins.split "href=\"${majorMinorPatchGroup}" htmlString; + stableVersions = builtins.concatLists + (builtins.filter (e: builtins.isList e) + splittedVersions); + in + if stableVersions == [ ] + then abort "Failed to extract versions from html." + else lib.last (builtins.sort builtins.lessThan stableVersions); + + # getHtml :: String -> String + getHtml = url: + builtins.readFile (builtins.fetchurl url); + + # getLatestStableVersion :: String + getLatestStableVersion = + extractLatestVersionFromHtml + (getHtml "https://download.documentfoundation.org/libreoffice/stable/"); + + # extractSha256FromHtml :: String -> String + extractSha256FromHtml = htmlString: + let + sha256 = (builtins.match ".*([0-9a-fA-F]{64}).*" htmlString); + in + if sha256 == [ ] + then abort "Failed to extract sha256 from html." + else builtins.head sha256; + + # getSha256 :: String -> String + getSha256 = dmgUrl: oldVersion: newVersion: + extractSha256FromHtml (getHtml (getSha256Url dmgUrl oldVersion newVersion)); + + # getSha256Url :: String -> String -> String -> String + getSha256Url = dmgUrl: oldVersion: newVersion: + (builtins.replaceStrings [ oldVersion ] [ newVersion ] dmgUrl) + ".sha256"; + +in +{ + inherit + extractLatestVersionFromHtml + getHtml + getLatestStableVersion + extractSha256FromHtml + getSha256 + getSha256Url; +} diff --git a/pkgs/applications/office/libreoffice/darwin/update.nix b/pkgs/applications/office/libreoffice/darwin/update.nix new file mode 100644 index 0000000000000..b74cca802fcb1 --- /dev/null +++ b/pkgs/applications/office/libreoffice/darwin/update.nix @@ -0,0 +1,18 @@ +# Impure functions, for passthru.updateScript runtime only +{ aarch64Url +, x86_64Url +, version +, pkgs ? import ../../../../../default.nix { } +, +}: +let + inherit (import ./update-utils.nix { inherit (pkgs) lib; }) + getLatestStableVersion + getSha256; +in +pkgs.mkShell rec { + buildInputs = [ pkgs.common-updater-scripts ]; + newVersion = getLatestStableVersion; + newAarch64Sha256 = getSha256 aarch64Url version newVersion; + newX86_64Sha256 = getSha256 x86_64Url version newVersion; +} diff --git a/pkgs/applications/office/portfolio/default.nix b/pkgs/applications/office/portfolio/default.nix index 653e72a163eb3..835f96d2158a9 100644 --- a/pkgs/applications/office/portfolio/default.nix +++ b/pkgs/applications/office/portfolio/default.nix @@ -25,11 +25,11 @@ let in stdenv.mkDerivation rec { pname = "PortfolioPerformance"; - version = "0.57.2"; + version = "0.58.3"; src = fetchurl { url = "https://github.com/buchen/portfolio/releases/download/${version}/PortfolioPerformance-${version}-linux.gtk.x86_64.tar.gz"; - sha256 = "sha256-ftLKlNzr46iL/V+P3J1wtoUByGHHl7wrh4xctU4JYkM="; + sha256 = "sha256-hm7iIYv4egd79G+LfetFSFLQRnfechJIY3k5Dys63vY="; }; nativeBuildInputs = [ |