name: denaro 
base: core22 
adopt-info: denaro
source-code: https://github.com/nlogozzo/NickvisionMoney
issues: https://github.com/nlogozzo/NickvisionMoney/issues
donation: https://github.com/sponsors/nlogozzo
contact: https://matrix.to/#/#nickvision:matrix.org
grade: stable 
confinement: strict 
architectures:
  - build-on: amd64
  - build-on: arm64
  - build-on: armhf

parts:
  # When the snap of `blueprint-compiler` comes up, we can remove this part upto L21
  blueprint-compiler:
    source-depth: 1
    source: https://gitlab.gnome.org/jwestman/blueprint-compiler.git
    source-tag: 'v0.10.0'
    plugin: meson
    meson-parameters:
      - --prefix=/usr
    override-prime: ''
  denaro:
    after:  # remove this and next line too when the snap of `blueprint-compiler` comes up
      - blueprint-compiler
    plugin: nil
    source: .
    parse-info: [ usr/share/metainfo/org.nickvision.money.metainfo.xml ]
    build-environment:
      - DOTNET_CLI_TELEMETRY_OPTOUT: '1'
      - PATH: $HOME/.dotnet:$HOME/.dotnet/tools:$HOME/.cargo/bin:$PATH
      - DOTNET_ROOT: $HOME/.dotnet
      - PYTHONPATH: $CRAFT_STAGE/usr/lib/python3/dist-packages:$PYTHONPATH
      - GI_TYPELIB_PATH: /snap/gnome-42-2204-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET/girepository-1.0:/snap/gnome-42-2204-sdk/current/usr/lib/girepository-1.0 
    build-packages:
      - wget
    override-pull: |
      craftctl default
      wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
      chmod +x ./dotnet-install.sh
      ./dotnet-install.sh --channel 8.0
      patch -p1 < $CRAFT_PROJECT_DIR/snap/denaro.patch
    override-build: |
      craftctl default
      cd $CRAFT_PART_SRC
      dotnet tool restore
      dotnet cake --target=Publish --prefix=/snap/denaro/current/usr --ui=gnome --self-contained
      dotnet cake --target=Install --destdir=$CRAFT_PART_INSTALL
      mkdir -p $CRAFT_PART_INSTALL/meta/gui
      cp -r $CRAFT_PART_INSTALL/snap/denaro/current/usr/share/icons $CRAFT_PART_INSTALL/meta/gui/
      for i in `find $CRAFT_PART_INSTALL/meta/gui/icons -name "*.svg" -o -name "*.png"`; do
        mv $i "`dirname $i`/snap.$CRAFT_PROJECT_NAME.`basename $i`"
      done
    organize:
      snap/denaro/current: .
    prime:
      - -snap/current

slots:
  denaro:
    interface: dbus
    bus: session
    name: org.nickvision.denaro


apps:
  denaro:
    command: usr/bin/org.nickvision.money
    extensions: [gnome]
    common-id: org.nickvision.money
    plugs:
      - home
      - network
      - network-status
