@@ -32,12 +32,13 @@ source $script_dir/common-functions.sh
32
32
33
33
usage () {
34
34
if [[ $# -gt 0 ]]; then echo " $* " >&2 ; fi
35
- echo " Usage: ${script_name} [-nF] [-u <url>] <year> <version>"
36
- echo " year the 4-digit year the sqlite version was released"
35
+ echo " Usage: ${script_name} [-nF] [-u <url>] [-y <year>] <version>"
37
36
echo " version the sqlite version as <major>.<minor>[.<patch>]"
38
37
echo " the patch level defaults to 0"
39
38
echo " -n dry-run: evaluate arguments but d not change anything"
40
39
echo " -u url download the tarball from the specified url"
40
+ echo " -y year the 4-digit year the sqlite version was released - required"
41
+ echo " if a full url is not specified and the year is not this year"
41
42
echo " -F force execution even if not in external/sqlite"
42
43
echo
43
44
echo " Example:"
@@ -47,29 +48,30 @@ usage() {
47
48
dry_run=
48
49
force=
49
50
src_tarball_url=
50
- while getopts " hnFu:" option; do
51
+ year=$( date +%Y)
52
+ while getopts " hnFu:y:" option; do
51
53
case $option in
52
54
h) usage; exit 0;;
53
55
n) dry_run=y;;
54
56
u) src_tarball_url=$OPTARG ;;
57
+ y) year=$OPTARG ;;
55
58
F) force=y;;
56
59
* ) usage " unknown switch" ; exit 1;;
57
60
esac
58
61
done
59
62
shift $(( OPTIND- 1 ))
60
63
61
- if [[ $# -lt 2 ]]; then
64
+ if [[ $# -lt 1 ]]; then
62
65
usage; die " missing required arguments"
63
- elif [[ $# -gt 2 ]]; then
66
+ elif [[ $# -gt 1 ]]; then
64
67
die " extra arguments on command line"
65
68
fi
66
- year=$1
67
- validate_year " $year " || die " invalid year"
68
- sqlite_release=$( normalize_release " $2 " ) || die " invalid release"
69
+ sqlite_release=$( normalize_release " $1 " ) || die " invalid release"
69
70
70
71
sqlite_base=" sqlite-autoconf-${sqlite_release} "
71
72
sqlite_file=" ${sqlite_base} .tar.gz"
72
73
if [[ -z $src_tarball_url ]]; then
74
+ validate_year " $year " || die " invalid year"
73
75
src_tarball_url=" https://www.sqlite.org/$year /${sqlite_file} "
74
76
fi
75
77
0 commit comments