name: sabnzbd
summary: SABnzbd
description: The automated Usenet download tool
confinement: strict
base: core18
grade: stable
icon: interfaces/Config/templates/staticcfg/images/logo-small.svg
adopt-info: sabnzbd

apps:
  sabnzbd:
    environment:
      LC_CTYPE: C.UTF-8
    command: python3 $SNAP/opt/sabnzbd/SABnzbd.py -f $SNAP_COMMON
    daemon: simple
    plugs: [network, home, network-bind, removable-media]

parts:
  sabnzbd:
    plugin: python
    source: .
    python-version: python3
    requirements: [snap/requirements_snap.txt, requirements.txt]
    stage-packages: [python3-dev, libdb5.3, unrar, p7zip-full, par2]
    build-packages: [libffi-dev, python3-dev, libssl-dev, cargo]
    override-build: |
      snapcraftctl set-version $(grep -oP '(?<=^Version: ).*' PKG-INFO)
      snapcraftctl build
      python3 tools/make_mo.py
      mkdir -p $SNAPCRAFT_PART_INSTALL/opt
      cp -R $SNAPCRAFT_PART_BUILD $SNAPCRAFT_PART_INSTALL/opt/sabnzbd
    organize:
      usr/bin/unrar-nonfree: usr/bin/unrar
