Commit 3217f4af authored by Albert Safin's avatar Albert Safin Committed by xzfc
Browse files

collabora-online: init at 24.04.6-1

parent 0e0ab066
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
In the nix build, COOLWSD_VERSION_HASH becomes the same as COOLWSD_VERSION, e.g.
`24.04.3.5`.  The web server that serves files from
`/browser/$COOLWSD_VERSION_HASH`, doesn't expect the hash to contain dots.

--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -933,7 +933,7 @@ std::string FileServerRequestHandler::getRequestPathname(const HTTPRequest& requ
 
     std::string path(requestUri.getPath());
 
-    Poco::RegularExpression gitHashRe("/([0-9a-f]+)/");
+    Poco::RegularExpression gitHashRe("/([0-9a-f.]+)/");
     std::string gitHash;
     if (gitHashRe.extract(path, gitHash))
     {
+9897 −0

File added.

Preview size limit exceeded, changes collapsed.

+105 −0
Original line number Diff line number Diff line
{
  autoreconfHook,
  cairo,
  cppunit,
  fetchFromGitHub,
  fetchNpmDeps,
  lib,
  libcap,
  libpng,
  libreoffice-collabora,
  nodejs,
  npmHooks,
  pam,
  pango,
  pixman,
  pkg-config,
  poco,
  python3,
  rsync,
  stdenv,
  zstd,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "collabora-online";
  version = "24.04.6-1";

  src = fetchFromGitHub {
    owner = "CollaboraOnline";
    repo = "online";
    rev = "refs/tags/cp-${finalAttrs.version}";
    hash = "sha256-0IvymvXAozsjm+GXJK9AGWo79QMaIACrAfkYfX67fBc=";
  };

  nativeBuildInputs = [
    autoreconfHook
    nodejs
    npmHooks.npmConfigHook
    pkg-config
    python3
    python3.pkgs.lxml
    python3.pkgs.polib
    rsync
  ];

  buildInputs = [
    cairo
    cppunit
    libcap
    libpng
    pam
    pango
    pixman
    poco
    zstd
  ];

  configureFlags = [
    "--disable-setcap"
    "--disable-werror"
    "--enable-silent-rules"
    "--with-lo-path=${libreoffice-collabora}/lib/collaboraoffice"
    "--with-lokit-path=${libreoffice-collabora.src}/include"
  ];

  patches = [ ./fix-file-server-regex.patch ];

  postPatch = ''
    cp ${./package-lock.json} ${finalAttrs.npmRoot}/package-lock.json

    patchShebangs browser/util/*.py coolwsd-systemplate-setup scripts/*
    substituteInPlace configure.ac --replace-fail '/usr/bin/env python3' python3
    substituteInPlace coolwsd-systemplate-setup --replace-fail /bin/pwd pwd
  '';

  # Copy dummy self-signed certificates provided for testing.
  postInstall = ''
    cp etc/ca-chain.cert.pem etc/cert.pem etc/key.pem $out/etc/coolwsd
  '';

  npmDeps = fetchNpmDeps {
    unpackPhase = "true";
    # TODO: Use upstream `npm-shrinkwrap.json` once it's fixed
    # https://github.com/CollaboraOnline/online/issues/9644
    postPatch = ''
      cp ${./package-lock.json} package-lock.json
    '';
    hash = "sha256-CUh+jwJnKtmzk8w6QwH1Nh92500dFj63ThkI4tN5FyQ=";
  };

  npmRoot = "browser";

  passthru = {
    libreoffice = libreoffice-collabora; # Used by NixOS module.
    updateScript = ./update.sh;
  };

  meta = {
    description = "Collaborative online office suite based on LibreOffice technology";
    license = lib.licenses.mpl20;
    maintainers = [ lib.maintainers.xzfc ];
    homepage = "https://www.collaboraonline.com";
    platforms = lib.platforms.linux;
  };
})
+38 −0
Original line number Diff line number Diff line
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p common-updater-scripts prefetch-npm-deps jq sd
#shellcheck shell=bash

set -xeu -o pipefail

PACKAGE_DIR="$(realpath "$(dirname "$0")")"
cd "$PACKAGE_DIR/.."
while ! test -f default.nix; do cd .. ; done
NIXPKGS_DIR="$PWD"

new_version="$(
  list-git-tags --url=https://github.com/CollaboraOnline/online \
  | grep --perl-regex --only-matching '^cp-\K[0-9.-]+$' \
  | sort --version-sort \
  | tail -n1
)"

cd "$NIXPKGS_DIR"
update-source-version collabora-online "$new_version"

TMPDIR="$(mktemp -d)"
trap 'rm -rf "$TMPDIR"' EXIT
cd "$TMPDIR"

src="$(nix-build --no-link "$NIXPKGS_DIR" -A collabora-online.src)"
cp "$src"/browser/package.json .
npm install --package-lock-only
cp ./package-lock.json "$PACKAGE_DIR"

prev_npm_hash="$(nix-instantiate "$NIXPKGS_DIR" \
  --eval --json \
  -A collabora-online.npmDeps.hash \
  | jq -r .
)"
new_npm_hash="$(prefetch-npm-deps ./package-lock.json)"

sd --fixed-strings "$prev_npm_hash" "$new_npm_hash" "$PACKAGE_DIR/package.nix"