name: vlc
version-script: cat $SNAPCRAFT_STAGE/version
version: "daily"
grade: stable
summary: Read, capture, broadcast your multimedia streams
description: |
  VLC is a free and open source cross-platform multimedia player and
  framework that plays most multimedia files as well as DVDs, Audio CDs,
  VCDs, and various streaming protocols.
  NOTE. This snap contains an untested daily build of VLC
confinement: strict

apps:
  vlc:
    desktop: usr/share/applications/vlc.desktop
    command: desktop-launch $SNAP/bin/vlc-snap-wrapper.sh
    plugs:
      - unity7
      - network
      - network-bind
      - home
      - opengl
      - pulseaudio
      - mount-observe
      - optical-drive
      - camera
      - removable-media
      - screen-inhibit-control
      - x11
      - desktop
      - desktop-legacy
    slots:
      - mpris

parts:
  desktop-qt5-vlc:
    source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
    source-commit: de8dc068a05d24cea5c0438863280ab641226570
    source-subdir: qt/
    plugin: make
    make-parameters: ["FLAVOR=qt5"]
    build-packages:
      - qtbase5-dev
      - dpkg-dev
    stage-packages:
      - libxkbcommon0
      - ttf-ubuntu-font-family
      - dmz-cursor-theme
      - light-themes
      - shared-mime-info
      - libqt5gui5
      - libgdk-pixbuf2.0-0
      - libqt5svg5
      - locales-all
  vlc:
    after: [desktop-qt5-vlc]
    source: ../../../
    source-type: git
    plugin: autotools
    override-build: |
      sed -i 's|0\.19\.8|0\.19\.7|'  configure.ac
      cd extras/tools
      ./bootstrap
      make -j $(getconf _NPROCESSORS_ONLN) .protoc
      make -j $(getconf _NPROCESSORS_ONLN) .nasm
      make -j $(getconf _NPROCESSORS_ONLN) .meson
      cd ../../
      export PATH=$PWD/extras/tools/build/bin:$PATH
      cd contrib && mkdir linux && cd linux
      ../bootstrap \
        --enable-libdsm \
        --enable-dvdcss \
        --enable-protobuf \
        --disable-upnp \
        --disable-srt \
        --disable-chromaprint
      make list
      make -j $(getconf _NPROCESSORS_ONLN) fetch
      make -j $(getconf _NPROCESSORS_ONLN) -k install || make -j1
      cd ../../
      export NOCONFIGURE=1
      autoreconf -fi
      ./configure \
          --prefix=$SNAPCRAFT_PART_INSTALL/usr \
          --disable-wayland \
          --enable-merge-ffmpeg
      make -j $(getconf _NPROCESSORS_ONLN)
      echo $(git describe HEAD) > $SNAPCRAFT_STAGE/version
      make install
      sed -i 's|Icon=vlc|Icon=/usr/share/icons/hicolor/256x256/apps/vlc\.png|' $SNAPCRAFT_PART_INSTALL/usr/share/applications/vlc.desktop
      sed -i 's|TryExec=.*|TryExec=/snap/bin/vlc|' $SNAPCRAFT_PART_INSTALL/usr/share/applications/vlc.desktop
    build-packages:
      - ant
      - git
      - g++
      - make
      - yasm
      - autoconf
      - libtool
      - libtool-bin
      - cmake
      - automake
      - build-essential
      - libxcb-xfixes0-dev
      - libqt5svg5-dev
      - libasound2-dev
      - libavahi-client-dev
      - libcdio-dev
      - libdbus-1-dev
      - libdirectfb-dev
      - libegl1-mesa-dev
      - libfreerdp-dev
      - libfreetype6-dev
      - libfribidi-dev
      - libgles2-mesa-dev
      - libgnutls28-dev
      - libgtk2.0-dev
      - libidn11-dev
      - libjack-dev
      - liblircclient-dev
      - liblua5.2-dev
      - libmtp-dev
      - libncursesw5-dev
      - libpng-dev
      - libpulse-dev
      - libqt5x11extras5-dev
      - qtbase5-private-dev
      - librsvg2-dev
      - libsecret-1-dev
      - libudev-dev
      - libupnp-dev
      - libv4l-dev
      - libva-dev
      - libvdpau-dev
      - libx11-dev
      - libxcb-composite0-dev
      - libxcb-keysyms1-dev
      - libxcb-randr0-dev
      - libxcb-shm0-dev
      - libxcb-xv0-dev
      - libxcb1-dev
      - libxext-dev
      - libxi-dev
      - libxinerama-dev
      - libxml2-dev
      - libxpm-dev
      - libzvbi-dev
      - lua5.2
      - pkg-config
      - qtbase5-dev
      - xz-utils
      - zlib1g-dev
      - bison
      - flex
    stage-packages:
      - fonts-freefont-ttf
      - dbus-x11
      - libegl1-mesa
      - libfreerdp-client1.1
      - libfreerdp-core1.1
      - libfreerdp-gdi1.1
      - libfreetype6
      - libfribidi0
      - libdb5.3
      - libgcc1
      - libgl1-mesa-glx
      - libgles2-mesa
      - libglib2.0-0
      - libpulse0
      - libqt5core5a
      - libqt5gui5
      - librsvg2-2
      - libsecret-1-0
      - libva-drm1
      - libva-x11-1
      - libva1
      - libvdpau1
      - libx11-6
      - libxcb-composite0
      - libxcb-keysyms1
      - libxcb-randr0
      - libxcb-shm0
      - libxcb-xv0
      - libxcb1
      - libxext6
      - libxi6
      - libxinerama1
      - libxpm4
      - vdpau-va-driver
      - i965-va-driver
      - mesa-utils
      - mesa-vdpau-drivers
      - zlib1g
      - kde-style-breeze
      - breeze-icon-theme
      - frameworkintegration
      - plasma-integration
      - phonon4qt5-backend-null
      - libjack0
      - libasound2
      - libgtk-3-0
      - liblua5.2-0
      - libmtp9
      - libschroedinger-1.0-0
      - libupnp6
      - libzvbi0
      - libnotify4
      - libaacs0
    filesets:
      exclusion:
      - "-usr/lib/*/cmake/*"
      - "-usr/include/*"
      - "-usr/share/ECM/*"
      - "-usr/share/doc/*"
      - "-usr/share/man/*"
      - "-usr/bin/X11"
      - "-usr/lib/gcc/x86_64-linux-gnu/6.0.0"
      - "-usr/lib/aspell/*"
    prime:
      - "$exclusion"

  wrapper:
    plugin: dump
    after: [vlc]
    source: .
    organize:
      vlc-snap-wrapper.sh: bin/vlc-snap-wrapper.sh
