Debian Codegraph @

upgrade/check.sh

raw
1 #!/bin/sh
2
3 set -e
4
5 cd "$(dirname "$0")/.."
6
7 CURRENT_VERSION=$(grep '#define SQLITE_VERSION ' sqlite3-binding.c | grep -o '[0-9]*\.[0-9]*\.[0-9]*')
8
9 if [ -z "$CURRENT_VERSION" ]; then
10 echo "Error: Could not extract current SQLite version from sqlite3-binding.c"
11 exit 1
12 fi
13
14 LATEST_VERSION=$(curl -fsSL https://www.sqlite.org/download.html \
15 | grep -o 'sqlite-amalgamation-[0-9]*\.zip' \
16 | head -n 1 \
17 | sed 's/sqlite-amalgamation-\([0-9]\)\([0-9][0-9]\)\([0-9][0-9]\)[0-9][0-9]\.zip/\1.\2.\3/' \
18 | sed 's/\.0*\([0-9]\)/.\1/g')
19
20 if [ -z "$LATEST_VERSION" ]; then
21 echo "Error: Could not extract latest SQLite version from sqlite.org"
22 exit 1
23 fi
24
25 echo "Current version: $CURRENT_VERSION"
26 echo "Latest version: $LATEST_VERSION"
27
28 if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then
29 echo "Already up to date."
30 exit 0
31 fi
32
33 echo "Upgrade available: $CURRENT_VERSION -> $LATEST_VERSION"
34 echo "Run upgrade/upgrade.sh to upgrade."
35 exit 1