Unverified Commit e907f6aa authored by Maciej Krüger's avatar Maciej Krüger Committed by GitHub
Browse files

odoo: fix tests and update to 18.0 (#346397)

parents 22adbbb4 d48355b2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -440,6 +440,7 @@ in {
  pyload = handleTest ./pyload.nix {};
  oci-containers = handleTestOn ["aarch64-linux" "x86_64-linux"] ./oci-containers.nix {};
  odoo = handleTest ./odoo.nix {};
  odoo17 = handleTest ./odoo.nix { package = pkgs.odoo17; };
  odoo16 = handleTest ./odoo.nix { package = pkgs.odoo16; };
  odoo15 = handleTest ./odoo.nix { package = pkgs.odoo15; };
  # 9pnet_virtio used to mount /nix partition doesn't support
+8 −22
Original line number Diff line number Diff line
{ lib
, fetchgit
, fetchzip
, python310
, python312
, rtlcss
, wkhtmltopdf
, nixosTests
, odoo_version ? "17.0"
, odoo_release ? "20240610"
}:

let
  python = python310.override {
  odoo_version = "18.0";
  odoo_release = "20241010";
  python = python312.override {
    self = python;
    packageOverrides = final: prev: {
      # requirements.txt fixes docutils at 0.17; the default 0.21.1 tested throws exceptions
      docutils-0_17 = prev.docutils.overridePythonAttrs (old: rec {
        version = "0.17";
        src = fetchgit {
          url = "git://repo.or.cz/docutils.git";
          rev = "docutils-${version}";
          hash = "sha256-O/9q/Dg1DBIxKdNBOhDV16yy5ez0QANJYMjeovDoWX8=";
        };
        buildInputs = with prev; [setuptools];
      });
    };
  };
in python.pkgs.buildPythonApplication rec {
  pname = "odoo";
@@ -34,13 +22,10 @@ in python.pkgs.buildPythonApplication rec {
  src = fetchzip {
    # find latest version on https://nightly.odoo.com/${odoo_version}/nightly/src
    url = "https://nightly.odoo.com/${odoo_version}/nightly/src/odoo_${version}.zip";
    name = "${pname}-${version}";
    hash = "sha256-blibGJyaz+MxMazOXhPbGBAJWZoGubirwSnjVYyLBJs="; # odoo
    name = "odoo-${version}";
    hash = "sha256-TUfLyB0m8XyEiS493Q/ECgSJutAd1rtWX93f3mwfOK0="; # odoo
  };

  # needs some investigation
  doCheck = false;

  makeWrapperArgs = [
    "--prefix" "PATH" ":" "${lib.makeBinPath [ wkhtmltopdf rtlcss ]}"
  ];
@@ -50,7 +35,8 @@ in python.pkgs.buildPythonApplication rec {
    chardet
    cryptography
    decorator
    docutils-0_17  # sphinx has a docutils requirement >= 18
    docutils
    distutils
    ebaysdk
    freezegun
    geoip2
+13 −7
Original line number Diff line number Diff line
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnused nix coreutils nix-prefetch
# shellcheck shell=bash

set -euo pipefail

VERSION="17.0" # must be incremented manually
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
PKG=$(basename "$SCRIPT_DIR")

LATEST="18" # increment manually
VERSION="${PKG/#odoo}"
VERSION="${VERSION:-$LATEST}.0"

RELEASE="$(
    curl "https://nightly.odoo.com/$VERSION/nightly/src/" |
@@ -12,15 +18,15 @@ RELEASE="$(
)"

latestVersion="$VERSION.$RELEASE"
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; odoo.version or (lib.getVersion odoo)" | tr -d '"')
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; $PKG.version or (lib.getVersion $PKG)" | tr -d '"')

if [[ "$currentVersion" == "$latestVersion" ]]; then
    echo "odoo is up-to-date: $currentVersion"
    echo "$PKG is up-to-date: $currentVersion"
    exit 0
fi

cd "$(dirname "${BASH_SOURCE[0]}")"
cd "$SCRIPT_DIR"

sed -ri "s| hash.+ # odoo| hash = \"$(nix-prefetch -q fetchzip --url "https://nightly.odoo.com/${VERSION}/nightly/src/odoo_${latestVersion}.zip")\"; # odoo|g" package.nix
sed -ri "s|, odoo_version \? .+|, odoo_version ? \"$VERSION\"|" package.nix
sed -ri "s|, odoo_release \? .+|, odoo_release ? \"$RELEASE\"|" package.nix
sed -ri "s| hash.+ # odoo| hash = \"$(nix-prefetch -q fetchzip --option extra-experimental-features flakes --url "https://nightly.odoo.com/${VERSION}/nightly/src/odoo_${latestVersion}.zip")\"; # odoo|g" package.nix
sed -ri "s|odoo_version = .+|odoo_version = \"$VERSION\";|" package.nix
sed -ri "s|odoo_release = .+|odoo_release = \"$RELEASE\";|" package.nix
+18 −27
Original line number Diff line number Diff line
{ lib, fetchFromGitHub, fetchzip, python310, rtlcss, wkhtmltopdf
, nixosTests }:
{ lib
, fetchFromGitHub
, fetchzip
, python310
, rtlcss
, wkhtmltopdf
, nixosTests
}:

let
  odoo_version = "15.0";
  odoo_release = "20241010";
  python = python310.override {
    self = python;
    packageOverrides = self: super: {
      pypdf2 = super.pypdf2.overridePythonAttrs (old: rec {
        version = "1.28.6";
        format = "setuptools";

        src = fetchFromGitHub {
          owner = "py-pdf";
@@ -17,43 +24,25 @@ let
          hash = "sha256-WnRbsy/PJcotZqY9mJPLadrYqkXykOVifLIbDyNf4s4=";
        };

        dependencies = [ self.setuptools ];

        nativeCheckInputs = with self; [ pytestCheckHook pillow ];
      });
      flask = super.flask.overridePythonAttrs (old: rec {
        version = "2.1.3";
        src = old.src.override {
          inherit version;
          hash = "sha256-FZcuUBffBXXD1sCQuhaLbbkCWeYgrI1+qBOjlrrVtss=";
        };
      });
      werkzeug = super.werkzeug.overridePythonAttrs (old: rec {
        version = "2.1.2";
        src = old.src.override {
          inherit version;
          hash = "sha256-HOCOgJPtZ9Y41jh5/Rujc1gX96gN42dNKT9ZhPJftuY=";
        };
      });
    };
  };

  odoo_version = "15.0";
  odoo_release = "20230816";
in python.pkgs.buildPythonApplication rec {
  pname = "odoo15";
  pname = "odoo";
  version = "${odoo_version}.${odoo_release}";

  format = "setuptools";

  # latest release is at https://github.com/odoo/docker/blob/master/15.0/Dockerfile
  # latest release is at https://github.com/odoo/docker/blob/5fb6a842747c296099d9384587cd89640eb7a615/15.0/Dockerfile#L58
  src = fetchzip {
    url = "https://nightly.odoo.com/${odoo_version}/nightly/src/odoo_${version}.zip";
    name = "${pname}-${version}";
    hash = "sha256-h81JA0o44DVtl/bZ52rGQfg54TigwQcNpcMjQbi0zIQ="; # odoo
    name = "odoo-${version}";
    hash = "sha256-Hkre6mghEiLrDwfB1BxGbqEm/zruHLwaS+eIFQKjl1o="; # odoo
  };

  # needs some investigation
  doCheck = false;

  makeWrapperArgs = [
    "--prefix"
    "PATH"
@@ -74,6 +63,7 @@ in python.pkgs.buildPythonApplication rec {
    jinja2
    libsass
    lxml
    lxml-html-clean
    markupsafe
    mock
    num2words
@@ -108,6 +98,7 @@ in python.pkgs.buildPythonApplication rec {
  dontStrip = true;

  passthru = {
    updateScript = ./update.sh;
    tests = { inherit (nixosTests) odoo15; };
  };

+32 −0
Original line number Diff line number Diff line
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnused nix coreutils nix-prefetch
# shellcheck shell=bash

set -euo pipefail

SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
PKG=$(basename "$SCRIPT_DIR")

LATEST="18" # increment manually
VERSION="${PKG/#odoo}"
VERSION="${VERSION:-$LATEST}.0"

RELEASE="$(
    curl "https://nightly.odoo.com/$VERSION/nightly/src/" |
        sed -nE 's/.*odoo_'"$VERSION"'.(20[0-9]{6}).tar.gz.*/\1/p' |
        tail -n 1
)"

latestVersion="$VERSION.$RELEASE"
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; $PKG.version or (lib.getVersion $PKG)" | tr -d '"')

if [[ "$currentVersion" == "$latestVersion" ]]; then
    echo "$PKG is up-to-date: $currentVersion"
    exit 0
fi

cd "$SCRIPT_DIR"

sed -ri "s| hash.+ # odoo| hash = \"$(nix-prefetch -q fetchzip --option extra-experimental-features flakes --url "https://nightly.odoo.com/${VERSION}/nightly/src/odoo_${latestVersion}.zip")\"; # odoo|g" package.nix
sed -ri "s|odoo_version = .+|odoo_version = \"$VERSION\";|" package.nix
sed -ri "s|odoo_release = .+|odoo_release = \"$RELEASE\";|" package.nix
Loading