Skip to content

Commit ed5c043

Browse files
committed
snap: update tag and fix build with latest snapcraft version
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 7510f73 commit ed5c043

File tree

1 file changed

+39
-28
lines changed

1 file changed

+39
-28
lines changed

snap/snapcraft.yaml

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,56 @@
11
name: cloudmonkey
2-
version: git
2+
# define the tag anchor on the allowed 'version' field
3+
version: &release_tag 6.4.0
34
summary: Apache CloudStack CLI
45
description: |
5-
An CLI and interactive shell that simplifies configuration and management of
6+
A CLI and interactive shell that simplifies configuration and management of
67
Apache CloudStack, the opensource IAAS cloud computing platform.
78
8-
base: core18
9+
base: core22
910
license: Apache-2.0
1011
grade: stable
1112
confinement: strict
13+
adopt-info: cloudmonkey
1214

1315
apps:
1416
cloudmonkey:
1517
command: bin/cmk
16-
plugs:
17-
- home
18-
- network
18+
plugs: [home, network]
1919

2020
parts:
2121
cloudmonkey:
22-
source: .
23-
source-type: git
24-
source-tag: 6.1.0
2522
plugin: go
26-
go-importpath: github.com/apache/cloudstack-cloudmonkey
27-
build-packages:
28-
- gcc
29-
- make
30-
- file
31-
- git
23+
source: &cmk_repo https://github.com/apache/cloudstack-cloudmonkey.git
24+
source-type: git
25+
source-tag: *release_tag
26+
source-depth: 1
27+
28+
build-snaps: [go]
29+
build-packages: [git, file, binutils]
30+
31+
build-environment:
32+
- CMK_REPO: *cmk_repo
33+
- CMK_TAG: *release_tag
34+
35+
override-pull: |
36+
set -euo pipefail
37+
craftctl default
38+
REPO="${CMK_REPO}"
39+
TAG="${CMK_TAG}"
40+
FULL_SHA="$(git ls-remote "${REPO}" "refs/tags/${TAG}" | awk '{print $1}')"
41+
SHORT_SHA="${FULL_SHA:0:7}"
42+
: "${SHORT_SHA:=unknown}"
43+
echo "${SHORT_SHA}" > "$CRAFT_PART_SRC/.remote-sha"
44+
craftctl set version="${TAG}-${SHORT_SHA}"
45+
3246
override-build: |
33-
set -eu
34-
go version
35-
go mod vendor
36-
git checkout -- .
37-
git status
38-
git rev-parse HEAD
39-
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
40-
file cmk
41-
chmod +x cmk
42-
./cmk -v
43-
mkdir -p $SNAPCRAFT_PART_INSTALL/bin
44-
mv cmk $SNAPCRAFT_PART_INSTALL/bin/
45-
strip --remove-section=.comment --remove-section=.note $SNAPCRAFT_PART_INSTALL/bin/cmk
47+
set -euo pipefail
48+
cd "$CRAFT_PART_SRC"
49+
SHORT_SHA="$(cat .remote-sha 2>/dev/null || echo unknown)"
50+
BUILD_DATE="$(date +%FT%T%z)"
51+
go mod vendor || true
52+
go build -trimpath \
53+
-ldflags "-s -w -X main.GitSHA=${SHORT_SHA} -X main.BuildDate=${BUILD_DATE}" \
54+
-o cmk cmk.go
55+
install -Dm0755 cmk "$CRAFT_PART_INSTALL/bin/cmk"
56+
strip --remove-section=.comment --remove-section=.note "$CRAFT_PART_INSTALL/bin/cmk" || true

0 commit comments

Comments
 (0)