This repository has been archived by the owner on May 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We need to have `yq` installed before we can 'make', as we now use it for a version check in the build. But, we may not have golang installed. Add a script that installs `yq` via curl'ing from the github releases. This was cloned from the function in the tests repo .ci scripts that perform the same action. Signed-off-by: Graham Whaley <[email protected]>
- Loading branch information
Graham Whaley
committed
Oct 30, 2018
1 parent
58ce1b8
commit cbf7fb2
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Copyright (c) 2018 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
# If we fail for any reason a message will be displayed | ||
die() { | ||
msg="$*" | ||
echo "ERROR: $msg" >&2 | ||
exit 1 | ||
} | ||
|
||
# Install the yq yaml query package from the mikefarah github repo | ||
# Install via binary download, as we may not have golang installed at this point | ||
function install_yq() { | ||
GOPATH=${GOPATH:-${HOME}/go} | ||
local yq_path="${GOPATH}/bin/yq" | ||
local yq_pkg="github.com/mikefarah/yq" | ||
[ -x "${GOPATH}/bin/yq" ] && return | ||
|
||
read -r -a sysInfo <<< "$(uname -sm)" | ||
|
||
case "${sysInfo[0]}" in | ||
"Linux" | "Darwin") | ||
goos="${sysInfo[0],}" | ||
;; | ||
"*") | ||
die "OS ${sysInfo[0]} not supported" | ||
;; | ||
esac | ||
|
||
case "${sysInfo[1]}" in | ||
"aarch64") | ||
goarch=arm64 | ||
;; | ||
"ppc64le") | ||
goarch=ppc64le | ||
;; | ||
"x86_64") | ||
goarch=amd64 | ||
;; | ||
"s390x") | ||
goarch=s390x | ||
;; | ||
"*") | ||
die "Arch ${sysInfo[1]} not supported" | ||
;; | ||
esac | ||
|
||
mkdir -p "${GOPATH}/bin" | ||
|
||
# Workaround to get latest release from github (to not use github token). | ||
# Get the redirection to latest release on github. | ||
yq_latest_url=$(curl -Ls -o /dev/null -w %{url_effective} "https://${yq_pkg}/releases/latest") | ||
# The redirected url should include the latest release version | ||
# https://github.com/mikefarah/yq/releases/tag/<VERSION-HERE> | ||
yq_version=$(basename "${yq_latest_url}") | ||
|
||
local yq_url="https://${yq_pkg}/releases/download/${yq_version}/yq_${goos}_${goarch}" | ||
curl -o "${yq_path}" -L ${yq_url} | ||
chmod +x ${yq_path} | ||
|
||
if ! command -v "${yq_path}" >/dev/null; then | ||
die "Cannot not get ${yq_path} executable" | ||
fi | ||
} | ||
|
||
install_yq |