name: keepassxc
version: 2.3.3
grade: stable
summary: Community-driven port of the Windows application “KeePass Password Safe”
description: |
  KeePassXC is an application for people with extremely high demands on secure
  personal data management. It has a light interface, is cross-platform and
  published under the terms of the GNU General Public License.
confinement: strict

apps:
  keepassxc:
    command: desktop-launch keepassxc
    plugs: [unity7, x11, opengl, gsettings, home, network, network-bind, removable-media, raw-usb]
    desktop: usr/share/applications/org.keepassxc.KeePassXC.desktop
  cli:
    command: keepassxc-cli
    plugs: [gsettings, home, removable-media, raw-usb]
  proxy:
    command: keepassxc-proxy
    plugs: [home]

parts:
  keepassxc:
    source: .
    plugin: cmake
    configflags:
      - -DCMAKE_BUILD_TYPE=Release
      - -DCMAKE_INSTALL_PREFIX=/usr
      - -DCMAKE_LIBRARY_PATH=/opt/keepassxc-libs/lib/x86_64-linux-gnu
      - -DCMAKE_INCLUDE_PATH=/opt/keepassxc-libs/include
      - -DKEEPASSXC_DIST_TYPE=Snap
      - -DKEEPASSXC_BUILD_TYPE=Release
      - -DWITH_TESTS=OFF
      - -DWITH_XC_ALL=ON
    build-packages:
      - g++
      - libgcrypt20-18-dev
      - libqt5x11extras5-dev
      - qtbase5-dev
      - qttools5-dev
      - qttools5-dev-tools
      - zlib1g-dev
      - libxi-dev
      - libxtst-dev
      - libyubikey-dev
      - libykpers-1-dev
      - libsodium-dev
      - libargon2-0-dev
    stage-packages:
      - dbus
      - qttranslations5-l10n # common translations
      - libgcrypt20-18
      - libykpers-1-1
      - libargon2-0
      - libsodium23
      - libxtst6
      - libqt5x11extras5
      - libusb-1.0-0
    override-build: |
      snapcraftctl build
      sed -i 's|Icon=keepassxc|Icon=${SNAP}/usr/share/icons/hicolor/256x256/apps/keepassxc.png|g' $SNAPCRAFT_PART_INSTALL/usr/share/applications/org.keepassxc.KeePassXC.desktop
    organize:
      usr/share/qt5/translations/*.qm: usr/share/keepassxc/translations/
      opt/keepassxc-libs/lib/x86_64-linux-gnu/*: usr/lib/x86_64-linux-gnu/
      opt/keepassxc-libs/share/locale/*: usr/share/locale/
    stage:
      - -opt
    after: [desktop-qt5]