Skip to content

Commit

Permalink
odoo: update script for all versions
Browse files Browse the repository at this point in the history
Signed-off-by: phanirithvij <phanirithvij2000@gmail.com>
  • Loading branch information
phanirithvij committed Oct 23, 2024
1 parent 34e7279 commit d48355b
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 7 deletions.
19 changes: 12 additions & 7 deletions pkgs/by-name/od/odoo/update.sh
Original file line number Diff line number Diff line change
@@ -1,10 +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="${1:-18.0}" # must be incremented manually
echo $VERSION
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 @@ -13,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 --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
sed -ri "s|odoo_version = .+|odoo_version = \"$VERSION\";|" package.nix
sed -ri "s|odoo_release = .+|odoo_release = \"$RELEASE\";|" package.nix
1 change: 1 addition & 0 deletions pkgs/by-name/od/odoo15/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -98,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
1 change: 1 addition & 0 deletions pkgs/by-name/od/odoo16/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -80,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
32 changes: 32 additions & 0 deletions pkgs/by-name/od/odoo17/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

0 comments on commit d48355b

Please sign in to comment.