name: strawberry
adopt-info: strawberry
summary: music player and collection organizer
description: |
  Strawberry is a music player and collection organizer.
  It is a fork of Clementine released in 2018 aimed at music collectors and audiophiles

grade: stable
confinement: strict
base: core18

parts:

  desktop-qt5:
    build-packages:
      - build-essential
      - qtbase5-dev
      - dpkg-dev
    make-parameters:
      - FLAVOR=qt5
    plugin: make
    source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
    source-subdir: qt
    stage-packages:
      - libqt5gui5
      - libqt5svg5
      - libgdk-pixbuf2.0-0
      - locales-all
      - xdg-user-dirs
      - fcitx-frontend-qt5
      - libxkbcommon0
      - ttf-ubuntu-font-family
      - dmz-cursor-theme
      - light-themes
      - gnome-themes-standard
      - shared-mime-info
      - adwaita-icon-theme
      - oxygen-icon-theme
      - breeze-icon-theme
      - qtwayland5
      - try: [appmenu-qt5]

  alsa-lib:
    plugin: autotools
    source: https://www.alsa-project.org/files/pub/lib/alsa-lib-1.2.3.tar.bz2
    configflags:
      - --prefix=/usr
      - --sysconfdir=/etc
      - --libexec=/usr/lib
      - --libdir=/usr/lib
      - --localstatedir=/var
      - --with-configdir=/snap/$SNAPCRAFT_PROJECT_NAME/current/usr/share/alsa
      - --with-plugindir=/snap/$SNAPCRAFT_PROJECT_NAME/current/usr/lib/alsa-lib
      - --disable-static
    stage:
      - usr/include
      - usr/lib
    prime:
      - -usr/bin
      - -usr/include
      - -usr/lib/pkgconfig
      - -usr/share/alsa/alsa.conf
      - -usr/share/alsa/pcm
      - -usr/share/alsa/topology/broadwell

  strawberry:
    plugin: cmake
    source-type: git
    source: https://github.com/strawberrymusicplayer/strawberry
    after:
      - alsa-lib
      - desktop-qt5
    override-pull: |
      snapcraftctl pull
      snapcraftctl set-version "$(git describe --tags | sed 's/^v//' | cut -d "-" -f1-2)"
    override-build: |
      cmake ../src -DCMAKE_INSTALL_PREFIX=/usr
      make -j $(getconf _NPROCESSORS_ONLN)
      make DESTDIR=$SNAPCRAFT_PART_INSTALL install
      sed -i 's|Icon=strawberry|Icon=/usr/share/icons/hicolor/128x128/apps/strawberry\.png|' $SNAPCRAFT_PART_INSTALL/usr/share/applications/org.strawberrymusicplayer.strawberry.desktop
      sed -i 's|TryExec=.*|TryExec=/snap/bin/strawberry|' $SNAPCRAFT_PART_INSTALL/usr/share/applications/org.strawberrymusicplayer.strawberry.desktop

    build-packages:
      - cmake
      - make
      - gcc
      - g++
      - protobuf-compiler
      - gettext
      - libglib2.0-dev
      - libgnutls28-dev
      - libdbus-1-dev
      - libprotobuf-dev
      - libboost-dev
      - libsqlite3-dev
      - libasound2-dev
      - libpulse-dev
      - libtag1-dev
      - qtbase5-dev
      - qtbase5-dev-tools
      - qtbase5-private-dev
      - qttools5-dev
      - libqt5x11extras5-dev
      - libgstreamer1.0-dev
      - libgstreamer-plugins-base1.0-dev
      - libvlc-dev
      - libcdio-dev
      - libgpod-dev
      - libmtp-dev
      - libchromaprint-dev
      - libfftw3-dev

    stage-packages:
      - libstdc++6
      - libgcc1
      - libprotobuf10
      - libpcre16-3
      - libqt5core5a
      - libqt5gui5
      - libqt5widgets5
      - libqt5concurrent5
      - libqt5network5
      - libqt5dbus5
      - libqt5sql5
      - libqt5x11extras5
      - libqt5sql5-sqlite
      - libsqlite3-0
      - libgpm2
      - libasound2
      - libasound2-plugins
      - libpulse0
      - libcdio17
      - libgpod4
      - libmtp9
      - libvlc5
      - libvlccore9
      - libtag1v5
      - libchromaprint1
      - zlib1g
      - libx11-6
      - libxcomposite1
      - libxcursor1
      - libxrandr2
      - libdb5.3
      - libglu1
      - libslang2
      - libatk1.0-0
      - libatk-bridge2.0-0
      - libatk1.0-data
      - libatk-adaptor
      - dbus-x11
      - libgstreamer1.0-0
      - libgstreamer-plugins-base1.0-0
      - gstreamer1.0-alsa
      - gstreamer1.0-pulseaudio
      - gstreamer1.0-plugins-base
      - gstreamer1.0-plugins-good
      - gstreamer1.0-plugins-bad
      - gstreamer1.0-plugins-ugly
      - gstreamer1.0-libav
      - qt5-gtk-platformtheme
      - plasma-integration
      - kde-style-breeze
      - qtwayland5

apps:
  strawberry:
    command: desktop-launch $SNAP/usr/bin/strawberry
    desktop: usr/share/applications/org.strawberrymusicplayer.strawberry.desktop
    environment:
      ALSA_CONFIG_PATH: /snap/$SNAPCRAFT_PROJECT_NAME/current/usr/share/alsa/alsa.conf
      LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio
      DISABLE_WAYLAND: 1
    plugs:
      - home
      - udisks2
      - network
      - network-manager-observe
      - network-bind
      - desktop
      - desktop-legacy
      - x11
      - wayland
      - alsa
      - audio-playback
      - removable-media
      - optical-drive
      - raw-usb
      - media-hub
      - screen-inhibit-control
      - unity7
    slots:
      - mpris

  strawberry-tagreader:
    command: strawberry-tagreader
    plugs:
      - network
      - network-manager-observe
      - network-bind
