1717# specific language governing permissions and limitations
1818# under the License.
1919
20+ NEW_VERSIONING_CUTOVER_MAJOR_VERSION=24
21+
2022function getTemplateVersion() {
2123 projVersion=$1
2224 version=" $( cut -d' -' -f1 <<< " $projVersion" ) "
2325 subversion1=" $( cut -d' .' -f1 <<< " $version" ) "
2426 subversion2=" $( cut -d' .' -f2 <<< " $version" ) "
2527 minorversion=" $( cut -d' .' -f3 <<< " $version" ) "
26- securityversion=" $( cut -d' .' -f4 <<< " $version" ) "
2728 export CS_VERSION=" ${subversion1} " ." ${subversion2} "
2829 export CS_MINOR_VERSION=" ${minorversion} "
2930 export VERSION=" ${CS_VERSION} .${CS_MINOR_VERSION} "
31+ if [[ " $subversion1 " -ge " $NEW_VERSIONING_CUTOVER_MAJOR_VERSION " ]]; then
32+ # New versioning (major.minor.security): the third component is the
33+ # security release itself, there is no separate patch component.
34+ export FULL_VERSION=" ${VERSION} "
35+ else
36+ # Legacy versioning (major.minor.patch.security)
37+ securityversion=" $( cut -d' .' -f4 <<< " $version" ) "
38+ export FULL_VERSION=" ${VERSION} .${securityversion} "
39+ fi
3040 export CS_SYSTEMTEMPLATE_REPO=" https://download.cloudstack.org/systemvm/"
3141}
3242
@@ -64,7 +74,7 @@ function getChecksum() {
6474
6575function createMetadataFile() {
6676 local fileData=$( cat " $SOURCEFILE " )
67- echo -e " [" default" ]\nversion = $VERSION . ${securityversion} \ndownloadrepository = $CS_SYSTEMTEMPLATE_REPO \n" >> " $METADATAFILE "
77+ echo -e " [" default" ]\nversion = $FULL_VERSION \ndownloadrepository = $CS_SYSTEMTEMPLATE_REPO \n" >> " $METADATAFILE "
6878 for template in " ${templates[@]} "
6979 do
7080 section=" ${template%%:* } "
@@ -81,27 +91,30 @@ function createMetadataFile() {
8191 done
8292}
8393
84- declare -a templates
85- getTemplateVersion $1
86- declare -A template_specs=(
87- [kvm-x86_64]=" x86_64-kvm.qcow2.bz2"
88- [kvm-aarch64]=" aarch64-kvm.qcow2.bz2"
89- [vmware]=" x86_64-vmware.ova"
90- [xenserver]=" x86_64-xen.vhd.bz2"
91- [hyperv]=" x86_64-hyperv.vhd.zip"
92- [lxc]=" x86_64-kvm.qcow2.bz2"
93- [ovm3]=" x86_64-ovm.raw.bz2"
94- )
94+ # Guard so the file can be sourced (e.g. by tests) without running the steps below.
95+ if [[ " ${BASH_SOURCE[0]} " == " ${0} " ]]; then
96+ declare -a templates
97+ getTemplateVersion $1
98+ declare -A template_specs=(
99+ [kvm-x86_64]=" x86_64-kvm.qcow2.bz2"
100+ [kvm-aarch64]=" aarch64-kvm.qcow2.bz2"
101+ [vmware]=" x86_64-vmware.ova"
102+ [xenserver]=" x86_64-xen.vhd.bz2"
103+ [hyperv]=" x86_64-hyperv.vhd.zip"
104+ [lxc]=" x86_64-kvm.qcow2.bz2"
105+ [ovm3]=" x86_64-ovm.raw.bz2"
106+ )
95107
96- templates=()
97- for key in " ${! template_specs[@]} " ; do
98- url=" ${CS_SYSTEMTEMPLATE_REPO} /${CS_VERSION} /systemvmtemplate-$VERSION -${template_specs[$key]} "
99- templates+=(" $key :$url " )
100- done
108+ templates=()
109+ for key in " ${! template_specs[@]} " ; do
110+ url=" ${CS_SYSTEMTEMPLATE_REPO} /${CS_VERSION} /systemvmtemplate-$VERSION -${template_specs[$key]} "
111+ templates+=(" $key :$url " )
112+ done
101113
102- PARENTPATH=" $( cd -- " $( dirname " $0 " ) " > /dev/null 2>&1 ; pwd -P ) /dist/systemvm-templates/"
103- mkdir -p " $PARENTPATH "
104- METADATAFILE=" ${PARENTPATH} metadata.ini"
105- echo > " $METADATAFILE "
106- SOURCEFILE=" ${PARENTPATH} sha512sum.txt"
107- createMetadataFile
114+ PARENTPATH=" $( cd -- " $( dirname " $0 " ) " > /dev/null 2>&1 ; pwd -P ) /dist/systemvm-templates/"
115+ mkdir -p " $PARENTPATH "
116+ METADATAFILE=" ${PARENTPATH} metadata.ini"
117+ echo > " $METADATAFILE "
118+ SOURCEFILE=" ${PARENTPATH} sha512sum.txt"
119+ createMetadataFile
120+ fi
0 commit comments