Skip to content

Commit 79e269e

Browse files
committed
update-template-oraclelinux.sh: reword version to major version, release to minor version
Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
1 parent 702e5d3 commit 79e269e

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

hack/update-template-oraclelinux.sh

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ function oraclelinux_print_help() {
1414
$(basename "${BASH_SOURCE[0]}"): Update the Oracle Linux image location in the specified templates
1515
1616
Usage:
17-
$(basename "${BASH_SOURCE[0]}") [--version <version>] <template.yaml>...
17+
$(basename "${BASH_SOURCE[0]}") [--version-major <major version>] <template.yaml>...
1818
1919
Description:
2020
This script updates the Oracle Linux image location in the specified templates.
2121
Image location basename format:
2222
23-
OL<version>U<release>_<arch>-kvm[-cloud]-b<build number>.qcow2
23+
OL<major version>U<minor version>_<arch>-kvm[-cloud]-b<build number>.qcow2
2424
2525
Published Oracle Linux image information is fetched from the following URLs:
2626
@@ -38,23 +38,23 @@ Examples:
3838
Update the Oracle Linux image location in templates/**.yaml:
3939
$ $(basename "${BASH_SOURCE[0]}") templates/**.yaml
4040
41-
Update the Oracle Linux image location to version 9 in ~/.lima/oraclelinux/lima.yaml:
42-
$ $(basename "${BASH_SOURCE[0]}") --version 9 ~/.lima/oraclelinux/lima.yaml
41+
Update the Oracle Linux image location to major version 9 in ~/.lima/oraclelinux/lima.yaml:
42+
$ $(basename "${BASH_SOURCE[0]}") --version-major 9 ~/.lima/oraclelinux/lima.yaml
4343
$ limactl factory-reset oraclelinux
4444
4545
Flags:
46-
--version <version> Use the specified Oracle Linux <version>.
47-
The version must be 7+ for x86_64 or 8+ for aarch64.
48-
-h, --help Print this help message
46+
--version-major <major version> Use the specified Oracle Linux <major version>.
47+
The major version must be 7+ for x86_64 or 8+ for aarch64.
48+
-h, --help Print this help message
4949
HELP
5050
}
5151

5252
# print the URL spec for the given location
5353
function oraclelinux_url_spec_from_location() {
5454
local location=$1 jq_filter url_spec
5555
jq_filter='capture("
56-
^https://yum\\.oracle\\.com/templates/OracleLinux/OL(?<path_version>\\d+)/u(?<path_release>\\d+)/(?<path_arch>[^/]+)/
57-
OL(?<version>\\d+)U(?<release>\\d+)_(?<arch>[^-]+)-(?<type>[^-]+)(?<cloud>-cloud)?-b(?<build_number>\\d+)\\.(?<file_extension>.*)$
56+
^https://yum\\.oracle\\.com/templates/OracleLinux/OL(?<path_major_version>\\d+)/u(?<path_minor_version>\\d+)/(?<path_arch>[^/]+)/
57+
OL(?<major_version>\\d+)U(?<minor_version>\\d+)_(?<arch>[^-]+)-(?<type>[^-]+)(?<cloud>-cloud)?-b(?<build_number>\\d+)\\.(?<file_extension>.*)$
5858
";"x")
5959
'
6060
url_spec=$(jq -e -r "${jq_filter}" <<<"\"${location}\"")
@@ -63,7 +63,7 @@ function oraclelinux_url_spec_from_location() {
6363
6464
readonly oraclelinux_jq_filter_json_url='
6565
"https://yum.oracle.com/templates/OracleLinux/" +
66-
"ol\(.path_version)\(if .path_arch != "x86_64" then "_" + .path_arch else "" end)\(.cloud // "")-template.json"
66+
"ol\(.path_major_version)\(if .path_arch != "x86_64" then "_" + .path_arch else "" end)\(.cloud // "")-template.json"
6767
'
6868
6969
function oraclelinux_json_url_from_url_spec() {
@@ -95,7 +95,7 @@ function oraclelinux_latest_image_entry_for_url_spec() {
9595
function oraclelinux_cache_key_for_image_kernel() {
9696
local location=$1 overriding=${3:-"{}"} url_spec
9797
url_spec=$(oraclelinux_url_spec_from_location "${location}" | jq -r ". + ${overriding}")
98-
jq -r '["oraclelinux", .path_version, .type, .cloud // empty, .arch, .file_extension] | join(":")' <<<"${url_spec}"
98+
jq -r '["oraclelinux", .path_major_version, .type, .cloud // empty, .arch, .file_extension] | join(":")' <<<"${url_spec}"
9999
}
100100
101101
function oraclelinux_image_entry_for_image_kernel() {
@@ -141,27 +141,27 @@ while [[ $# -gt 0 ]]; do
141141
exit 0
142142
;;
143143
-d | --debug) set -x ;;
144-
--version)
144+
--version-major)
145145
if [[ -n $2 && $2 != -* ]]; then
146146
overriding=$(
147-
path_version="${2}"
148-
[[ ${path_version} =~ ^[0-9]+$ ]] || error_exit "Oracle Linux version must be a number"
149-
[[ ${path_version} -eq 7 ]] && echo 'Oracle Linux version 7 exists only for x86_64. It may fail for aarch64.' >&2
150-
[[ ${path_version} -gt 7 ]] || error_exit "Oracle Linux version must be 7+ for x86_64 or 8+ for aarch64"
151-
json_vars path_version <<<"${overriding}"
147+
path_major_version="${2}"
148+
[[ ${path_major_version} =~ ^[0-9]+$ ]] || error_exit "Oracle Linux major version must be a number"
149+
[[ ${path_major_version} -eq 7 ]] && echo 'Oracle Linux major version 7 exists only for x86_64. It may fail for aarch64.' >&2
150+
[[ ${path_major_version} -gt 7 ]] || error_exit "Oracle Linux major version must be 7+ for x86_64 or 8+ for aarch64"
151+
json_vars path_major_version <<<"${overriding}"
152152
)
153153
shift
154154
else
155-
error_exit "--version requires a value"
155+
error_exit "--version-major requires a value"
156156
fi
157157
;;
158-
--version=*)
158+
--version-major=*)
159159
overriding=$(
160-
path_version="${1#*=}"
161-
[[ ${path_version} =~ ^[0-9]+$ ]] || error_exit "Oracle Linux version must be a number"
162-
[[ ${path_version} -eq 7 ]] && echo 'Oracle Linux version 7 exists only for x86_64. It may fail for aarch64.' >&2
163-
[[ ${path_version} -gt 7 ]] || error_exit "Oracle Linux version must be 7+ for x86_64 or 8+ for aarch64"
164-
json_vars path_version <<<"${overriding}"
160+
path_major_version="${1#*=}"
161+
[[ ${path_major_version} =~ ^[0-9]+$ ]] || error_exit "Oracle Linux major version must be a number"
162+
[[ ${path_major_version} -eq 7 ]] && echo 'Oracle Linux major version 7 exists only for x86_64. It may fail for aarch64.' >&2
163+
[[ ${path_major_version} -gt 7 ]] || error_exit "Oracle Linux major version must be 7+ for x86_64 or 8+ for aarch64"
164+
json_vars path_major_version <<<"${overriding}"
165165
)
166166
;;
167167
*.yaml) templates+=("$1") ;;

0 commit comments

Comments
 (0)