Skip to content

Commit d48355b

Browse files
committed
odoo: update script for all versions
Signed-off-by: phanirithvij <[email protected]>
1 parent 34e7279 commit d48355b

File tree

6 files changed

+110
-7
lines changed

6 files changed

+110
-7
lines changed

pkgs/by-name/od/odoo/update.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
#!/usr/bin/env nix-shell
22
#!nix-shell -i bash -p curl gnused nix coreutils nix-prefetch
3+
# shellcheck shell=bash
34

45
set -euo pipefail
56

6-
VERSION="${1:-18.0}" # must be incremented manually
7-
echo $VERSION
7+
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
8+
PKG=$(basename "$SCRIPT_DIR")
9+
10+
LATEST="18" # increment manually
11+
VERSION="${PKG/#odoo}"
12+
VERSION="${VERSION:-$LATEST}.0"
813

914
RELEASE="$(
1015
curl "https://nightly.odoo.com/$VERSION/nightly/src/" |
@@ -13,15 +18,15 @@ RELEASE="$(
1318
)"
1419

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

1823
if [[ "$currentVersion" == "$latestVersion" ]]; then
19-
echo "odoo is up-to-date: $currentVersion"
24+
echo "$PKG is up-to-date: $currentVersion"
2025
exit 0
2126
fi
2227

23-
cd "$(dirname "${BASH_SOURCE[0]}")"
28+
cd "$SCRIPT_DIR"
2429

2530
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
26-
sed -ri "s|odoo_version = .+;|odoo_version = \"$VERSION\"|" package.nix
27-
sed -ri "s|odoo_release = .+;|odoo_release = \"$RELEASE\"|" package.nix
31+
sed -ri "s|odoo_version = .+|odoo_version = \"$VERSION\";|" package.nix
32+
sed -ri "s|odoo_release = .+|odoo_release = \"$RELEASE\";|" package.nix

pkgs/by-name/od/odoo15/package.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ in python.pkgs.buildPythonApplication rec {
9898
dontStrip = true;
9999

100100
passthru = {
101+
updateScript = ./update.sh;
101102
tests = { inherit (nixosTests) odoo15; };
102103
};
103104

pkgs/by-name/od/odoo15/update.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env nix-shell
2+
#!nix-shell -i bash -p curl gnused nix coreutils nix-prefetch
3+
# shellcheck shell=bash
4+
5+
set -euo pipefail
6+
7+
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
8+
PKG=$(basename "$SCRIPT_DIR")
9+
10+
LATEST="18" # increment manually
11+
VERSION="${PKG/#odoo}"
12+
VERSION="${VERSION:-$LATEST}.0"
13+
14+
RELEASE="$(
15+
curl "https://nightly.odoo.com/$VERSION/nightly/src/" |
16+
sed -nE 's/.*odoo_'"$VERSION"'.(20[0-9]{6}).tar.gz.*/\1/p' |
17+
tail -n 1
18+
)"
19+
20+
latestVersion="$VERSION.$RELEASE"
21+
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; $PKG.version or (lib.getVersion $PKG)" | tr -d '"')
22+
23+
if [[ "$currentVersion" == "$latestVersion" ]]; then
24+
echo "$PKG is up-to-date: $currentVersion"
25+
exit 0
26+
fi
27+
28+
cd "$SCRIPT_DIR"
29+
30+
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
31+
sed -ri "s|odoo_version = .+|odoo_version = \"$VERSION\";|" package.nix
32+
sed -ri "s|odoo_release = .+|odoo_release = \"$RELEASE\";|" package.nix

pkgs/by-name/od/odoo16/package.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ in python.pkgs.buildPythonApplication rec {
8080
dontStrip = true;
8181

8282
passthru = {
83+
updateScript = ./update.sh;
8384
tests = {
8485
inherit (nixosTests) odoo;
8586
};

pkgs/by-name/od/odoo16/update.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env nix-shell
2+
#!nix-shell -i bash -p curl gnused nix coreutils nix-prefetch
3+
# shellcheck shell=bash
4+
5+
set -euo pipefail
6+
7+
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
8+
PKG=$(basename "$SCRIPT_DIR")
9+
10+
LATEST="18" # increment manually
11+
VERSION="${PKG/#odoo}"
12+
VERSION="${VERSION:-$LATEST}.0"
13+
14+
RELEASE="$(
15+
curl "https://nightly.odoo.com/$VERSION/nightly/src/" |
16+
sed -nE 's/.*odoo_'"$VERSION"'.(20[0-9]{6}).tar.gz.*/\1/p' |
17+
tail -n 1
18+
)"
19+
20+
latestVersion="$VERSION.$RELEASE"
21+
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; $PKG.version or (lib.getVersion $PKG)" | tr -d '"')
22+
23+
if [[ "$currentVersion" == "$latestVersion" ]]; then
24+
echo "$PKG is up-to-date: $currentVersion"
25+
exit 0
26+
fi
27+
28+
cd "$SCRIPT_DIR"
29+
30+
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
31+
sed -ri "s|odoo_version = .+|odoo_version = \"$VERSION\";|" package.nix
32+
sed -ri "s|odoo_release = .+|odoo_release = \"$RELEASE\";|" package.nix

pkgs/by-name/od/odoo17/update.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env nix-shell
2+
#!nix-shell -i bash -p curl gnused nix coreutils nix-prefetch
3+
# shellcheck shell=bash
4+
5+
set -euo pipefail
6+
7+
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
8+
PKG=$(basename "$SCRIPT_DIR")
9+
10+
LATEST="18" # increment manually
11+
VERSION="${PKG/#odoo}"
12+
VERSION="${VERSION:-$LATEST}.0"
13+
14+
RELEASE="$(
15+
curl "https://nightly.odoo.com/$VERSION/nightly/src/" |
16+
sed -nE 's/.*odoo_'"$VERSION"'.(20[0-9]{6}).tar.gz.*/\1/p' |
17+
tail -n 1
18+
)"
19+
20+
latestVersion="$VERSION.$RELEASE"
21+
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; $PKG.version or (lib.getVersion $PKG)" | tr -d '"')
22+
23+
if [[ "$currentVersion" == "$latestVersion" ]]; then
24+
echo "$PKG is up-to-date: $currentVersion"
25+
exit 0
26+
fi
27+
28+
cd "$SCRIPT_DIR"
29+
30+
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
31+
sed -ri "s|odoo_version = .+|odoo_version = \"$VERSION\";|" package.nix
32+
sed -ri "s|odoo_release = .+|odoo_release = \"$RELEASE\";|" package.nix

0 commit comments

Comments
 (0)