name: mosquitto
version: 2.1.0
summary: Eclipse Mosquitto MQTT broker
description: This is a message broker that supports version 5.0, 3.1.1, and 3.1 of the MQTT protocol.
    MQTT provides a method of carrying out messaging using a publish/subscribe
    model. It is lightweight, both in terms of bandwidth usage and ease of
    implementation. This makes it particularly useful at the edge of the network
    where a sensor or other simple device may be implemented using a microcontroller for
    example.
confinement: strict
grade: stable
base: core24

apps:
  mosquitto:
    command: launcher.sh
    daemon: simple
    restart-condition: always
    plugs: [home, network, network-bind]

  ctrl:
    command: usr/bin/mosquitto_ctrl
    plugs: [home, network]

  pub:
    command: usr/bin/mosquitto_pub
    plugs: [home, network]

  rr:
    command: usr/bin/mosquitto_rr
    plugs: [home, network]

  signal:
    command: usr/bin/mosquitto_signal
    plugs: [home, network]

  sub:
    command: usr/bin/mosquitto_sub
    plugs: [home, network]

  passwd:
    command: usr/bin/mosquitto_passwd
    plugs: [home]


parts:
  script:
    plugin: dump
    source: snap/local/
    prime:
      - default_config.conf
      - launcher.sh
  config:
    plugin: dump
    source: .
    prime:
      - mosquitto.conf

  dashboard:
    plugin: dump
    source: dashboard/src
    organize:
      '*': dashboard/

  mosquitto:
    plugin: cmake
    cmake-parameters:
      - -DCMAKE_INSTALL_PREFIX=/usr
      - -DHTTP_API_DIR="/snap/mosquitto/current/dashboard/"
      - -DWITH_TESTS=OFF
    source: https://github.com/eclipse-mosquitto/mosquitto
    source-type: git

    build-packages:
      - docbook-xsl
      - g++
      - gcc
      - libcjson-dev
      - libedit-dev
      - libmicrohttpd-dev
      - libsqlite3-dev
      - libssl-dev
      - xsltproc
    stage-packages:
      - ca-certificates
      - libcjson1
      - libmicrohttpd12t64
      - libssl3t64
    prime:
      - usr/sbin/mosquitto
      - usr/bin/mosquitto_ctrl
      - usr/bin/mosquitto_db_dump
      - usr/bin/mosquitto_pub
      - usr/bin/mosquitto_rr
      - usr/bin/mosquitto_signal
      - usr/bin/mosquitto_sub
      - usr/bin/mosquitto_passwd
      - usr/include/mosquitto.h
      - usr/include/mosquitto/*.h
      - usr/include/mosquitto_broker.h
      - usr/include/mosquitto_plugin.h
      - usr/include/mosquittopp.h
      - usr/include/mqtt_protocol.h
      - usr/lib/*-linux-gnu/libcjson.so*
      - usr/lib/*-linux-gnu/libcrypto.so*
      - usr/lib/*-linux-gnu/libmicrohttpd.so*
      - usr/lib/*-linux-gnu/libmosquitto.so*
      - usr/lib/*-linux-gnu/libmosquitto_common.so*
      - usr/lib/*-linux-gnu/libmosquittopp.so*
      - usr/lib/*-linux-gnu/libssl.so*
      - usr/lib/*-linux-gnu/mosquitto_acl_file.so*
      - usr/lib/*-linux-gnu/mosquitto_dynamic_security.so*
      - usr/lib/*-linux-gnu/mosquitto_password_file.so*
      - usr/lib/*-linux-gnu/mosquitto_persist_sqlite.so*
      - usr/lib/*-linux-gnu/mosquitto_sparkplug_aware.so*
