Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

odoo: fix tests and update to 18.0 #346397

Merged
merged 8 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 8 additions & 22 deletions pkgs/by-name/od/odoo/package.nix
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
{ 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";
Expand All @@ -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 ]}"
];
Expand All @@ -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
Expand Down
20 changes: 13 additions & 7 deletions pkgs/by-name/od/odoo/update.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#!/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/" |
Expand All @@ -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
45 changes: 18 additions & 27 deletions pkgs/by-name/od/odoo15/package.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
{ 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";
Expand All @@ -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"
Expand All @@ -74,6 +63,7 @@ in python.pkgs.buildPythonApplication rec {
jinja2
libsass
lxml
lxml-html-clean
markupsafe
mock
num2words
Expand Down Expand Up @@ -108,6 +98,7 @@ in python.pkgs.buildPythonApplication rec {
dontStrip = true;

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

Expand Down
32 changes: 32 additions & 0 deletions pkgs/by-name/od/odoo15/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/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
33 changes: 6 additions & 27 deletions pkgs/by-name/od/odoo16/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,11 @@
}:

let
odoo_version = "16.0";
odoo_release = "20241010";
python = python310.override {
self = python;
packageOverrides = self: super: {
flask = super.flask.overridePythonAttrs (old: rec {
version = "2.3.3";
src = old.src.override {
inherit version;
hash = "sha256-CcNHqSqn/0qOfzIGeV8w2CZlS684uHPQdEzVccpgnvw=";
};
});
werkzeug = super.werkzeug.overridePythonAttrs (old: rec {
version = "2.3.7";
src = old.src.override {
inherit version;
hash = "sha256-K4wORHtLnbzIXdl7butNy69si2w74L1lTiVVPgohV9g=";
};
disabledTests = old.disabledTests ++ [
"test_response_body"
];
});
};
};

odoo_version = "16.0";
odoo_release = "20231024";
in python.pkgs.buildPythonApplication rec {
pname = "odoo";
version = "${odoo_version}.${odoo_release}";
Expand All @@ -41,13 +21,10 @@ in python.pkgs.buildPythonApplication rec {
# latest release is at https://github.com/odoo/docker/blob/master/16.0/Dockerfile
src = fetchzip {
url = "https://nightly.odoo.com/${odoo_version}/nightly/src/odoo_${version}.zip";
name = "${pname}-${version}";
hash = "sha256-Ux8RfA7kWLKissBBY5wrfL+aKKw++5BxjP3Vw0JAOsk="; # odoo
name = "odoo-${version}";
hash = "sha256-ICe5UOy+Ga81fE66SnIhRz3+JEEbGfoz7ag53mkG4UM="; # odoo
};

# needs some investigation
doCheck = false;

makeWrapperArgs = [
"--prefix" "PATH" ":" "${lib.makeBinPath [ wkhtmltopdf rtlcss ]}"
];
Expand All @@ -66,6 +43,7 @@ in python.pkgs.buildPythonApplication rec {
jinja2
libsass
lxml
lxml-html-clean
markupsafe
num2words
ofxparse
Expand Down Expand Up @@ -102,6 +80,7 @@ in python.pkgs.buildPythonApplication rec {
dontStrip = true;

passthru = {
updateScript = ./update.sh;
tests = {
inherit (nixosTests) odoo;
};
Expand Down
32 changes: 32 additions & 0 deletions pkgs/by-name/od/odoo16/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/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