EdgexAgent/device-gps-go/snap/snapcraft.yaml

100 lines
4.1 KiB
YAML
Raw Normal View History

2025-07-10 20:30:06 +08:00
name: edgex-device-gps
# The snap to derive the runtime rootfs from, here core18 corresponds to a
# minimal Ubuntu 18.04 Server rootfs
base: core18
type: app
adopt-info: version
license: Apache-2.0
title: EdgeX Simple Device Service
summary: Demonstrate the Device SDK go in EdgeX using device-gps
description: |
device-simple is an example EdgeX Device Service built using the
device-sdk-go.
# delhi: 0, edinburgh: 1, fuji: 2, geneva: 3, ireland: 4
epoch: 4
# What architectures to build the snap on
architectures:
- build-on: amd64
- build-on: arm64
# The "stability" of the snap and what users can expect from it
# Note that "devel" grade cannot be released to stable or candidate channels
grade: stable
confinement: strict
apps:
device-simple:
# `adapter` specifies what kind of environment variables need to be setup
# for the app, since our app is a statically compiled go app, we don't
# need any of the env vars, but if this was a c program or used cgo, we
# would need adapter: full
adapter: none
command: bin/device-gps --registry $CONFIG_PRO_ARG $CONF_ARG
# Since we can't include the colon ':' characters in the command above,
# we need to specify the consul address in an env var like so
# see https://bugs.launchpad.net/snapd/+bug/1827392 for more details
environment:
CONFIG_PRO_ARG: "--cp=consul.http://localhost:8500"
CONF_ARG: "--configDir=$SNAP_DATA/config/device-gps/res"
DEVICE_DEVICESDIR: "$SNAP_DATA/config/device-gps/res/devices"
DEVICE_PROFILESDIR: "$SNAP_DATA/config/device-gps/res/profiles"
# The service is a simple service that is directly exec'd and expected to
# always run in a single long-lived process
daemon: simple
# Use network and network-bind plugs to access the network and bind to
# ports on network interfaces
plugs: [network, network-bind]
parts:
version:
plugin: nil
source: snap/local
override-pull: |
cd $SNAPCRAFT_PROJECT_DIR
GIT_VERSION=$(git describe --tags --abbrev=0 | sed 's/v//')
snapcraftctl set-version ${GIT_VERSION}
device-simple:
source: .
plugin: make
build-packages: [git, libzmq3-dev, zip, pkg-config]
build-snaps:
- go/1.16/stable
stage-packages: [libzmq5]
override-build: |
# Build device-simple first
cd $SNAPCRAFT_PART_SRC
make build
# Copy the resulting binary into $SNAPCRAFT_PART_INSTALL in the build
# environment, which snapcraft will pack into $SNAP when the build is
# done.
install -DT "./example/cmd/device-simple/device-simple" \
"$SNAPCRAFT_PART_INSTALL/bin/device-simple"
# "ProfilesDir" in combination with the confdir and profile command-line
# options are sufficient to not need to cd before exec'ing the binary.
# Change "ProfilesDir" to be under $SNAP_DATA which is writable and
# where the install hook copies the config files and device profiles to
# when the snap is first installed
install -DT "./example/cmd/device-simple/res/configuration.yaml" \
"$SNAPCRAFT_PART_INSTALL/config/device-simple/res/configuration.yaml"
# Install the example device and device profile
install -DT "./example/cmd/device-simple/res/devices/simple-device.toml" \
"$SNAPCRAFT_PART_INSTALL/config/device-simple/res/devices/simple-device.toml"
install -DT "./example/cmd/device-simple/res/profiles/Simple-Driver.yaml" \
"$SNAPCRAFT_PART_INSTALL/config/device-simple/res/profiles/Simple-Driver.yaml"
# Also install the Attribution.txt and LICENSE files into the snap at
# usr/share/doc/device-simple which is a debian standard location for
# licenses in the snap.
# Note also if the license is changed that the license key in the
# metadata for the snap at the top of this file should be updated too.
install -DT "./example/cmd/device-simple/Attribution.txt" \
"$SNAPCRAFT_PART_INSTALL/usr/share/doc/device-simple/Attribution.txt"
install -DT "./LICENSE" \
"$SNAPCRAFT_PART_INSTALL/usr/share/doc/device-simple/LICENSE"