app-id: com.danplanet.chirp
runtime: org.freedesktop.Platform
runtime-version: '21.08'
sdk: org.freedesktop.Sdk
command: chirpw
finish-args:
  - --share=ipc
  - --socket=x11
  - --socket=wayland
  - --filesystem=home
  - --share=network
  - --device=all
modules:
  - upstream: https://github.com/flathub/shared-modules/tree/master/intltool
    name: intltool
    cleanup:
      - '*'
    sources:
      - type: archive
        url: https://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz
        sha256: 67c74d94196b153b774ab9f89b2fa6c6ba79352407037c8c14d5aeb334e959cd
  - upstream: https://github.com/flathub/shared-modules/tree/master/gtk2
    name: gtk2
    cleanup:
      - /bin
      - /share/gtk-2.0
      - /share/aclocal
      - /share/gtk-doc
      - /lib/pkgconfig
      - /lib/gtk-2.0/include
      - /include
      - '*.la'
    x-cpe:
      product: gtk+
    config-opts:
      - --disable-dependency-tracking
      - --disable-gtk-doc-html
      - --disable-introspection
      - --with-xinput=xfree
    sources:
      - type: archive
        url: https://download.gnome.org/sources/gtk+/2.24/gtk+-2.24.32.tar.xz
        sha256: b6c8a93ddda5eabe3bfee1eb39636c9a03d2a56c7b62828b359bf197943c582e
      - type: patch
        path: gtk2-use-adwaita-theme.patch
  - upstream: https://github.com/flathub/shared-modules/tree/master/gtk2
    name: gnome-themes-extra
    rm-configure: true
    config-opts:
      - --disable-dependency-tracking
      - --disable-gtk3-engine
    cleanup:
      - /share/themes/Adwaita/gtk-3.0
      - /share/themes/Adwaita-dark/gtk-3.0
      - /share/themes/HighContrast/gtk-3.0
      - '*.la'
    sources:
      - type: archive
        url: https://download.gnome.org/sources/gnome-themes-extra/3.28/gnome-themes-extra-3.28.tar.xz
        sha256: 7c4ba0bff001f06d8983cfc105adaac42df1d1267a2591798a780bac557a5819
      - type: shell
        //: We want to avoid generating icons as its 99% of the build time and gnome
          runtime has it
        commands:
          - sed -i 's/icons//' themes/HighContrast/Makefile.am
      - type: script
        commands:
          - autoreconf -fsi
  - name: ensure-gtk2-installed-correctly
    build-commands:
      - pkg-config --print-errors --modversion "gtk+-2.0"
      - pkg-config --exists --print-errors "gtk+-2.0 >= 2.8.0"
  - upstream: https://github.com/flathub/shared-modules/tree/master/python2.7
    name: python-2.7
    sources:
      - type: archive
        url: https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tar.xz
        sha256: b62c0e7937551d0cc02b8fd5cb0f544f9405bafc9a54d3808ed4594812edef43
    config-opts:
      - --enable-shared
      - --with-ensurepip=no
      - --with-system-expat
      - --with-system-ffi
      - --enable-loadable-sqlite-extensions=no
      - --with-dbmliborder=gdbm
      - --enable-unicode=ucs4
    post-install:
      - chmod 644 $FLATPAK_DEST/lib/libpython2.7.so.1.0
    cleanup:
      - /bin/2to3*
      - /bin/easy_install*
      - /bin/idle*
      - /bin/pydoc*
      - /bin/python*-config
      - /bin/pyvenv*
      - /include
      - /lib/pkgconfig
      - /lib/python*/config
      - /share
      - /lib/python*/test
      - /lib/python*#/test
      - /lib/python*#/tests
      - /lib/python*/lib-tk/test
      - /lib/python*/lib-dynload/_*_test.*.so
      - /lib/python*/lib-dynload/_test*.*.so
      - /lib/python*/idlelib
      - /lib/python*/tkinter*
      - /lib/python*/turtle*
      - /lib/python*/lib2to3*
      - /lib/python2.7/config/libpython2.7.a
  - name: pycairo
    buildsystem: simple
    sources:
      - type: archive
        url: https://github.com/pygobject/pycairo/releases/download/v1.13.1/pycairo-1.13.1.tar.gz
        sha256: d8f58de67ddd01eda9e5112de57599b7d0154d71c9474821e98866c228794641
    build-commands:
      - python2 setup.py install
  - name: pygobject
    sources:
      - type: archive
        url: https://download.gnome.org/sources/pygobject/2.28/pygobject-2.28.7.tar.xz
        sha256: bb9d25a3442ca7511385a7c01b057492095c263784ef31231ffe589d83a96a5a
  - why_is_this_here: pygtk 2.24 does not compile with pango-1.44 so downgrade it.
      TODO See if CHIRP runs without pango.
    name: pango-1.42
    sources:
      - type: archive
        url: https://download.gnome.org/sources/pango/1.42/pango-1.42.4.tar.xz
        sha256: 1d2b74cd63e8bd41961f2f8d952355aa0f9be6002b52c8aa7699d9f5da597c9d
  - name: pygtk
    sources:
      - type: archive
        url: https://download.gnome.org/sources/pygtk/2.24/pygtk-2.24.0.tar.gz
        sha256: 6e3e54fa6e65a69ac60bd58cb2e60a57f3346ac52efe995f3d10b6c38c972fd8
  - name: libxml2
    sources:
      - type: archive
        url: http://xmlsoft.org/sources/libxml2-2.9.9.tar.gz
        sha256: 94fb70890143e3c6549f265cee93ec064c80a84c42ad0f23e85ee1fd6540a871
    config-opts :
      - --with-python=/app
  - name: pyserial
    buildsystem: simple
    sources:
      - type: archive
        url: https://github.com/pyserial/pyserial/releases/download/v3.2.1/pyserial-3.2.1.tar.gz
        sha256: 1eecfe4022240f2eab5af8d414f0504e072ee68377ba63d3b6fe6e66c26f66d1
    build-commands:
      - python2 setup.py install
  - name: python-future
    upstream: https://github.com/PythonCharmers/python-future
    buildsystem: simple
    sources:
      - type: archive
        url: https://files.pythonhosted.org/packages/45/0b/38b06fd9b92dc2b68d58b75f900e97884c45bedd2ff83203d933cf5851c9/future-0.18.2.tar.gz
        sha256: b1bead90b70cf6ec3f0710ae53a525360fa360d306a86583adc6bf83a4db537d
    build-commands:
      - python2 setup.py install
  - name: python-suds
    buildsystem: simple
    sources:
      - type: archive
        url: https://github.com/suds-community/suds/archive/v0.8.4.tar.gz
        sha256: 3fc1c6dc961e0c9b421e8355bff45104e8db7edb8764b33939c4a84afa98116e
    build-commands:
      - python2 setup.py install
  - name: chirp
    buildsystem: simple
    sources:
      - type: archive
        path: chirp-daily.tar.gz
    build-commands:
      - sed -i 's/Icon=chirp/Icon=com.danplanet.chirp/' share/chirp.desktop
      - sed -i 's#share/pixmaps#share/icons/hicolor/128x128/apps#' setup.py
      - sed -i 's#chirp.png#com.danplanet.chirp.png#' setup.py
      - sed -i 's#chirp.png#com.danplanet.chirp.png#' chirp/ui/mainapp.py
      - mv share/chirp.png share/com.danplanet.chirp.png
      - mv share/chirp.desktop share/com.danplanet.chirp.desktop
      - python2 setup.py install
