snap/snapcraft.yaml
author Edouard Tisserant <edouard.tisserant@gmail.com>
Sun, 21 Aug 2022 19:27:35 +0200
changeset 101 5799370243c0
parent 86 3564991cd359
child 106 cf158979ecae
permissions -rw-r--r--
Version "name" of installer and snap is now deduced from beremiz' version.py
name: beremiz
adopt-info: beremiz
summary: Beremiz Open Source PLC.
description: |
  Beremiz is Free and Open Source PLC. It brings Free Software IDE (GPL) and Runtime (LGPL) for machine automation, conforming to IEC-61131.
icon: snap/gui/beremiz.png
contact: 
  - https://beremiz.org
  - snap@beremiz.fr


grade: devel
confinement: strict
base: core20
architectures: [amd64, arm64]

parts:

  python-deps:
    # This part provides all python2 dependencies, including interpreter
    # More particularily, it builds latest PIP supporting python2 from git
    # and uses it to collect and buid other Beremiz dependencies.
    #
    # rational:
    #  - python plugin doesn't support python2 anymore on core20+
    #  - attempts to get python2+pip+virtualenv in a core20 based snap failed

    plugin: nil
    source: https://github.com/pypa/pip/archive/refs/tags/20.3.4.tar.gz
    build-packages:
      - libssl-dev
      - libgtk-3-dev
      - libgl1-mesa-dev
      - libglu1-mesa-dev
      - python2-dev

    stage-packages:
      - python2
      - python-setuptools
      - python-lxml

    override-build: |
      # For some reasons site-packages needs to be created and 
      # added to PYTHONPATH during PIP (own) build.
      # Apparently not anymore when snap is executed.
      mkdir $SNAPCRAFT_PART_INSTALL/usr/lib/python2.7/site-packages
      PYTHONPATH=$SNAPCRAFT_PART_INSTALL/usr/lib/python2.7/site-packages \
        $SNAPCRAFT_PART_INSTALL/usr/bin/python2 $SNAPCRAFT_PART_SRC/setup.py \
            install --prefix $SNAPCRAFT_PART_INSTALL/usr
      PYTHONPATH=$SNAPCRAFT_PART_INSTALL/usr/lib/python2.7/site-packages \
        $SNAPCRAFT_PART_INSTALL/usr/bin/pip install \
          future              \
          matplotlib          \
          msgpack_python      \
          u-msgpack-python    \
          zeroconf2           \
          enum34              \
          pyro                \
          sslpsk              \
          posix_spawn         \
          twisted             \
          nevow               \
          autobahn            \
          click               \
          opcua               \
          pycountry           \
          fonttools           \
          Brotli              \
          wxPython==4.1.1

  beremiz:
    # Beremiz python source + GCC toolchain
    # source tree is expected to be just aside snap directory
    plugin: nil
    source: beremiz
    source-type: local
    stage-packages:
      - gcc
      - libc6
      - libc6-dev
      - linux-libc-dev
      - libgcc-9-dev
      - libgcc-s1
    override-pull: |
      snapcraftctl pull
      snapcraftctl set-version `python2 $SNAPCRAFT_PART_SRC/version.py`
    override-build: |
      cp -a $SNAPCRAFT_PART_SRC $SNAPCRAFT_PART_INSTALL/beremiz

  matiec:
    # Matiec ST, SFC and IL compiler.
    # source tree is expected to be just aside snap directory
    plugin: nil
    source: matiec
    source-type: local
    build-packages:
      - build-essential
      - automake
      - flex
      - bison
    override-build: |
      autoreconf -i && ./configure && make
      cp -a $SNAPCRAFT_PART_BUILD $SNAPCRAFT_PART_INSTALL/matiec

  modbus:
    plugin: nil
    source: Modbus
    source-type: local
    build-packages:
      - build-essential
      - automake
    override-build: |
      make
      cp -a $SNAPCRAFT_PART_BUILD $SNAPCRAFT_PART_INSTALL/Modbus

  open62541:
    plugin: nil
    source: open62541
    source-type: local
    build-packages:
      - build-essential
      - cmake
    override-build: |
      mkdir build && cd build && cmake .. && make
      cp -a $SNAPCRAFT_PART_BUILD $SNAPCRAFT_PART_INSTALL/open62541
      
  inkscape:
    # CLI only, used in SVGHMI build
    # GUI fails to launch couldn't find a way
    plugin: nil
    stage-packages:
      - inkscape
      - libgtk-3-0 
      # libgtk3 needs to be explicitely given
      # otherwise wxGtk doesn't start, with this error :
      # libgtk-3.so.0: undefined symbol: pango_font_family_get_face
      # ... why ?

  revisiontxt:
    # Makefile generated "revisions.txt"
    plugin: nil
    source: .
    source-type: local
    override-build: |
      cp $SNAPCRAFT_PART_SRC/revisions.txt $SNAPCRAFT_PART_INSTALL

apps:
  ide:
    # Launcher for the IDE
    environment:
      SYSROOT: $SNAP
    command: usr/bin/python2 $SNAP/beremiz/Beremiz.py
    extensions: [gnome-3-38]
    plugs:
      - network
      - network-bind

  beremiz:
    # Beremiz Command Line interface
    environment:
      SYSROOT: $SNAP
    command: usr/bin/python2 $SNAP/beremiz/Beremiz_cli.py
    plugs:
      - network
      - network-bind
 
  runtime:
    # Standalone runtime
    environment:
      SYSROOT: $SNAP
    command: usr/bin/python2 $SNAP/beremiz/Beremiz_service.py
    plugs:
      - network
      - network-bind