about summary refs log tree commit diff
path: root/pkgs/by-name/od/odoo/update.sh
blob: e9c50ccb508157340a55b7e3bef0ce8d45c29484 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnused nix coreutils nix-prefetch

set -euo pipefail

VERSION="17.0" # must be incremented manually

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 ./. {}; odoo.version or (lib.getVersion odoo)" | tr -d '"')

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

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

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