Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 39 additions & 28 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,56 @@
name: cloudmonkey
version: git
# define the tag anchor on the allowed 'version' field
version: &release_tag 6.4.0
summary: Apache CloudStack CLI
description: |
An CLI and interactive shell that simplifies configuration and management of
A CLI and interactive shell that simplifies configuration and management of
Apache CloudStack, the opensource IAAS cloud computing platform.

base: core18
base: core22
license: Apache-2.0
grade: stable
confinement: strict
adopt-info: cloudmonkey

apps:
cloudmonkey:
command: bin/cmk
plugs:
- home
- network
plugs: [home, network]

parts:
cloudmonkey:
source: .
source-type: git
source-tag: 6.1.0
plugin: go
go-importpath: github.com/apache/cloudstack-cloudmonkey
build-packages:
- gcc
- make
- file
- git
source: &cmk_repo https://github.com/apache/cloudstack-cloudmonkey.git
source-type: git
source-tag: *release_tag
source-depth: 1

build-snaps: [go]
build-packages: [git, file, binutils]

build-environment:
- CMK_REPO: *cmk_repo
- CMK_TAG: *release_tag

override-pull: |
set -euo pipefail
craftctl default
REPO="${CMK_REPO}"
TAG="${CMK_TAG}"
FULL_SHA="$(git ls-remote "${REPO}" "refs/tags/${TAG}" | awk '{print $1}')"
SHORT_SHA="${FULL_SHA:0:7}"
: "${SHORT_SHA:=unknown}"
echo "${SHORT_SHA}" > "$CRAFT_PART_SRC/.remote-sha"
craftctl set version="${TAG}-${SHORT_SHA}"

override-build: |
set -eu
go version
go mod vendor
git checkout -- .
git status
git rev-parse HEAD
go build -mod=vendor -ldflags="-s -w -X main.GitSHA=$(git rev-parse --short HEAD) -X main.BuildDate=$(date +%FT%T%z)" -o cmk cmk.go
file cmk
chmod +x cmk
./cmk -v
mkdir -p $SNAPCRAFT_PART_INSTALL/bin
mv cmk $SNAPCRAFT_PART_INSTALL/bin/
strip --remove-section=.comment --remove-section=.note $SNAPCRAFT_PART_INSTALL/bin/cmk
set -euo pipefail
cd "$CRAFT_PART_SRC"
SHORT_SHA="$(cat .remote-sha 2>/dev/null || echo unknown)"
BUILD_DATE="$(date +%FT%T%z)"
go mod vendor || true
go build -trimpath \
-ldflags "-s -w -X main.GitSHA=${SHORT_SHA} -X main.BuildDate=${BUILD_DATE}" \
-o cmk cmk.go
install -Dm0755 cmk "$CRAFT_PART_INSTALL/bin/cmk"
strip --remove-section=.comment --remove-section=.note "$CRAFT_PART_INSTALL/bin/cmk" || true