{
  "app-id": "ch.theologeek.Manuskript",
  "runtime": "org.kde.Platform",
  "runtime-version": "5.15-21.08",
  "base": "io.qt.qtwebengine.BaseApp",
  "base-version": "5.15-21.08",
  "sdk": "org.kde.Sdk",
  "add-extensions": {
      "org.freedesktop.Sdk.Extension.texlive": {
        "directory": "texlive",
        "subdirectories": true,
        "autodelete": true,
        "version": "21.08"
      }
  },
  "command": "manuskript",
  "finish-args": [
	"--share=ipc",
	"--socket=x11",
	"--device=dri",
	
	/* access to local files */
    "--filesystem=home",
    "--env=QT_QPA_PLATFORM=xcb",
    "--env=TMPDIR=/var/tmp",
    
    /* add paths of TeXlive Flatpak extension binaries */
    "--env=PATH=/usr/bin:/app/bin:/app/texlive/bin:/app/texlive/bin/x86_64-linux:/app/texlive/bin/aarch64-linux"
    
    /* allow using the QtWebEngine */
    "--env=QTWEBENGINEPROCESS_PATH=/app/bin/QtWebEngineProcess"
  ],
  "modules": [
    "python3-modules.json",
    {
      "name": "sip",
      "buildsystem": "simple",
      "build-commands": [
        "python3 configure.py -b ${FLATPAK_DEST}/bin -d ${FLATPAK_DEST}/lib/python3.9/site-packages -e ${FLATPAK_DEST}/include -v ${FLATPAK_DEST}/share/sip --stubsdir=/app/lib/python3.9/site-packages --sip-module PyQt5.sip",
        "make -j $FLATPAK_BUILDER_N_JOBS",
        "make install"
      ],
      "sources": [
      	{
          "type" : "archive",
          "url" : "https://distfiles.macports.org/py-sip/sip-4.19.22.tar.gz",
          "sha256" : "e1b768824ec1a2ee38dd536b6b6b3d06de27b00a2f5f55470d1b512306e3be45"
        }
      ]
    },
	{
      "name" : "pyqt5",
      "buildsystem": "simple",
      "build-commands": [
        "python3 configure.py --confirm-license --sip-incdir=/app/include --bindir=/app/bin --destdir=/app/lib/python3.9/site-packages --designer-plugindir=/app/lib/plugins/designer --qml-plugindir=/app/lib/plugins/PyQt5 --sipdir=/app/share/sip --stubsdir=/app/lib/python3.9/site-packages/PyQt5 --sip=/app/bin/sip",
        "make -j $FLATPAK_BUILDER_N_JOBS",
        "make install"
      ],
      "sources" : [
        {
          "type" : "archive",
          "url": "https://files.pythonhosted.org/packages/4d/81/b9a66a28fb9a7bbeb60e266f06ebc4703e7e42b99e3609bf1b58ddd232b9/PyQt5-5.14.2.tar.gz",
          "sha256": "bd230c6fd699eabf1ceb51e13a8b79b74c00a80272c622427b80141a22269eb0"
        }
      ]
    },
    {
      "name": "enchant",
      "buildsystem": "autotools",
      "sources": [
        {
          "type": "archive",
          "url": "https://github.com/AbiWord/enchant/releases/download/v2.3.1/enchant-2.3.1.tar.gz",
          "sha256": "7b4b1afcf2cd8bfa691deea6188404d337f23174bbc39b9c2add2bf340736e9c"
        }
      ]
    },
    {
      "name": "pandoc",
      "buildsystem": "simple",
      "build-commands": [
        "cp -R . /app/"
      ],
      "sources": [
	    {
          "type": "archive",
          "url": "https://github.com/jgm/pandoc/releases/download/2.16.1/pandoc-2.16.1-linux-amd64.tar.gz",
          "sha256": "3fe3d42179af289d4f5452b9317d2bc9cd139a4f33a37f68d70e128f1d415aa4",
		  "only-arches": [ "x86_64" ]
        },
	    {
          "type": "archive",
          "url": "https://github.com/jgm/pandoc/releases/download/2.16.1/pandoc-2.16.1-linux-arm64.tar.gz",
          "sha256": "c1130d917fb6e8c9a29cadc52ef9e4c4405450868d5f7dd3018f413755ac2b31",
		  "only-arches": [ "aarch64" ]
        }
      ],
	  "modules": [
		{
		  "name": "texlive-extension",
		  "buildsystem": "simple",
		  "build-commands": [
			"mkdir /app/texlive"
		  ]
		}
	  ]
    },
    {
      "name": "manuskript",
      "buildsystem": "simple",
      "build-commands": [
        "mkdir -p /app/share/manuskript/",
        "cp -R . /app/share/manuskript/",
        "mkdir -p /app/bin/",
        "ln -s ../share/manuskript/bin/manuskript /app/bin/manuskript"
      ],
      "sources": [
	    {
          "type": "archive",
          "url": "https://github.com/olivierkes/manuskript/archive/0.12.0.zip",
          "sha256": "676da858d0a3bb658234191b2b36c56dbb07f03371469990de34f7701842c441"
        },
		{
		  "type": "file",
		  "path": "ch.theologeek.Manuskript.desktop"
		},
		{
		  "type": "file",
		  "path": "ch.theologeek.Manuskript.appdata.xml"
		}
      ],
	  "post-install": [
		  /* install icons in several resolutions */
		  "install -Dm644 icons/Manuskript/icon-16px.png /app/share/app-info/icons/flatpak/16x16/ch.theologeek.Manuskript.png",
		  "install -Dm644 icons/Manuskript/icon-32px.png /app/share/app-info/icons/flatpak/32x32/ch.theologeek.Manuskript.png",
		  "install -Dm644 icons/Manuskript/icon-64px.png /app/share/app-info/icons/flatpak/64x64/ch.theologeek.Manuskript.png",
		  "install -Dm644 icons/Manuskript/icon-128px.png /app/share/app-info/icons/flatpak/128x128/ch.theologeek.Manuskript.png",
		  "install -Dm644 icons/Manuskript/icon-256px.png /app/share/app-info/icons/flatpak/256x256/ch.theologeek.Manuskript.png",
		  "install -Dm644 icons/Manuskript/icon-512px.png /app/share/app-info/icons/flatpak/512x512/ch.theologeek.Manuskript.png",
		  
		  /* install desktop file and application data */
		  "install -Dm644 ch.theologeek.Manuskript.desktop /app/share/desktop/ch.theologeek.Manuskript.desktop",
		  "install -Dm644 ch.theologeek.Manuskript.appdata.xml /app/share/appdata/ch.theologeek.Manuskript.appdata.xml"
	  ]
    }
  ]
}
