diff options
author | Lee Shombert <shombert@google.com> | 2024-03-25 15:35:08 -0700 |
---|---|---|
committer | Lee Shombert <shombert@google.com> | 2024-03-25 15:35:08 -0700 |
commit | 152fb62b3e5d8b9c8700158bb4972656ba1e2f6f (patch) | |
tree | a54552742723c4b4d482a6c3c7967695d4708af5 | |
parent | e83637dc68330081c82b319681e075d6cf1702a0 (diff) | |
download | sqlite-152fb62b3e5d8b9c8700158bb4972656ba1e2f6f.tar.gz |
Update the sqlite build scripts
UPDATE-SOURCE now accepts a url on the command line. This is
important when the canonical url does not work (as is the case when
using an unreleased sqlite tarball).
The version number can now be specified as four integers, which is
useful when using an unreleased sqlite tarball.
Some common functions used by UPDATE-SOURCE and REBUILD-PATCH have
been moved into shared file.
Test: The updated scripts were used to install an unreleased sqlite
tarball from the 3.44.2 train.
Bug: 323176655
Change-Id: I674f9079407df1e9e00541cbed92041f0ded2f3e
-rwxr-xr-x | REBUILD-ANDROID-PATCH.bash | 29 | ||||
-rwxr-xr-x | UPDATE-SOURCE.bash | 63 | ||||
-rwxr-xr-x | common-functions.sh | 68 |
3 files changed, 79 insertions, 81 deletions
diff --git a/REBUILD-ANDROID-PATCH.bash b/REBUILD-ANDROID-PATCH.bash index 53d0990..de7f58a 100755 --- a/REBUILD-ANDROID-PATCH.bash +++ b/REBUILD-ANDROID-PATCH.bash @@ -26,34 +26,7 @@ set -e script_name="$(basename "$0")" script_dir=$(dirname $(realpath ${BASH_SOURCE[0]})) -die() { - echo "$script_name: $*" - exit 1 -} - -echo_and_exec() { - echo " Running: $@" - "$@" -} - -# This function converts a release string like "3.42.0" to the canonical 7-digit -# format used by sqlite.org for downloads: "3420000". A hypothetical release -# number of 3.45.6 is converted to "3450600". A hypothetical release number of -# 3.45.17 is converted to "3451700". The last two digits are assumed to be -# "00" for now, as there are no known counter-examples. -function normalize_release { - local version=$1 - local -a fields - fields=($(echo "$version" | sed 's/\./ /g')) - if [[ ${#fields[*]} -lt 2 || ${#fields[*]} -gt 3 ]]; then - echo "cannot parse version: $version" - return 1 - elif [[ ${#fields[*]} -eq 2 ]]; then - fields+=(0) - fi - printf "%d%02d%02d00" ${fields[*]} - return 0 -} +source $script_dir/common-functions.sh if [[ $# -lt 1 ]]; then die "missing required arguments" diff --git a/UPDATE-SOURCE.bash b/UPDATE-SOURCE.bash index 24e3a1a..297799c 100755 --- a/UPDATE-SOURCE.bash +++ b/UPDATE-SOURCE.bash @@ -28,75 +28,30 @@ set -e script_name="$(basename "$0")" script_dir=$(dirname $(realpath ${BASH_SOURCE[0]})) +source $script_dir/common-functions.sh + usage() { if [[ $# -gt 0 ]]; then echo "$*" >&2; fi - echo "Usage: ${script_name} -nF <year> <version>" + echo "Usage: ${script_name} [-nF] [-u <url>] <year> <version>" echo " year the 4-digit year the sqlite version was released" echo " version the sqlite version as <major>.<minor>[.<patch>]" echo " the patch level defaults to 0" echo " -n dry-run: evaluate arguments but d not change anything" + echo " -u url download the tarball from the specified url" echo " -F force execution even if not in external/sqlite" echo echo "Example:" echo "${script_name} 2023 3.42" } -die() { - echo "$script_name: $*" - exit 1 -} - -echo_and_exec() { - echo " Running: $@" - "$@" -} - -validate_year() { - local year=$1 - if [[ "$year" =~ ^2[0-9][0-9][0-9]$ ]]; then - return 0; - else - return 1; - fi -} - -# This function converts a release string like "3.42.0" to the canonical 7-digit -# format used by sqlite.org for downloads: "3420000". A hypothetical release -# number of 3.45.6 is converted to "3450600". A hypothetical release number of -# 3.45.17 is converted to "3451700". The last two digits are assumed to be -# "00" for now, as there are no known counter-examples. -function normalize_release { - local version=$1 - local -a fields - fields=($(echo "$version" | sed 's/\./ /g')) - if [[ ${#fields[*]} -lt 2 || ${#fields[*]} -gt 3 ]]; then - echo "cannot parse version: $version" - return 1 - elif [[ ${#fields[*]} -eq 2 ]]; then - fields+=(0) - fi - printf "%d%02d%02d00" ${fields[*]} - return 0 -} - -function prettify_release { - local version=$1 - local patch=$((version % 100)) - version=$((version / 100)) - local minor=$((version % 100)) - version=$((version / 100)) - local major=$((version % 100)) - version=$((version / 100)) - # version now contains the generation number. - printf "%d.%d.%d" $version $major $minor -} - dry_run= force= -while getopts "hnF" option; do +src_tarball_url= +while getopts "hnFu:" option; do case $option in h) usage; exit 0;; n) dry_run=y;; + u) src_tarball_url=$OPTARG;; F) force=y;; *) usage "unknown switch"; exit 1;; esac @@ -114,7 +69,9 @@ sqlite_release=$(normalize_release "$2") || die "invalid release" sqlite_base="sqlite-autoconf-${sqlite_release}" sqlite_file="${sqlite_base}.tar.gz" -src_tarball_url="https://www.sqlite.org/$year/${sqlite_file}" +if [[ -z $src_tarball_url ]]; then + src_tarball_url="https://www.sqlite.org/$year/${sqlite_file}" +fi if [[ -n $dry_run ]]; then echo "fetching $src_tarball_url" diff --git a/common-functions.sh b/common-functions.sh new file mode 100755 index 0000000..91cb618 --- /dev/null +++ b/common-functions.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# +# Copyright (C) 2024 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Some common functions used by the source-update scripts. +# + +die() { + echo "$script_name: $*" + exit 1 +} + +echo_and_exec() { + echo " Running: $@" + "$@" +} + +validate_year() { + local year=$1 + if [[ "$year" =~ ^2[0-9][0-9][0-9]$ ]]; then + return 0; + else + return 1; + fi +} + +# This function converts a release string like "3.42.0" to the canonical 7-digit +# format used by sqlite.org for downloads: "3420000". A hypothetical release +# number of 3.45.6 is converted to "3450600". A hypothetical release number of +# 3.45.17 is converted to "3451700". The last two digits are assumed to be +# "00" for now, as there are no known counter-examples. +function normalize_release { + local version=$1 + local -a fields + fields=($(echo "$version" | sed 's/\./ /g')) + if [[ ${#fields[*]} -lt 2 || ${#fields[*]} -gt 4 ]]; then + echo "cannot parse version: $version" + return 1 + fi + if [[ ${#fields[*]} -eq 2 ]]; then fields+=(0); fi + if [[ ${#fields[*]} -eq 3 ]]; then fields+=(0); fi + printf "%d%02d%02d%02d" ${fields[*]} + return 0 +} + +function prettify_release { + local version=$1 + local patch=$((version % 100)) + version=$((version / 100)) + local minor=$((version % 100)) + version=$((version / 100)) + local major=$((version % 100)) + version=$((version / 100)) + # version now contains the generation number. + printf "%d.%d.%d" $version $major $minor +} |