
# SPDX-FileCopyrightText: 2023-2025 Scarlett Moore <sgmoore@kde.org>
#
# SPDX-License-Identifier: CC0-1.0
---
name: labplot
confinement: strict
grade: stable
base: core24
adopt-info: labplot
apps:
  labplot:
    extensions:
      - kde-neon-6
    common-id: org.kde.labplot.desktop
    command: usr/bin/labplot
    plugs:
      - cups
      - home
    # command-chain:
    #   - bin/tmpdir
    environment:
      QTWEBENGINE_DISABLE_SANDBOX: 1
parts:
  # launchers:
  #   source: snap/local/launchers
  #   plugin: dump
  #   organize:
  #       '*': bin/
  analitza:
    source: https://invent.kde.org/education/analitza.git
    source-branch: release/25.04
    plugin: cmake
    build-packages:
      - libxslt1-dev
      - libpulse0
    stage-packages:
      - rsync
      - libxslt1.1
    cmake-parameters:
      - -DCMAKE_INSTALL_PREFIX=/usr
      - -DCMAKE_BUILD_TYPE=Release
      - -DQT_MAJOR_VERSION=6
      - -DBUILD_WITH_QT6=ON
      - -DBUILD_TESTING=OFF
      - -DQT_DEBUG_FIND_PACKAGE=ON
      - "-DCMAKE_FIND_ROOT_PATH=$CRAFT_STAGE\\;/snap/kde-qt6-core24-sdk/current\\;/snap/kf6-core24-sdk/current/usr"
      - "-DCMAKE_PREFIX_PATH=$CRAFT_STAGE\\;/snap/kde-qt6-core24-sdk/current\\;/snap/kf6-core24-sdk/current/usr"
    build-environment: &build_env
      - PATH: /snap/kf6-core24-sdk/current/usr/bin:/snap/kde-qt6-core24-sdk/current/usr/bin${PATH:+:$PATH}
      - PKG_CONFIG_PATH: /snap/kde-qt6-core24-sdk/current/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/pkgconfig:/snap/kf6-core24-sdk/current/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}
      - XDG_DATA_DIRS: $CRAFT_STAGE/usr/share:/snap/kf6-core24-sdk/current/usr/share:/snap/kde-qt6-core24-sdk/current/usr/share:/usr/share${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}
      - XDG_CONFIG_HOME: $CRAFT_STAGE/etc/xdg:/snap/kf6-core24-sdk/current/etc/xdg:/snap/kde-qt6-core24-sdk/current/etc/xdg:/etc/xdg${XDG_CONFIG_HOME:+:$XDG_CONFIG_HOME}
      - LD_LIBRARY_PATH: /snap/kde-qt6-core24-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:/snap/kde-qt6-core24-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libproxy:/snap/kde-qt6-core24-sdk/current/usr/lib:/snap/kf6-core24-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:/snap/kf6-core24-sdk/current/usr/lib:$CRAFT_STAGE/usr/lib:$CRAFT_STAGE/lib/:$CRAFT_STAGE/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR
      - LDFLAGS: "-L$CRAFT_STAGE/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR"
      - CFLAGS: "-I$CRAFT_STAGE/usr/include"
    override-stage: |
        craftctl default
        rsync -a --ignore-existing $CRAFT_PART_INSTALL/ /
  qxlsx:
    plugin: cmake
    source: https://github.com/QtExcel/QXlsx.git
    source-tag: v1.4.6
    source-subdir: QXlsx
    build-packages:
      - cmake
      - rsync
    cmake-parameters:
      - -DCMAKE_INSTALL_PREFIX=/usr
      - -DCMAKE_BUILD_TYPE=Release
      - -DQT_MAJOR_VERSION=6
      - -DBUILD_WITH_QT6=ON
      - -DBUILD_TESTING=OFF
      - "-DCMAKE_FIND_ROOT_PATH=$CRAFT_STAGE\\;/snap/kde-qt6-core24-sdk/current\\;/snap/kf6-core24-sdk/current/usr"
      - "-DCMAKE_PREFIX_PATH=$CRAFT_STAGE\\;/snap/kde-qt6-core24-sdk/current\\;/snap/kf6-core24-sdk/current/usr"
    build-environment: *build_env
    override-stage: |
        craftctl default
        rsync -a --ignore-existing $CRAFT_PART_INSTALL/ /
  qtmqtt:
    after:
      - qxlsx
    source: https://github.com/qt/qtmqtt.git
    source-tag: v6.7.2
    plugin: cmake
    build-packages:
      - cmake
    cmake-parameters:
      - -DCMAKE_INSTALL_PREFIX=/usr
      - -DCMAKE_BUILD_TYPE=Release
      - -DQT_MAJOR_VERSION=6
      - -DBUILD_WITH_QT6=ON
      - -DBUILD_TESTING=OFF
      - "-DCMAKE_FIND_ROOT_PATH=$CRAFT_STAGE\\;/snap/kde-qt6-core24-sdk/current\\;/snap/kf6-core24-sdk/current/usr"
      - "-DCMAKE_PREFIX_PATH=$CRAFT_STAGE\\;/snap/kde-qt6-core24-sdk/current\\;/snap/kf6-core24-sdk/current/usr"
    build-environment: *build_env
  gsl:
    after:
      - qxlsx
    source: http://ftp.gnu.org/gnu/gsl/gsl-2.8.tar.gz
    source-checksum: sha256/6a99eeed15632c6354895b1dd542ed5a855c0f15d9ad1326c6fe2b2c9e423190
    plugin: autotools
    autotools-configure-parameters:
      - --prefix=/usr
      - --enable-fixed-path=/snap/kde-qt6-core24-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR
    build-environment:
      - LD_LIBRARY_PATH: $LD_LIBRARY_PATH:/snap/kde-qt6-core24-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:/snap/kf6-core24-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:$CRAFT_STAGE/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:/usr
      - PKG_CONFIG_PATH: /snap/kde-qt6-core24-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/pkgconfig
    override-build: |
      craftctl default
      rsync -a --ignore-existing $CRAFT_PART_INSTALL/ /
  libqalculate:
    plugin: autotools
    source: https://github.com/Qalculate/libqalculate/releases/download/v5.5.0/libqalculate-5.5.0.tar.gz
    autotools-configure-parameters:
      - --prefix=/usr
    build-packages:
      - autotools-dev
      - intltool
      - libgmp-dev
      - libmpfr-dev
      - libcurl4-openssl-dev
      - libicu-dev
      - icu-devtools
      - libxml2-dev
    stage-packages:
      - libgmp10
      - libmpfr6
      - libcurl4t64
      - libicu74
      - libxml2
  libgpgmepp-qt6:
    build-packages:
      - libassuan-dev
      - libgpg-error-dev
      - rsync
    stage-packages:
      - libassuan0
      - libgpg-error0
    source: https://www.gnupg.org/ftp/gcrypt/gpgme/gpgme-1.23.2.tar.bz2
    source-checksum: sha256/9499e8b1f33cccb6815527a1bc16049d35a6198a6c5fae0185f2bd561bce5224
    plugin: autotools
    autotools-configure-parameters:
      - --disable-gpgsm-test
      - --enable-languages=cpp,qt6
      - --prefix=/usr
      - --enable-fixed-path=/snap/kde-qt6-core24-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR
    build-environment: &buildenvironment
      - LD_LIBRARY_PATH: $LD_LIBRARY_PATH:/snap/kde-qt6-core24-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:/snap/kde-qt6-core24-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libproxy:/snap/kf6-core24-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:$CRAFT_STAGE/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:/usr
      - PKG_CONFIG_PATH: /snap/kde-qt6-core24-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/pkgconfig
    override-build: |
      craftctl default
      rsync -a --ignore-existing $CRAFT_PART_INSTALL/ /
  poppler:
    after:
      - libgpgmepp-qt6
    plugin: cmake
    source: https://poppler.freedesktop.org/poppler-25.06.0.tar.xz
    build-packages:
      - cmake
      - libfreetype6-dev
      - libfontconfig1-dev
      - libjpeg-dev
      - zlib1g-dev
      - liblcms2-dev
      - libcurl4-openssl-dev
      - libopenjp2-7-dev
      - libboost-dev
      - libgl1-mesa-dev
      - libtiff-dev
      - libpulse0
    stage-packages:
      - libasn1-8-heimdal
      - libbrotli1
      - libcurl4t64
      - libdouble-conversion3
      - libfontconfig1
      - libfreetype6
      - libgraphite2-3
      - libgssapi3-heimdal
      - libharfbuzz0b
      - libhcrypto5t64-heimdal
      - libheimbase1-heimdal
      - libheimntlm0-heimdal
      - libhx509-5-heimdal
      - libicu74
      - libjbig0
      - libjpeg-turbo8
      - libkrb5-26-heimdal
      - liblcms2-2
      - libldap2
      - libnghttp2-14
      - libnspr4
      - libpcre2-16-0
      - libpng16-16
      - libpsl5
      - libroken19-heimdal
      - librtmp1
      - libsasl2-2
      - libssh-4
      - libtiff6
      - libwebp7
      - libwind0-heimdal
      - libx11-6
      - libxau6
      - libxcb1
      - libxdmcp6
      - libmd4c0
      - libopenjpip7
      - libtiff6
      - libpulse0
    cmake-parameters:
      - -DCMAKE_INSTALL_PREFIX=/usr
      - -DCMAKE_BUILD_TYPE=Release
      - -DQT_MAJOR_VERSION=6
      - -DENABLE_QT5=OFF
      - -DENABLE_QT6=ON
      - -DBUILD_GTK_TESTS=OFF
      - -DBUILD_QT6_TESTS=OFF
      - -DBUILD_QT5_TESTS=OFF
      - -DBUILD_CPP_TESTS=OFF
      - -DBUILD_MANUAL_TESTS=OFF
      - -DENABLE_NSS3=OFF
      - "-DCMAKE_FIND_ROOT_PATH=$CRAFT_STAGE\\;/snap/kde-qt6-core24-sdk/current\\;/snap/kf6-core24-sdk/current/usr"
      - "-DCMAKE_PREFIX_PATH=$CRAFT_STAGE\\;/snap/kde-qt6-core24-sdk/current\\;/snap/kf6-core24-sdk/current/usr"
    build-environment:
      - LD_LIBRARY_PATH: $LD_LIBRARY_PATH:/snap/kde-qt6-core24-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:/snap/kde-qt6-core24-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libproxy:/snap/kf6-core24-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:$CRAFT_STAGE/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:/usr
      - PKG_CONFIG_PATH: /snap/kde-qt6-core24-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/pkgconfig
    override-build: |
      craftctl default
      rsync -a --ignore-existing $CRAFT_PART_INSTALL/ /
  cantor:
    after:
      - analitza
      - libqalculate
      - poppler
    parse-info:
      - usr/share/metainfo/org.kde.cantor.appdata.xml
    plugin: cmake
    source: https://invent.kde.org/education/cantor.git
    source-branch: release/25.04
    build-packages:
      - libmarkdown2-dev
      - libglib2.0-dev
      - liblapack-dev
      - libluajit-5.1-dev
      - libspectre-dev
      - pkg-config
      - python3-dev
      - r-base-core
      - libxslt-dev
    stage-packages:
      - libmarkdown2
      - libglib2.0-0
      - liblapack3
      - libluajit-5.1-2
      - libspectre1
      - python3
      - r-base-core
      - libpython3.12
      - libncurses6
      - libreadline8
      - libgl1
    cmake-parameters:
      - -DCMAKE_INSTALL_PREFIX=/usr
      - -DCMAKE_BUILD_TYPE=Release
      - -DQT_MAJOR_VERSION=6
      - -DBUILD_WITH_QT6=ON
      - -DBUILD_TESTING=OFF
      - "-DCMAKE_FIND_ROOT_PATH=$CRAFT_STAGE\\;/snap/kde-qt6-core24-sdk/current\\;/snap/kf6-core24-sdk/current/usr"
      - "-DCMAKE_PREFIX_PATH=$CRAFT_STAGE\\;/snap/kde-qt6-core24-sdk/current\\;/snap/kf6-core24-sdk/current/usr"
    build-environment:
      - PATH: /snap/kf6-core24-sdk/current/usr/bin:/snap/kde-qt6-core24-sdk/current/usr/bin${PATH:+:$PATH}
      - PKG_CONFIG_PATH: /snap/kde-qt6-core24-sdk/current/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/pkgconfig:/snap/kf6-core24-sdk/current/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}
      - XDG_DATA_DIRS: $CRAFT_STAGE/usr/share:/snap/kf6-core24-sdk/current/usr/share:/snap/kde-qt6-core24-sdk/current/usr/share:/usr/share${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}
      - XDG_CONFIG_HOME: $CRAFT_STAGE/etc/xdg:/snap/kf6-core24-sdk/current/etc/xdg:/snap/kde-qt6-core24-sdk/current/etc/xdg:/etc/xdg${XDG_CONFIG_HOME:+:$XDG_CONFIG_HOME}
      - LD_LIBRARY_PATH: /snap/kde-qt6-core24-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:/snap/kde-qt6-core24-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libproxy:/snap/kde-qt6-core24-sdk/current/usr/lib:/snap/kf6-core24-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:/snap/kf6-core24-sdk/current/usr/lib:$CRAFT_STAGE/usr/lib:$CRAFT_STAGE/lib/:$CRAFT_STAGE/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR
  labplot:
    after:
      - qxlsx
      - qtmqtt
      - poppler
      - analitza
      - cantor
      - gsl
    parse-info:
      - usr/share/metainfo/org.kde.labplot.appdata.xml
    plugin: cmake
    build-packages:
      - libhdf5-dev
      - libboost-all-dev
      - libfftw3-dev
      - bison
      - libnetcdf-dev
      - libcfitsio-dev
      - libcerf-dev
      - liblz4-dev
      - liborigin2-dev
      - libreadstat-dev
      - libmatio-dev
      - libmarkdown2-dev
      - libfast5-dev
      - libxkbcommon-dev
      - libcups2-dev
      - liborigin2-dev
      - liborcus-dev
      - libeigen3-dev
      - libopenjp2-7-dev
      - libhdf5-dev
      - libnsl-dev
      - libnsl2
    stage-packages:
      - bison
      - discount
      - libasn1-8-heimdal
      - libbrotli1
      - libcerf2
      - libcfitsio10t64
      - libcurl3-gnutls
      - libfftw3-double3
      - libgssapi3t64-heimdal
      - libhcrypto5t64-heimdal
      - libhdf5-103-1t64
      - libheimbase1t64-heimdal
      - libheimntlm0t64-heimdal
      - libhx509-5t64-heimdal
      - libidn12
      - libijs-0.35
      - libjbig0
      - libjbig2dec0
      - libkrb5-26t64-heimdal
      - liblcms2-2
      - libldap2
      - liblz4-1
      - libmatio11
      - libnetcdf19
      - libnghttp2-14
      - libnspr4
      - libnss3
      - libopenjp2-7
      - libpaper1
      - libpsl5
      - libreadstat1
      - libroken19t64-heimdal
      - librtmp1
      - libsasl2-2
      - libspectre1
      - libssh-4
      - libtiff6
      - libwebp7
      - libwind0t64-heimdal
      - libxcb-keysyms1
      - libxcb1
      - libxkbcommon0
      - liborigin2-1v5
      - liborcus-0.18-0
      - libboost-system1.83.0
      - libboost-iostreams1.83.0
      - libboost-program-options1.83.0
      - libboost-filesystem1.83.0
      - libboost-date-time1.83.0
      - r-base-core
      - libluajit-5.1-2
    source: .
    source-type: local
    cmake-parameters:
      - -DCMAKE_INSTALL_PREFIX=/usr
      - -DCMAKE_BUILD_TYPE=Releaselibhdf5-dev
      - -DQT_MAJOR_VERSION=6
      - -DBUILD_WITH_QT6=ON
      - -DENABLE_TESTS=OFF
      - "-DCMAKE_FIND_ROOT_PATH=$CRAFT_STAGE\\;/snap/kde-qt6-core24-sdk/current\\;/snap/kf6-core24-sdk/current/usr"
      - "-DCMAKE_PREFIX_PATH=$CRAFT_STAGE\\;/snap/kde-qt6-core24-sdk/current\\;/snap/kf6-core24-sdk/current/usr"
    build-environment: *build_env
    prime:
      - -usr/lib/*/cmake/*
      - -usr/include/*
      - -usr/share/ECM/*
      - -usr/share/man/*
      - -usr/bin/X11
      - -usr/lib/gcc/$CRAFT_ARCH_TRIPLET_BUILD_FOR/6.0.0
      - -usr/lib/aspell/*
      - -usr/share/lintian
  gpu-2404:
    after: [labplot]
    source: https://github.com/canonical/gpu-snap.git
    plugin: dump
    override-prime: |
      craftctl default
      ${CRAFT_PART_SRC}/bin/gpu-2404-cleanup mesa-2404
    prime:
      - bin/gpu-2404-wrapper
  cleanup:
    after:
      - labplot
    plugin: nil
    build-snaps:
      - core24
      - kf6-core24
    override-prime: |
      set -eux
      for snap in "core24" "kf6-core24"; do
      cd "/snap/$snap/current" && find . -type f,l -exec rm -rf "${CRAFT_PRIME}/{}" \;
      done
