~sumner/sublime-music

2ed4106e5ec6b95e10d82d99eae945a406040ad4 — Sumner Evans 4 months ago cd2450a deprecate-official-flatpak
flatpak: deprecate official support

See #309
16 files changed, 10 insertions(+), 399 deletions(-)

D .builds/build-flatpak.yml
M .gitignore
M .gitlab-ci.yml
M CHANGELOG.rst
M CONTRIBUTING.md
M README.rst
D cicd/flatpak-build/Dockerfile
M cicd/publish-gitlab-release.sh
M docs/index.rst
D flatpak/.gitignore
D flatpak/app.sublimemusic.SublimeMusic.json
D flatpak/flatpak_build.sh
M pyproject.toml
M setup.cfg
M shell.nix
M sublime_music/__init__.py
D .builds/build-flatpak.yml => .builds/build-flatpak.yml +0 -27
@@ 1,27 0,0 @@
image: archlinux
packages:
  - dbus
  - flatpak
  - flatpak-builder
  - gobject-introspection
  - gtk3
  - mpv
  - python-cairo
  - python-gobject
  - python-pip
  - python-poetry
  - xorg-server-xvfb
sources:
  - https://git.sr.ht/~sumner/sublime-music
environment:
  REPO_NAME: sublime-music
artifacts:
  - sublime-music/flatpak/sublime-music.flatpak
# triggers:
#   - action: email
#     condition: failure
#     to: ~sumner/sublime-music-devel@lists.sr.ht
tasks:
  - build-flatpak: |
      cd ${REPO_NAME}/flatpak
      sudo REPO=repo ./flatpak_build.sh

M .gitignore => .gitignore +0 -3
@@ 1,7 1,4 @@
.direnv
flatpak/flatpak_build_dir/
flatpak/sublime-music.flatpak
flatpak/repo

# Created by https://www.gitignore.io/api/python
# Edit at https://www.gitignore.io/?templates=python

M .gitlab-ci.yml => .gitlab-ci.yml +0 -25
@@ 53,16 53,6 @@ build:
      - dist/*
    expire_in: 7 days

build_flatpak:
  image: registry.gitlab.com/sublime-music/sublime-music/flatpak-build:latest
  stage: build
  script:
    - cd flatpak
    - ./flatpak_build.sh
  artifacts:
    paths:
      - flatpak/sublime-music.flatpak

# Deploy documenation and code coverage to GitLab Pages
pages:
  only:


@@ 91,21 81,6 @@ publish_release:
# Scheduled Jobs
# =============================================================================

# Create the Docker image for Flatpak builds.
flatpak_docker:
  image: docker:1.13
  stage: build-containers
  only:
    variables:
      - $REBUILD_FLATPAK_DOCKER == "True"
  services:
    - docker:dind
  script:
    - docker version
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker build -t $CI_REGISTRY_IMAGE/flatpak-build:latest ./cicd/flatpak-build
    - docker push $CI_REGISTRY_IMAGE/flatpak-build

# Create the Docker image for Python testing/builds.
python_docker:
  image: docker:1.13

M CHANGELOG.rst => CHANGELOG.rst +7 -0
@@ 1,3 1,10 @@
v0.11.13
========

**Deprecations**

* Official Flatpak support has been dropped (#309)

v0.11.12
========


M CONTRIBUTING.md => CONTRIBUTING.md +0 -12
@@ 87,17 87,6 @@ If you do not want to activate the Poetry virtual environment, you can use:
$ poetry run sublime-music
```

### Building the flatpak

- A flatpak-builder environment must be setup on the build machine to do a
  flatpak build. This includes `org.gnome.SDK//3.36` and
  `org.gnome.Platform//3.36`.
- The `flatpak` folder contains the required files to build a flatpak package.
- The script `flatpak_build.sh` will run the required commands to grab the
  remaining dependencies and build the flatpak.
- You can install the Flatpak using: `flatpak install sublime-music.flatpak` and
  run it using `flatpak run app.sublimemusic.SublimeMusic`.

### Code Style

This project follows [PEP-8](https://www.python.org/dev/peps/pep-0008/)


@@ 201,7 190,6 @@ application to PyPi. A brief description of each of the stages is as follows:
`build`

* Builds the Python dist tar file
* Builds the flatpak.

`deploy`


M README.rst => README.rst +0 -24
@@ 135,30 135,6 @@ the package with::

    sudo apt install sublime-music

**Via Flatpak**:

In the future, you will be able to install via Flathub. For now, if you want to
try the Flatpak, you will have to install it manually by visiting the Releases_
page and downloading the ``.flatpak`` file from there.

Next, install the dependencies for Sublime Music. If you haven't already, follow
the instructions to setup ``flathub`` here:
https://docs.flatpak.org/en/latest/using-flatpak.html#add-a-remote

Then, install the dependencies of Sublime Music::

    sudo flatpak install -y org.gnome.Platform//3.38 org.gnome.Sdk//3.38

And finally, install Sublime Music with::

    sudo flatpak install sublime-music.flatpak

To run Sublime, use the following command::

    flatpak run app.sublimemusic.SublimeMusic

.. _Releases: https://gitlab.com/sublime-music/sublime-music/-/releases

**Via PyPi**::

    pip install sublime-music

D cicd/flatpak-build/Dockerfile => cicd/flatpak-build/Dockerfile +0 -17
@@ 1,17 0,0 @@
FROM fedora:30

LABEL maintainer robozman "https://gitlab.com/robozman"

VOLUME [ "/sys/fs/cgroup", "/tmp", "/run" ]


RUN dnf -y update && \
    dnf install -y flatpak flatpak-builder ostree fuse wget curl elfutils dconf git bzip2 bzr python3 python3-pip && \
    dnf clean all

RUN flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo

RUN flatpak install -y org.gnome.Platform//3.38 && \
    flatpak install -y org.gnome.Sdk//3.38

RUN pip3 install requirements-parser

M cicd/publish-gitlab-release.sh => cicd/publish-gitlab-release.sh +0 -23
@@ 48,29 48,6 @@ if [[ "${milestone}" != "" ]]; then
    milestones=",\"milestones\":[\"${milestone}\"]"
fi

# Determine whether or not to include the Flatpak build.
set +e
failed=$(curl \
    --header "PRIVATE-TOKEN: ${RELEASE_PUBLISH_TOKEN}" \
    --request GET \
    "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/pipelines/${CI_PIPELINE_ID}/jobs?scope[]=failed" \
    | grep '"name":"build_flatpak"')
set -e

assets=""
if [[ $failed == "" ]]; then
    assets=",
    \"assets\": {
        \"links\": [
            {
                \"name\": \"sublime-music-${CI_COMMIT_TAG}.flatpak\",
                \"url\": \"${CI_PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_TAG}/raw/flatpak/sublime-music.flatpak?job=build_flatpak\"
            }
        ]
    }
    "
fi

url="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/releases"
data="
{

M docs/index.rst => docs/index.rst +0 -24
@@ 109,30 109,6 @@ the package with::

    sudo apt install sublime-music

**Via Flatpak**:

In the future, you will be able to install via Flathub. For now, if you want to
try the Flatpak, you will have to install it manually by visiting the Releases_
page and downloading the ``.flatpak`` file from there.

Next, install the dependencies for Sublime Music. If you haven't already, follow
the instructions to setup ``flathub`` here:
https://docs.flatpak.org/en/latest/using-flatpak.html#add-a-remote

Then, install the dependencies of Sublime Music::

    sudo flatpak install -y org.gnome.Platform//3.38 org.gnome.Sdk//3.38

And finally, install Sublime Music with::

    sudo flatpak install sublime-music.flatpak

To run Sublime, use the following command::

    flatpak run app.sublimemusic.SublimeMusic

.. _Releases: https://gitlab.com/sublime-music/sublime-music/-/releases

**Via PyPi**::

    pip install sublime-music

D flatpak/.gitignore => flatpak/.gitignore +0 -3
@@ 1,3 0,0 @@
.flatpak-builder/
flatpak-builder-tools/
pypi-dependencies.json

D flatpak/app.sublimemusic.SublimeMusic.json => flatpak/app.sublimemusic.SublimeMusic.json +0 -197
@@ 1,197 0,0 @@
{
  "app-id": "app.sublimemusic.SublimeMusic",
  "runtime": "org.gnome.Platform",
  "runtime-version": "3.38",
  "sdk": "org.gnome.Sdk",
  "command": "sublime-music",
  "rename-icon": "sublime-music",
  "rename-desktop-file": "sublime-music.desktop",
  "rename-appdata-file": "sublime-music.metainfo.xml",
  "add-extentions": {
    "org.freedesktop.Platform.ffmpeg-full": {
      "directory": "lib/ffmpeg",
      "version": "19.08",
      "add-ld-path": "."
    }
  },
  "finish-args": [
    "--share=ipc",
    "--socket=fallback-x11",
    "--socket=wayland",
    "--share=network",
    "--socket=pulseaudio",
    "--talk-name=org.freedesktop.Notifications",
    "--own-name=org.mpris.MediaPlayer2.sublimemusic",
    "--filesystem=xdg-config/sublime-music",
    "--filesystem=xdg-cache/sublime-music",
    "--filesystem=xdg-data/sublime-music",
    "--env=TMPDIR=/tmp"
  ],
  "modules": [
    {
      "name": "icons-and-metadata",
      "buildsystem": "simple",
      "build-commands": [
        "install -Dm644 16.png /app/share/icons/hicolor/16x16/apps/sublime-music.png",
        "install -Dm644 22.png /app/share/icons/hicolor/22x22/apps/sublime-music.png",
        "install -Dm644 32.png /app/share/icons/hicolor/32x32/apps/sublime-music.png",
        "install -Dm644 36.png /app/share/icons/hicolor/36x36/apps/sublime-music.png",
        "install -Dm644 48.png /app/share/icons/hicolor/48x48/apps/sublime-music.png",
        "install -Dm644 64.png /app/share/icons/hicolor/64x64/apps/sublime-music.png",
        "install -Dm644 72.png /app/share/icons/hicolor/72x72/apps/sublime-music.png",
        "install -Dm644 96.png /app/share/icons/hicolor/96x96/apps/sublime-music.png",
        "install -Dm644 128.png /app/share/icons/hicolor/128x128/apps/sublime-music.png",
        "install -Dm644 192.png /app/share/icons/hicolor/192x192/apps/sublime-music.png",
        "install -Dm644 512.png /app/share/icons/hicolor/512x512/apps/sublime-music.png",
        "install -Dm644 sublime-music.desktop /app/share/applications/sublime-music.desktop",
        "install -Dm644 sublime-music.metainfo.xml /app/share/metainfo/sublime-music.metainfo.xml"
      ],
      "sources": [
        {
          "type": "dir",
          "path": "../logo/rendered"
        },
        {
          "type": "file",
          "path": "../sublime-music.desktop"
        },
        {
          "type": "file",
          "path": "../sublime-music.metainfo.xml"
        }
      ]
    },
    {
      "name": "sublime",
      "buildsystem": "simple",
      "build-commands": [
        "pip3 install --prefix=/app ."
      ],
      "build-options": {
        "build-args": [
          "--share=network"
        ]
      },
      "sources": [
        {
          "type": "dir",
          "path": ".."
        }
      ],
      "modules": [
        "pypi-dependencies.json",
        {
          "name": "libmpv",
          "cleanup": [
            "/include",
            "/lib/pkgconfig",
            "/share/man"
          ],
          "buildsystem": "simple",
          "build-commands": [
            "python3 waf configure --prefix=/app --enable-libmpv-shared --disable-cplayer --disable-build-date --disable-oss-audio --disable-alsa",
            "python3 waf build",
            "python3 waf install"
          ],
          "sources": [
            {
              "type": "archive",
              "url": "https://github.com/mpv-player/mpv/archive/v0.30.0.tar.gz",
              "sha256": "33a1bcb7e74ff17f070e754c15c52228cf44f2cefbfd8f34886ae81df214ca35"
            },
            {
              "type": "file",
              "url": "https://waf.io/waf-2.0.12",
              "sha256": "0979ca87f45928e0d752049ab2f43be8551249be73dc5563b944ec54f8871d1f",
              "dest-filename": "waf"
            }
          ],
          "modules": [
            {
              "name": "luajit",
              "no-autogen": true,
              "cleanup": [
                "/bin",
                "/lib/*.a",
                "/include",
                "/lib/pkgconfig",
                "/share/man"
              ],
              "sources": [
                {
                  "type": "archive",
                  "url": "http://luajit.org/download/LuaJIT-2.1.0-beta3.tar.gz",
                  "sha256": "1ad2e34b111c802f9d0cdf019e986909123237a28c746b21295b63c9e785d9c3"
                },
                {
                  "type": "shell",
                  "commands": [
                    "sed -i 's|/usr/local|/app|' ./Makefile"
                  ]
                }
              ]
            },
            {
              "name": "libass",
              "cleanup": [
                "/include",
                "/lib/*.la",
                "/lib/pkgconfig"
              ],
              "config-opts": [
                "--disable-static"
              ],
              "sources": [
                {
                  "type": "archive",
                  "url": "https://github.com/libass/libass/releases/download/0.14.0/libass-0.14.0.tar.xz",
                  "sha256": "881f2382af48aead75b7a0e02e65d88c5ebd369fe46bc77d9270a94aa8fd38a2"
                }
              ]
            },
            {
              "name": "uchardet",
              "buildsystem": "cmake-ninja",
              "config-opts": [
                "-DCMAKE_BUILD_TYPE=Release",
                "-DBUILD_STATIC=0"
              ],
              "cleanup": [
                "/bin",
                "/include",
                "/lib/pkgconfig",
                "/share/man"
              ],
              "sources": [
                {
                  "type": "archive",
                  "url": "https://www.freedesktop.org/software/uchardet/releases/uchardet-0.0.6.tar.xz",
                  "sha256": "8351328cdfbcb2432e63938721dd781eb8c11ebc56e3a89d0f84576b96002c61"
                }
              ]
            }
          ]
        },
        {
          "name": "libhandy",
          "buildsystem": "meson",
          "builddir": true,
          "config-opts": [
            "-Dexamples=false",
            "-Dglade_catalog=disabled",
            "-Dintrospection=disabled",
            "-Dtests=false",
            "-Dvapi=false"
          ],
          "sources": [
            {
              "type": "git",
              "branch": "flap-handle",
              "url": "https://gitlab.gnome.org/BenjaminSchaaf/libhandy.git"
            }
          ]
        }
      ]
    }
  ]
}

D flatpak/flatpak_build.sh => flatpak/flatpak_build.sh +0 -31
@@ 1,31 0,0 @@
#!/usr/bin/env bash

set -xe

ARCH=${ARCH:""}
REPO=${REPO:-/repo}
APPID=app.sublimemusic.SublimeMusic

if [ -z "$ARCH" ]; then
    ARCH_ARG=""
else
    ARCH_ARG="--arch=$ARCH"
fi

pip3 install toml
flatpak install -y org.gnome.Platform/$ARCH/3.38
flatpak install -y org.gnome.Sdk/$ARCH/3.38

rm -rf flatpak-builder-tools
git clone https://github.com/flatpak/flatpak-builder-tools.git

python3 ./flatpak-builder-tools/poetry/flatpak-poetry-generator.py \
    ../poetry.lock \
    --production \
    -o pypi-dependencies.json

mkdir -p $REPO

flatpak-builder --force-clean $ARCH_ARG --repo=$REPO flatpak_build_dir ${APPID}.json

flatpak build-bundle $ARCH_ARG $REPO sublime-music.flatpak $APPID

M pyproject.toml => pyproject.toml +1 -8
@@ 1,6 1,6 @@
[tool.poetry]
name = "sublime_music"
version = "0.11.12"
version = "0.11.13"
description = "A native GTK *sonic client."
license = "GPL-3.0-or-later"
authors = ["Sumner Evans <inquiries@sumnerevans.com>"]


@@ 74,10 74,3 @@ server = ["bottle"]
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.black]
exclude = '''
(
  /flatpak/
)
'''

M setup.cfg => setup.cfg +1 -2
@@ 1,6 1,6 @@
[flake8]
extend-ignore = E203, E402, E722, E731, W503, ANN002, ANN003, ANN101, ANN102, ANN204
exclude = .git,__pycache__,build,dist,flatpak,.venv
exclude = .git,__pycache__,build,dist,.venv
max-line-length = 88
suppress-none-returning = True
suppress-dummy-args = True


@@ 56,7 56,6 @@ log_cli_level = 10
addopts =
    -vvv
    --doctest-modules
    --ignore-glob='flatpak'
    --ignore-glob='cicd'
    --cov=sublime_music
    --cov-report html

M shell.nix => shell.nix +0 -2
@@ 28,8 28,6 @@ pkgs.mkShell {

  buildInputs = with pkgs; [
    bashInteractive
    flatpak
    flatpak-builder
    gcc
    git
    glib

M sublime_music/__init__.py => sublime_music/__init__.py +1 -1
@@ 1,1 1,1 @@
__version__ = "0.11.12"
__version__ = "0.11.13"