# Login to your Snapcraft Account
snapcraft login
# Build Snap Package
cd root/of/your/snap
snapcraft
# Publish to Stable Chnnel
snapcraft register snap_name
snapcraft push snap_name.snap --release stable
# Publishing Privately
snapcraft register --private snap_name
snapcraft push snap_name.snap --release stable
snap-a offers the stringsnap library. snap-b utilizes the stringsnap library and builds the stringrunner binary. We will use the content interface for connecting slots and plugs.
slots:
lib0-1804:
interface: content
content: lib0-1804
source:
read:
- $SNAP/lib
lib0-1804
exposes a slot on the content interface which has the capability to read the $SNAP/lib directory.
plugs:
lib0-1804:
interface: content
content: lib0-1804
default-provider: stringsnap:lib0-1804
target: $SNAP/extra-libs
Apart from this, we have to set the LD_LIBRARY_PATH
for the stringrunner snap so that it can find the required library at the extra-libs folder created.
apps:
my-app:
command: bin/stringrunner
plugs:
- lib0-1804
environment:
LD_LIBRARY_PATH: $SNAP/extra-libs/lib
By default, for a content interface, if the slots and plugs are coming from snaps from the same publisher, they are automatically connected. For the snaps to have a publisher associated to them, they have to be installed from the Snap Store. For manually connecting two snaps:
sudo snap connect snap1-name:plug-name snap2-name:slot-name
- snap_name shouldn't follow the regex
snap*
- Library name should follow the regex
lib*.la
- For content interfaces which are responsible for exposing libraries, it's preferred to keep the interface name as
libx-yyzz
wherex
is a version number,yyzz
represents Ubuntu yy.zz LTS used for building the snap package. - While building the dependent snap, we have to mention the absolute path of our required library in the Makefile.
- Since snaps have a confined environment in which they can work, they can't use the hardcoded path of the dependent snap at runtime. To solve this issue, we establish an interface to expose dependent snap's libraries to our required snap.