forked from edgexfoundry/device-modbus-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnapcraft.yaml
117 lines (100 loc) · 2.95 KB
/
snapcraft.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: edgex-device-modbus
base: core20
license: Apache-2.0
adopt-info: metadata
architectures:
- build-on: amd64
- build-on: arm64
grade: stable
confinement: strict
# 1: <= hanoi
# 2: >= ireland
epoch: 2
slots:
edgex-secretstore-token:
interface: content
source:
write: [$SNAP_DATA/device-modbus]
plugs:
device-modbus-config:
interface: content
target: $SNAP_DATA/config/device-modbus
# deprecated
device-config:
interface: content
target: $SNAP_DATA/config/device-modbus
apps:
device-modbus:
adapter: full
command: bin/device-modbus $CONFIG_PRO_ARG $CONF_ARG $REGISTRY_ARG
command-chain:
- bin/source-env-file.sh
environment:
CONFIG_PRO_ARG: "--cp=consul.http://localhost:8500"
CONF_ARG: "--configDir=$SNAP_DATA/config/device-modbus/res"
REGISTRY_ARG: "--registry"
DEVICE_PROFILESDIR: "$SNAP_DATA/config/device-modbus/res/profiles"
DEVICE_DEVICESDIR: "$SNAP_DATA/config/device-modbus/res/devices"
SECRETSTORE_TOKENFILE: $SNAP_DATA/device-modbus/secrets-token.json
daemon: simple
install-mode: disable
plugs: [network, network-bind]
parts:
helper-go:
source: snap/local/helper-go
plugin: make
build-snaps:
- go/1.18/stable
override-build: |
cd $SNAPCRAFT_PART_SRC
make build
install -DT ./helper-go $SNAPCRAFT_PART_INSTALL/bin/helper-go
device-modbus:
after: [metadata]
source: .
plugin: make
build-packages: [git, zip, pkg-config]
build-snaps:
- go/1.18/stable
override-build: |
cd $SNAPCRAFT_PART_SRC
# the version is needed for the build
cat ./VERSION
make tidy
make build
install -DT "./cmd/device-modbus" "$SNAPCRAFT_PART_INSTALL/bin/device-modbus"
RES=$SNAPCRAFT_PART_INSTALL/config/device-modbus/res/
mkdir -p $RES
cp cmd/res/configuration.toml $RES
cp -r cmd/res/devices $RES
cp -r cmd/res/profiles $RES
DOC=$SNAPCRAFT_PART_INSTALL/usr/share/doc/device-modbus
mkdir -p $DOC
cp Attribution.txt $DOC/Attribution.txt
cp LICENSE $DOC/LICENSE
local-bin:
plugin: dump
source: snap/local/bin
organize:
source-env-file.sh: bin/source-env-file.sh
metadata:
plugin: nil
source: https://github.com/canonical/edgex-snap-metadata.git
source-branch: appstream
source-depth: 1
override-build: |
# install the icon at the default internal path
install -DT edgex-snap-icon.png \
$SNAPCRAFT_PART_INSTALL/meta/gui/icon.png
# change to this project's repo to get the version
cd $SNAPCRAFT_PROJECT_DIR
if git describe ; then
VERSION=$(git describe --tags --abbrev=0 | sed 's/v//')
else
VERSION="0.0.0"
fi
# write version to file for the build
echo $VERSION > ./VERSION
# set the version of this snap
snapcraftctl set-version $VERSION
parse-info: [edgex-device-modbus.metainfo.xml]