Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Add snap packaging of device-grove-c #15

Merged
merged 3 commits into from
Jun 27, 2019

Conversation

anonymouse64
Copy link
Contributor

@anonymouse64 anonymouse64 commented Jun 25, 2019

This adds a snap of (currently Fuji since it's the master branch) device-grove-c.

This PR is currently a draft to setup the branches so we can test the jobs in the sandbox and get the jobs setup in Jenkins on ci-mangement

Fixes: #11

ci-management PR here has been merged: edgexfoundry/ci-management#433

This PR is now ready for review.

To test this snap, on an Raspberry Pi 3B+ that is running an arm64 image, such as what you get by following the setup instructions for the ubuntu server 18.04.2 found here, do the following to build and install the snap:

  1. Install snapcraft and lxd with snap install snapcraft --classic and by following the instructions here for lxd
  2. Checkout this branch using git
  3. Build the snap by going to the root directory of this project and running snapcraft --use-lxd.
  4. Install the edgexfoundry snap from the edinburgh/beta channel with snap install edgexfoundry --channel=edinburgh/beta - note you should do this first so that the EdgeX services are available when device-grove starts up after being install in the next step
  5. The build from step 3 should have produced a .snap file named edgex-device-grove*.snap, install this snap with snap install --dangerous edgex-device-grove*.snap

Assuming all of the above works, the snap is installed and the things to check are:

[ ] the daemon in the snap starts up, check with snap services edgex-device-grove all services listed there should be active and enabled
[ ] the daemon loads the default Grove_Device.yaml file from /var/snap/edgex-device-grove/current/config/device-grove/profiles/Grove_Device.yaml into core-metadata, etc.
[ ] the configuration.toml file doesn't contain any references to the revision, i.e. all paths under /var/snap/edgex-device-grove/ start with current as in /var/snap/edgex-device-grove/current/... and not /var/snap/edgex-device-grove/x1/...

Additionally, if you have access to the grove sensors, try loading some of the device profiles from /snap/edgex-device-grove/current/config/edgex-device-grove/res/example-profiles and make sure that curl commands produce correct output. I don't have access to any grove sensors so unfortunately I was unable to do this, but since it's basically the same code as the docker container it should work the same I think.

You can see logs from the daemon with snap logs -f -n=all edgex-device-grove or journalctl -ef -u snap.edgex-device-grove.*

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
jamesrgregg
jamesrgregg previously approved these changes Jun 25, 2019
Copy link
Contributor

@jamesrgregg jamesrgregg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@anonymouse64 anonymouse64 marked this pull request as ready for review June 26, 2019 23:25
@anonymouse64
Copy link
Contributor Author

Triggered the snap verify jobs and updated the PR description. This PR is now ready for review/merging

Copy link
Member

@SteveOss SteveOss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the CMake file think a simpler fix is just to add "-pthread" to CMAKE_C_FLAGS.

Also although nothing to do with PR. IMHO better setting C version with "set (CMAKE_C_STANDARD 99)" as opposed to the gcc specific "std=c99"

Previously, this would fail in a clean ubuntu 18.04 instance with:

[100%] Linking C executable device-grove
/usr/bin/ld: CMakeFiles/device-grove.dir/main.c.o: undefined reference to symbol 'sem_post@@GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

This is the simplest way to link to pthreads from this project without
digging into the c-sdk, etc.

Also set the c standard to c99 in a more portable way by setting 
CMAKE_C_STANDARD.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
* Add an install hook to copy the configuration file and default device
  profile from read-only $SNAP into $SNAP_DATA for use from the service.
  This is so users can modify the configuration.toml file and device
  profile easily
* Build the device-sdk-c from source on the edinburgh branch
* Use sed to modify the hostname for EdgeX services as localhost by
  default
* Patch libmraa using the patch in this repo before building it
* Stage all of the source files from iotech-c-utils and tomlc99 into
  $SNAPCRAFT_STAGE, then copy from there to the src directory of
  device-sdk-c before building device-sdk-c to handle the deps. This
  mirrors what the upstream build.sh script does as close as possible.
* Use environment variables for the options to launch device-grove 
  due to https://bugs.launchpad.net/snapd/+bug/1827392 because we can't
  have "=" in the snap command specification

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
@anonymouse64
Copy link
Contributor Author

@SteveOss okay, updated both things

@anonymouse64 anonymouse64 mentioned this pull request Jun 27, 2019
Copy link
Member

@SteveOss SteveOss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SteveOss SteveOss merged commit 4d03f64 into edgexfoundry:master Jun 27, 2019
@anonymouse64 anonymouse64 deleted the feature/snap branch August 2, 2019 02:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Snap packaging for device-grove
3 participants