File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -38,8 +38,28 @@ source hack/utils.sh
3838# invoked, so we are timeboxing it to 10 seconds. This shouldn't be the
3939# case with Packer installed from Hashicorp releases, which should give
4040# us a version number. This helps us distinguish the two Packer executables.
41- if (command -v packer && timeout 10 packer version) > /dev/null 2>&1 ; then exit 0; fi
4241
42+ if (command -v packer) > /dev/null 2>&1 ; then
43+ echo " Packer is already installed, checking version..."
44+ # if it's not the hashicorp packer, return "unexpected packer found"
45+ if ! (timeout 10 packer version) > /dev/null 2>&1 ; then
46+ echo " unexpected packer found" ;
47+ echo " downloading hashicorp packer version v1.9.5"
48+ fi
49+ existing_packer_version=$( packer version | head -1 | cut -d ' v' -f 2; exit 0)
50+ echo " existing packer version: $existing_packer_version "
51+ if [ " $existing_packer_version " != " $_version " ]; then
52+ echo " unsupported packer version ($existing_packer_version ) found"
53+ echo " current packer version: $existing_packer_version is not supported"
54+ echo " Downgrading packer to ${_version} "
55+ else
56+ echo " Packer version is as expected"
57+ echo " Packer version $existing_packer_version is already installed"
58+ exit 0
59+ fi
60+ fi
61+
62+ echo " Installing packer v${_version} in .local/bin"
4363mkdir -p .local/bin && cd .local/bin
4464
4565SED=" sed"
You can’t perform that action at this time.
0 commit comments