Skip to content

Commit

Permalink
snap: pull and install yq from github
Browse files Browse the repository at this point in the history
osbuilder shares the yq binary with the container that generates the image,
unfortunately the snap version of yq is not a static binary hence it's not
compatible with the alpine container.

Signed-off-by: Julio Montes <julio.montes@intel.com>
  • Loading branch information
Julio Montes committed Jul 9, 2019
1 parent 89f2c80 commit 335b884
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions snap/snapcraft.yaml
Expand Up @@ -10,19 +10,47 @@ grade: stable
confinement: classic

parts:
yq:
plugin: nil
prime:
- -*
build-packages:
- curl
override-build: |
yq_path="yq"
yq_pkg="github.com/mikefarah/yq"
goos="linux"
case "$(uname -m)" in
aarch64) goarch="arm64";;
ppc64le) goarch="ppc64le";;
x86_64) goarch="amd64";;
s390x) goarch="s390x";;
*) echo "unsupported architecture: $(uname -m)"; exit 1;;
esac
# 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}")
yq_url="https://${yq_pkg}/releases/download/${yq_version}/yq_${goos}_${goarch}"
curl -o "${yq_path}" -LSsf ${yq_url}
chmod +x ${yq_path}
go:
after: [yq]
override-build: |
yq=$(realpath ../../yq/build/yq)
versions_url=https://raw.githubusercontent.com/kata-containers/runtime/${SNAPCRAFT_PROJECT_VERSION}/versions.yaml
version="$(curl -sSL ${versions_url} | yq r - languages.golang.version)"
version="$(curl -sSL ${versions_url} | ${yq} r - languages.golang.version)"
curl -LO https://dl.google.com/go/go${version}.src.tar.gz
tar -xf go${version}.src.tar.gz --strip-components=1
cd src && env GOROOT_BOOTSTRAP=$(go env GOROOT | tr -d '\n') ./make.bash
build-packages:
- golang-go
- g++
- curl
build-snaps:
- yq
plugin: nil
prime:
- -*
Expand Down

0 comments on commit 335b884

Please sign in to comment.