|
1 | 1 | name: cloudmonkey |
2 | | -version: git |
| 2 | +# define the tag anchor on the allowed 'version' field |
| 3 | +version: &release_tag 6.4.0 |
3 | 4 | summary: Apache CloudStack CLI |
4 | 5 | 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 |
6 | 7 | Apache CloudStack, the opensource IAAS cloud computing platform. |
7 | 8 |
|
8 | | -base: core18 |
| 9 | +base: core22 |
9 | 10 | license: Apache-2.0 |
10 | 11 | grade: stable |
11 | 12 | confinement: strict |
| 13 | +adopt-info: cloudmonkey |
12 | 14 |
|
13 | 15 | apps: |
14 | 16 | cloudmonkey: |
15 | 17 | command: bin/cmk |
16 | | - plugs: |
17 | | - - home |
18 | | - - network |
| 18 | + plugs: [home, network] |
19 | 19 |
|
20 | 20 | parts: |
21 | 21 | cloudmonkey: |
22 | | - source: . |
23 | | - source-type: git |
24 | | - source-tag: 6.1.0 |
25 | 22 | 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 | +
|
32 | 46 | 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