You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2022/03/08 20:16:23 UTC

[cloudstack] branch main updated: Adapt script to bash version 3 (#6069)

This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/main by this push:
     new 8f427f6  Adapt script to bash version 3 (#6069)
8f427f6 is described below

commit 8f427f601a453de9070f8dbc34fb2724479f315f
Author: Pearl Dsilva <pe...@gmail.com>
AuthorDate: Wed Mar 9 01:45:47 2022 +0530

    Adapt script to bash version 3 (#6069)
    
    This PR fixes: #6060
    Bash version 3 does not have support for associative arrays. Hence during the packaging phase the metadata.ini file created (on osx) isn't in proper format as the script used to generate it i.e., templateConfig.sh made use of associative arrays - which is supported from bash v4 onward. This eventually leads failure to deploy DB on OSX.
    
    This PR modifies the script to work on systems using bash v3.
---
 engine/schema/templateConfig.sh | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/engine/schema/templateConfig.sh b/engine/schema/templateConfig.sh
index 891c73d..fb12ad7 100644
--- a/engine/schema/templateConfig.sh
+++ b/engine/schema/templateConfig.sh
@@ -55,28 +55,27 @@ function getChecksum() {
 function createMetadataFile() {
   local fileData=$(cat $SOURCEFILE)
   echo -e "["default"]\nversion = $VERSION.${securityversion}\n" >> $METADATAFILE
-  for i in "${!templates[@]}"
+  for template in "${templates[@]}"
   do
-    section="$i"
-    hvName=$(getGenericName $i)
+    section="${template%%:*}"
+    hvName=$(getGenericName $section)
 
-    templatename="systemvm-${i}-${VERSION}"
+    templatename="systemvm-${section}-${VERSION}"
     checksum=$(getChecksum "$fileData" "$VERSION-$hvName")
-    downloadurl="${templates[$i]}"
+    downloadurl="${template#*:}"
     filename=$(echo ${downloadurl##*'/'})
     echo -e "["$section"]\ntemplatename = $templatename\nchecksum = $checksum\ndownloadurl = $downloadurl\nfilename = $filename\n" >> $METADATAFILE
   done
 }
 
-declare -A templates
+declare -a templates
 getTemplateVersion $1
-templates=( ["kvm"]="https://download.cloudstack.org/systemvm/${CS_VERSION}/systemvmtemplate-$VERSION-kvm.qcow2.bz2"
-            ["vmware"]="https://download.cloudstack.org/systemvm/${CS_VERSION}/systemvmtemplate-$VERSION-vmware.ova"
-            ["xenserver"]="https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$VERSION-xen.vhd.bz2"
-            ["hyperv"]="https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$VERSION-hyperv.vhd.zip"
-            ["lxc"]="https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$VERSION-kvm.qcow2.bz2"
-            ["ovm3"]="https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$VERSION-ovm.raw.bz2" )
-
+templates=( "kvm:https://download.cloudstack.org/systemvm/${CS_VERSION}/systemvmtemplate-$VERSION-kvm.qcow2.bz2"
+            "vmware:https://download.cloudstack.org/systemvm/${CS_VERSION}/systemvmtemplate-$VERSION-vmware.ova"
+            "xenserver:https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$VERSION-xen.vhd.bz2"
+            "hyperv:https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$VERSION-hyperv.vhd.zip"
+            "lxc:https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$VERSION-kvm.qcow2.bz2"
+            "ovm3:https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$VERSION-ovm.raw.bz2" )
 
 PARENTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/dist/systemvm-templates/"
 mkdir -p $PARENTPATH