forked from edgexfoundry/device-usb-camera
/
snapcraft.yaml
142 lines (121 loc) · 4.29 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: edgex-device-usb-camera
base: core22
license: Apache-2.0
adopt-info: metadata
architectures:
- build-on: amd64
- build-on: arm64
grade: stable
confinement: strict
slots:
edgex-secretstore-token:
interface: content
content: edgex-secretstore-token
source:
write: [$SNAP_DATA/device-usb-camera]
plugs:
device-config:
interface: content
target: $SNAP_DATA/config/device-usb-camera
apps:
rtsp-simple-server:
command: bin/rtsp-simple-server $SNAP_DATA/config/rtsp-simple-server.yml
daemon: simple
install-mode: disable
plugs: [network-bind]
device-usb-camera:
command: bin/device-usb-camera $CONFIG_PRO_ARG $CONF_ARG $REGISTRY_ARG
command-chain:
- bin/startup-env-var.sh
environment:
CONFIG_PRO_ARG: "--cp=consul.http://localhost:8500"
CONF_ARG: "--confdir=$SNAP_DATA/config/device-usb-camera/res"
REGISTRY_ARG: "--registry"
DEVICE_PROFILESDIR: "$SNAP_DATA/config/device-usb-camera/res/profiles"
DEVICE_DEVICESDIR: "$SNAP_DATA/config/device-usb-camera/res/devices"
SECRETSTORE_TOKENFILE: $SNAP_DATA/device-usb-camera/secrets-token.json
# Add shared library object file to path for ffprobe/ffmpeg
LD_LIB: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET
LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$LD_LIB/blas:$LD_LIB/lapack:$LD_LIB/pulseaudio
daemon: simple
install-mode: disable
plugs: [network, network-bind, camera]
parts:
hooks:
source: snap/local/hooks
plugin: make
build-snaps: [go/1.17/stable]
override-build: |
cd $SNAPCRAFT_PART_SRC
make build
install -DT ./cmd/configure/configure $SNAPCRAFT_PART_INSTALL/snap/hooks/configure
install -DT ./cmd/install/install $SNAPCRAFT_PART_INSTALL/snap/hooks/install
rtsp-simple-server:
source:
- on amd64:
https://github.com/aler9/rtsp-simple-server/releases/download/v0.18.3/rtsp-simple-server_v0.18.3_linux_amd64.tar.gz
- on arm64:
https://github.com/aler9/rtsp-simple-server/releases/download/v0.18.3/rtsp-simple-server_v0.18.3_linux_arm64v8.tar.gz
plugin: dump
organize:
rtsp-simple-server: bin/rtsp-simple-server
rtsp-simple-server.yml: config/rtsp-simple-server.yml
build-packages: [curl]
override-build: |
DOC=$SNAPCRAFT_PART_INSTALL/usr/share/doc/rtsp-simple-server
mkdir -p $DOC
curl --silent --show-err https://raw.githubusercontent.com/aler9/rtsp-simple-server/main/LICENSE \
-o $DOC/LICENSE
snapcraftctl build
device-usb-camera:
after: [metadata]
source: .
plugin: make
build-packages: [git, libzmq3-dev, pkg-config]
build-snaps: [go/1.17/stable]
stage-packages:
- libzmq5
- ffmpeg
override-build: |
cd $SNAPCRAFT_PART_SRC
# the version is needed for the build
cat VERSION
make tidy
make build
install -DT "./cmd/device-usb-camera" "$SNAPCRAFT_PART_INSTALL/bin/device-usb-camera"
RES=$SNAPCRAFT_PART_INSTALL/config/device-usb-camera/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-usb-camera
mkdir -p $DOC
cp Attribution.txt $DOC/Attribution.txt
cp LICENSE $DOC/LICENSE
# The "which" command is used by goffmpeg package.
# Copy it to local bins to bypass apparmor protection
cp --dereference /usr/bin/which $SNAPCRAFT_PART_INSTALL/bin/which
runtime-helpers:
plugin: dump
source: snap/local/runtime-helpers
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-usb-camera.metainfo.xml]