{
    "app-id": "org.siril.Siril",
    "runtime": "org.gnome.Platform",
    "runtime-version": "48",
    "sdk": "org.gnome.Sdk",
    "command": "siril",
    "rename-icon": "org.siril.Siril",
    "finish-args": [
        "--share=ipc",
        "--share=network",
        "--socket=fallback-x11",
        "--socket=wayland",
        "--filesystem=host",
        "--talk-name=org.freedesktop.Flatpak",
        "--talk-name=org.gtk.vfs.*",
        "--filesystem=xdg-run/gvfs",
        "--filesystem=xdg-run/gvfsd",
        "--unset-env=LD_PRELOAD",
        "--env=LD_LIBRARY_PATH=/app/lib",
        "--env=PYTHONPATH=/app/lib/python3.13/site-packages"
    ],
    "modules": [
        {
        "name": "tcl",
        "subdir": "unix",
        "cleanup": [
            "/bin"
        ],
        "post-install": [
            "chmod u+w ${FLATPAK_DEST}/lib/libtcl*.so"
        ],
        "sources": [
            {
            "type": "archive",
            "url": "https://prdownloads.sourceforge.net/tcl/tcl8.6.16-src.tar.gz",
            "sha256": "91cb8fa61771c63c262efb553059b7c7ad6757afa5857af6265e4b0bdc2a14a5"
            }
        ]
        },
        {
            "name": "tk",
            "subdir": "unix",
            "cleanup": [
                "/bin",
                "/man"
            ],
            "post-install": [
                "chmod u+w ${FLATPAK_DEST}/lib/libtk*.so"
            ],
            "sources": [
                {
                    "type": "archive",
                    "url": "https://prdownloads.sourceforge.net/tcl/tk8.6.16-src.tar.gz",
                    "sha256": "be9f94d3575d4b3099d84bc3c10de8994df2d7aa405208173c709cc404a7e5fe"
                }
            ]
        },
        {
        "name": "python3.13",
        "config-opts": [
            "--enable-shared",
            "--prefix=/app",
            "--with-ensurepip=install",
            "--with-tcltk-includes=-I/app/include",
            "--with-tcltk-libs=-L/app/lib -ltcl8.6 -ltk8.6"
        ],
        "post-install": [
        "ln -svf ${FLATPAK_DEST}/bin/python3 ${FLATPAK_DEST}/bin/python",
        "echo '/app/lib' > ${FLATPAK_DEST}/lib/python3.13/site-packages/flatpak-python.pth"
        ],
        "sources": [
            {
            "type": "archive",
            "url": "https://www.python.org/ftp/python/3.13.5/Python-3.13.5.tar.xz",
            "sha256": "93e583f243454e6e9e4588ca2c2662206ad961659863277afcdb96801647d640"
            }
        ]
        },
        {
        "name": "python-setuptools",
        "buildsystem": "simple",
        "build-commands": [
            "/app/bin/python3 setup.py build",
            "/app/bin/python3 setup.py install --prefix=/app"
        ],
        "sources": [
            {
            "type": "archive",
            "url": "https://pypi.org/packages/source/s/setuptools/setuptools-69.0.3.tar.gz",
            "sha256": "be1af57fc409f93647f2e8e4573a142ed38724b8cdd389706a867bb4efcf1e78"
            }
        ]
        },
        {
            "name": "inih",
            "buildsystem": "meson",
            "config-opts": [
                "-Ddefault_library=shared",
                "-Ddistro_install=true",
                "-Dwith_INIReader=true"
            ],
            "sources": [
                {
                    "type": "archive",
                    "url": "https://github.com/benhoyt/inih/archive/refs/tags/r58.tar.gz",
                    "sha256": "e79216260d5dffe809bda840be48ab0eec7737b2bb9f02d2275c1b46344ea7b7"
                }
            ]
        },
        {
            "name": "exiv2",
            "buildsystem": "cmake-ninja",
            "builddir": true,
            "config-opts": [
                "-DCMAKE_BUILD_TYPE=Release",
                "-DEXIV2_BUILD_SAMPLES=OFF",
                "-DEXIV2_BUILD_UNIT_TESTS=OFF"
            ],
            "sources": [
                {
                    "type": "archive",
                    "url": "https://github.com/Exiv2/exiv2/archive/refs/tags/v0.28.5.tar.gz",
                    "sha256": "e1671f744e379a87ba0c984617406fdf8c0ad0c594e5122f525b2fb7c28d394d"
                }
            ]
        },
        {
            "name": "opencv",
            "buildsystem": "cmake-ninja",
            "builddir": true,
            "cleanup": [
                "/bin",
                "/include"
            ],
            "config-opts": [
                "-DCMAKE_BUILD_TYPE=Release",
                "-DBUILD_EXAMPLES=OFF",
                "-DOPENCV_GENERATE_PKGCONFIG=ON",
                "-DBUILD_DOCS=OFF",
                "-DBUILD_opencv_apps=OFF",
                "-DBUILD_opencv_python2=OFF",
                "-DBUILD_opencv_python3=OFF",
                "-DBUILD_PERF_TESTS=OFF",
                "-DBUILD_SHARED_LIBS=ON",
                "-DBUILD_TESTS=OFF",
                "-DBUILD_opencv_highgui=OFF",
                "-DBUILD_opencv_ml=OFF",
                "-DBUILD_opencv_dnn=OFF",
                "-DBUILD_opencv_imgcodecs=OFF",
                "-DBUILD_opencv_videoio=OFF",
                "-DBUILD_opencv_video=OFF",
                "-DBUILD_opencv_objdetect=OFF",
                "-DBUILD_opencv_photo=OFF",
                "-DBUILD_opencv_stitching=ON",
                "-DBUILD_opencv_gapi=OFF",
                "-DENABLE_PRECOMPILED_HEADERS=OFF",
                "-DFORCE_VTK=OFF",
                "-DWITH_FFMPEG=OFF",
                "-DWITH_GDAL=OFF",
                "-DWITH_IPP=OFF",
                "-DWITH_OPENEXR=OFF",
                "-DWITH_OPENGL=OFF",
                "-DWITH_QT=OFF",
                "-DWITH_TBB=OFF",
                "-DWITH_XINE=OFF",
                "-DBUILD_JPEG=ON",
                "-DBUILD_TIFF=ON",
                "-DBUILD_PNG=ON"
            ],
            "sources": [
                {
                    "type": "archive",
                    "url": "https://github.com/opencv/opencv/archive/refs/tags/4.12.0.zip",
                    "sha256": "fa3faf7581f1fa943c9e670cf57dd6ba1c5b4178f363a188a2c8bff1eb28b7e4"
                }
            ]
        },
        {
            "name": "cfitsio",
            "config-opts": [
                "--enable-reentrant",
                "CFLAGS=-std=c99"
            ],
            "make-args": ["shared"],
            "cleanup": [
                "/include",
                "*.a",
                "*.la",
                "/lib/pkgconfig"
            ],
            "sources": [
                {
                    "type": "archive",
                    "url": "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-4.2.0.tar.gz",
                    "disable-http-decompression": true,
                    "sha256": "eba53d1b3f6e345632bb09a7b752ec7ced3d63ec5153a848380f3880c5d61889"
                }
            ]
        },
        {
            "name": "libxml2",
            "buildsystem": "autotools",
            "config-opts": [
                "--disable-static",
                "--disable-python",
                "--disable-introspection",
                "--with-history",
                "--with-icu"
            ],
            "sources": [
                {
                    "type": "archive",
                    "url": "https://download.gnome.org/sources/libxml2/2.11/libxml2-2.11.5.tar.xz",
                    "sha256": "3727b078c360ec69fa869de14bd6f75d7ee8d36987b071e6928d4720a28df3a6"
                }
            ],
            "cleanup": [
                "/include",
                "/lib/pkgconfig",
                "/lib/cmake",
                "/bin/xmlcatalog",
                "/bin/xmllint",
                "/share/aclocal",
                "/share/doc",
                "/share/gtk-doc",
                "/share/man"
            ]
        },
        {
            "name": "gtksourceview4",
            "buildsystem": "meson",
            "config-opts": [
                "-Dgir=false",
                "-Dvapi=false"
            ],
            "sources": [
                {
                    "type": "archive",
                    "url": "https://deb.debian.org/debian/pool/main/g/gtksourceview4/gtksourceview4_4.8.4.orig.tar.xz",
                    "sha256": "7ec9d18fb283d1f84a3a3eff3b7a72b09a10c9c006597b3fbabbb5958420a87d"
                }
            ],
            "cleanup": [
                "/include",
                "*.la",
                "*.a",
                "/lib/pkgconfig",
                "/share/gtk-doc"
            ]
        },
        {
            "name": "libgit2",
            "buildsystem": "cmake",
            "config-opts": [
                "-DBUILD_EXAMPLES=OFF",
                "-DBUILD_TESTS=OFF",
                "-DUSE_SSH=ON"
            ],
             "modules": [
                {
                    "name": "libssh2",
                    "cleanup": [ "/bin" ],
                    "sources": [
                        {
                            "type": "archive",
                            "url": "https://github.com/libssh2/libssh2/releases/download/libssh2-1.11.0/libssh2-1.11.0.tar.bz2",
                            "sha256": "e56d81f01f090d3c6eaf5f56c645610fd1a90d92819541d0079ae363d1eed11e"
                        }
                    ]
                }
            ],
            "sources": [
                {
                    "type": "archive",
                    "url": "https://github.com/libgit2/libgit2/archive/refs/tags/v1.7.1.tar.gz",
                    "sha256": "17d2b292f21be3892b704dddff29327b3564f96099a1c53b00edc23160c71327"
                }
            ],
            "cleanup": [
                "/include",
                "*.la",
                "*.a",
                "/lib/cmake",
                "/lib/pkgconfig"
            ]
        },
        {
            "name": "libjxl",
            "buildsystem": "cmake-ninja",
            "builddir": true,
            "config-opts": [
                "-DBUILD_TESTING=OFF",
                "-DJPEGXL_ENABLE_BENCHMARK=OFF",
                "-DJPEGXL_ENABLE_DOXYGEN=OFF",
                "-DJPEGXL_ENABLE_EXAMPLES=OFF",
                "-DJPEGXL_ENABLE_JNI=OFF",
                "-DJPEGXL_ENABLE_MANPAGES=OFF",
                "-DJPEGXL_ENABLE_PLUGINS=OFF",
                "-DJPEGXL_ENABLE_SJPEG=OFF",
                "-DJPEGXL_ENABLE_SKCMS=OFF",
                "-DJPEGXL_ENABLE_TCMALLOC=OFF",
                "-DJPEGXL_ENABLE_TOOLS=OFF",
                "-DJPEGXL_FORCE_SYSTEM_BROTLI=ON",
                "-DJPEGXL_FORCE_SYSTEM_HWY=ON",
                "-DJPEGXL_FORCE_SYSTEM_LCMS2=ON",
                "-DJPEGXL_WARNINGS_AS_ERRORS=OFF"
            ],
            "modules": [
                {
                    "name": "libhwy",
                    "config-opts": [
                        "-DBUILD_TESTING=OFF",
                        "-DBUILD_SHARED_LIBS=OFF",
                        "-DHWY_ENABLE_EXAMPLES=OFF",
                        "-DHWY_ENABLE_TESTS=OFF",
                        "-DHWY_FORCE_STATIC_LIBS=ON"
                    ],
                    "buildsystem": "cmake-ninja",
                    "builddir": true,
                    "sources": [
                        {
                            "type": "archive",
                            "url": "https://github.com/google/highway/archive/refs/tags/1.0.7.tar.gz",
                            "sha256": "5434488108186c170a5e2fca5e3c9b6ef59a1caa4d520b008a9b8be6b8abe6c5"
                        }
                    ]
                }
            ],
            "sources": [
                {
                    "type": "archive",
                    "url": "https://github.com/libjxl/libjxl/archive/refs/tags/v0.10.2.tar.gz",
                    "sha256": "95e807f63143856dc4d161c071cca01115d2c6405b3d3209854ac6989dc6bb91"
                }
            ]
        },
        {
            "name": "wcslib",
            "config-opts": [
                "LIBS=-pthread -lcurl -lm",
                "--without-pgplot",
                "--without-cfitsio",
                "--disable-fortran"
            ],
            "cleanup": [
                "/include",
                "*.a",
                "*.la",
                "/lib/pkgconfig"
            ],
            "sources": [
                {
                    "type": "archive",
                    "url": "https://www.atnf.csiro.au/people/mcalabre/WCS/wcslib-8.3.tar.bz2",
                    "sha256": "431ea3417927bbc02b89bfa3415dc0b4668b0f21a3b46fb8a3525e2fcf614508"
                }
            ]
        },
        {
            "name": "gsl",
            "config-opts": [
                "--enable-shared",
                "--disable-static"
            ],
            "sources": [
                {
                    "type": "archive",
                    "url": "https://mirrors.ibiblio.org/gnu/gsl/gsl-2.7.1.tar.gz",
                    "sha256": "dcb0fbd43048832b757ff9942691a8dd70026d5da0ff85601e52687f6deeb34b"
                }
            ],
            "cleanup": [
                "/bin",
                "/include",
                "/lib/pkgconfig",
                "*.a",
                "*.la",
                "/share/aclocal",
                "/share/info",
                "/share/man"
            ]
        },
        {
            "name": "fftw3",
            "buildsystem": "autotools",
             "build-options": {
                "arch": {
                    "x86_64": {
                        "config-opts": [
                            "--enable-sse2",
                            "--enable-avx",
                            "--enable-avx-128-fma"
                        ]
                    },
                    "aarch64": {
                        "config-opts": [
                            "--enable-neon"
                        ]
                    }
                }
            },
            "config-opts": [
                "--enable-float",
                "--enable-threads",
                "--enable-openmp",
                "--disable-fortran"
            ],
            "sources": [
                {
                    "type": "archive",
                    "url": "http://fftw.org/fftw-3.3.10.tar.gz",
                    "sha256": "56c932549852cddcfafdab3820b0200c7742675be92179e59e6215b340e26467"
                }
            ],
            "cleanup": [
                "/bin",
                "/include",
                "*.a",
                "*.la",
                "/lib/cmake",
                "/lib/pkgconfig",
                "/share/info",
                "/share/man"
            ]
        },
        {
            "name": "libraw",
            "buildsystem": "autotools",
            "config-opts": [
                "--disable-examples",
                "--disable-jasper",
                "--disable-static",
                "--enable-jpeg",
                "--enable-lcms",
                "--enable-openmp"
            ],
            "cleanup": [ "/share/doc" ],
            "sources": [
                {
                    "type": "git",
                    "url": "https://github.com/LibRaw/LibRaw.git",
                    "commit": "8afe44cd0e96611ba3cb73779b83ad05e945634c"
                },
                {
                    "type": "shell",
                    "commands": [ "autoreconf -vfi" ]
                }
            ]
        },
        {
            "name": "ffms2",
            "config-opts": [
                "--with-pic",
                "--disable-static",
                "--enable-shared"
            ],
            "cleanup": [
                "/include",
                "/lib/pkgconfig"
            ],
            "sources": [
                {
                    "type": "git",
                    "url": "https://github.com/FFMS/ffms2.git",
                    "commit": "f20827cf280b669321cd5b62e01d744bc68c21fc"
                }
            ]
        },
        {
            "name" : "libheif",
            "buildsystem": "cmake",
            "config-opts": [ "-DWITH_GDK_PIXBUF=OFF" ],
            "cleanup": [ "/bin" ],
            "modules": [
                {
                    "name": "libde265",
                    "config-opts": [ "--disable-sherlock265" ],
                    "cleanup": [ "/bin" ],
                    "sources": [
                        {
                            "type": "archive",
                            "url": "https://github.com/strukturag/libde265/releases/download/v1.0.14/libde265-1.0.14.tar.gz",
                            "sha256": "99f46ef77a438be639aa3c5d9632c0670541c5ed5d386524d4199da2d30df28f"
                        }
                    ]
                }
            ],
            "sources" : [
                {
                    "url" : "https://github.com/strukturag/libheif/releases/download/v1.17.5/libheif-1.17.5.tar.gz",
                    "sha256" : "38ab01938ef419dbebb98346dc0b1c8bb503a0449ea61a0e409a988786c2af5b",
                    "type" : "archive"
                }
            ]
        },
        {
            "name": "libxisf",
            "buildsystem": "cmake",
            "config-opts": [
                "-DUSE_BUNDLED_ZLIB=OFF"
            ],
            "sources": [
                {
                    "type": "git",
                    "url": "https://gitea.nouspiro.space/nou/libXISF.git",
                    "branch": "master"
                }
            ],
            "cleanup": [
                "/include",
                "*.la",
                "*.a",
                "/lib/cmake",
                "/lib/pkgconfig"
            ],
             "modules": [
                {
                    "name": "pugixml",
                    "buildsystem": "cmake",
                    "sources": [
                        {
                            "type": "archive",
                            "url": "https://github.com/zeux/pugixml/releases/download/v1.14/pugixml-1.14.tar.gz",
                            "sha256": "2f10e276870c64b1db6809050a75e11a897a8d7456c4be5c6b2e35a11168a015"
                        }
                    ]
                },
                {
                    "name": "zstd",
                    "buildsystem": "cmake-ninja",
                    "subdir": "build/cmake",
                    "sources": [
                        {
                            "type": "archive",
                            "url": "https://github.com/facebook/zstd/releases/download/v1.5.6/zstd-1.5.6.tar.gz",
                            "sha256": "8c29e06cf42aacc1eafc4077ae2ec6c6fcb96a626157e0593d5e82a34fd403c1"
                        }
                    ]
                }
            ]
        },
        "shared-modules/intltool/intltool-0.51.json",
        {
            "name": "siril",
            "buildsystem": "meson",
            "config-opts": [
                "--buildtype=release",
                "-Dflatpak-id=${FLATPAK_ID}"
            ],
            "post-install": [
                "sed -i s/text-x-seq/${FLATPAK_ID}.text-x-seq/ ${FLATPAK_DEST}/share/mime/packages/siril.xml",
                "mv ${FLATPAK_DEST}/share/mime/packages/siril.xml ${FLATPAK_DEST}/share/mime/packages/${FLATPAK_ID}.xml",
                "mv ${FLATPAK_DEST}/share/icons/hicolor/scalable/mimetypes/text-x-seq.svg ${FLATPAK_DEST}/share/icons/hicolor/scalable/mimetypes/${FLATPAK_ID}.text-x-seq.svg"
            ],
            "sources": [
                {
                    "type": "dir",
                    "path": "../.."
                }
            ]
        }
    ]
}
