From 74b00570ddee65d134a7d95f87c11b2458a64821 Mon Sep 17 00:00:00 2001 From: Owen D'Aprile Date: Sun, 25 Sep 2022 15:11:22 -0400 Subject: [PATCH 1/3] build: allow setting installation prefix Allow $PREFIX to be set during compilation, changing where the app is installed. This is used to change where the app is installed inside the Flatpak sandbox. --- samplebrain.pro | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/samplebrain.pro b/samplebrain.pro index 58ec2bc..ea4957b 100644 --- a/samplebrain.pro +++ b/samplebrain.pro @@ -50,12 +50,17 @@ QMAKE_CXXFLAGS += -O3 -Wall -Wno-unused -std=c++11 # assets RESOURCES = app/samplebrain.qrc -unix:desktopfile.path = /usr/share/applications/ +PREFIX = $$(PREFIX) +isEmpty(PREFIX) { + PREFIX = /usr +} + +unix:desktopfile.path = $$PREFIX/share/applications/ unix:desktopfile.files = desktop/samplebrain.desktop -unix:iconfile.path = /usr/share/icons/hicolor/scalable/apps +unix:iconfile.path = $$PREFIX/share/icons/hicolor/scalable/apps unix:iconfile.files = desktop/samplebrain.svg -target.path = /usr/bin +target.path = $$PREFIX/bin INSTALLS += target desktopfile iconfile From 9d7931c8c2875c0ffc03927ffb9aad9648df88cb Mon Sep 17 00:00:00 2001 From: Owen D'Aprile Date: Sun, 25 Sep 2022 15:12:23 -0400 Subject: [PATCH 2/3] linux: don't use hardcoded path for Exec and Icon Desktop files respect $PATH and $XDG_DATA_DIRS, so the full path does not need to be specified to either. This fixes the Flatpak build by allowing Flatpak to rewrite these to match the app ID. --- desktop/samplebrain.desktop | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/desktop/samplebrain.desktop b/desktop/samplebrain.desktop index 76b77e6..20d400b 100644 --- a/desktop/samplebrain.desktop +++ b/desktop/samplebrain.desktop @@ -3,8 +3,8 @@ Encoding=UTF-8 Type=Application Name=Samplebrain Comment=A sample masher designed by Aphex Twin -Exec=/usr/bin/samplebrain -Icon=/usr/share/icons/hicolor/scalable/apps/samplebrain.svg +Exec=samplebrain +Icon=samplebrain Terminal=false Categories=GNOME;Application; StartupNotify=true \ No newline at end of file From 129b6ea41699d2c23416b73ea73a38b87b209488 Mon Sep 17 00:00:00 2001 From: Owen D'Aprile Date: Sun, 25 Sep 2022 15:19:18 -0400 Subject: [PATCH 3/3] linux: add a Flatpak manifest This manifest will build a Flatpak from the current local source directory. --- build-aux/flatpak/README.md | 31 ++++++++ .../flatpak/org.thentrythis.Samplebrain.yaml | 73 +++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 build-aux/flatpak/README.md create mode 100644 build-aux/flatpak/org.thentrythis.Samplebrain.yaml diff --git a/build-aux/flatpak/README.md b/build-aux/flatpak/README.md new file mode 100644 index 0000000..5185fee --- /dev/null +++ b/build-aux/flatpak/README.md @@ -0,0 +1,31 @@ +# Flatpak Build Instructions + +## Prerequisites +To build the Flatpak, install the `flatpak` and `flatpak-builder` packages +from your repositories. Then, [add Flathub](https://flatpak.org/setup/). + +Now, install the KDE SDK: +```sh +flatpak install flathub org.kde.Sdk//5.15-22.08 +``` + +## Building and installing +To build and install the app locally: + +```sh +flatpak-builder --force-clean --install --user builddir build-aux/flatpak/org.thentrythis.Samplebrain.yaml +``` + +## Building and exporting +To build and export a Flatpak bundle: + +```sh +flatpak-builder --force-clean --repo=repo builddir build-aux/flatpak/org.thentrythis.Samplebrain.yaml +flatpak build-bundle repo org.thentrythis.Samplebrain.flatpak org.thentrythis.Samplebrain +``` + +To install the bundle: + +```sh +flatpak install org.thentrythis.Samplebrain.flatpak +``` \ No newline at end of file diff --git a/build-aux/flatpak/org.thentrythis.Samplebrain.yaml b/build-aux/flatpak/org.thentrythis.Samplebrain.yaml new file mode 100644 index 0000000..3aa1a20 --- /dev/null +++ b/build-aux/flatpak/org.thentrythis.Samplebrain.yaml @@ -0,0 +1,73 @@ +id: org.thentrythis.Samplebrain +runtime: org.kde.Platform +runtime-version: "5.15-22.08" +sdk: org.kde.Sdk + +rename-desktop-file: samplebrain.desktop +rename-icon: samplebrain + +command: samplebrain + +finish-args: + - "--share=ipc" + - "--socket=wayland" + - "--socket=fallback-x11" + - "--socket=pulseaudio" + - "--device=dri" + - "--share=network" + +cleanup: + - "/include" + - "/lib/cmake" + - "/lib/pkgconfig" + - "/share/doc" + +modules: + - name: libsndfile + buildsystem: cmake-ninja + config-opts: + - "-DCMAKE_BUILD_TYPE=Release" + - "-DBUILD_SHARED_LIBS=ON" + - "-DENABLE_EXTERNAL_LIBS=NO" + - "-DENABLE_CPACK=NO" + - "-DBUILD_PROGRAMS=OFF" + - "-DBUILD_EXAMPLES=OFF" + sources: + - type: archive + url: https://github.com/libsndfile/libsndfile/releases/download/1.1.0/libsndfile-1.1.0.tar.xz + sha256: 0f98e101c0f7c850a71225fb5feaf33b106227b3d331333ddc9bacee190bcf41 + + - name: portaudio + buildsystem: autotools + config-opts: + - "--with-alsa" + - "--without-jack" + - "--without-oss" + - "--without-asihpi" + sources: + - type: archive + url: http://files.portaudio.com/archives/pa_stable_v190700_20210406.tgz + sha256: 47efbf42c77c19a05d22e627d42873e991ec0c1357219c0d74ce6a2948cb2def + + - name: liblo + buildsystem: autotools + config-opts: + - "--disable-tests" + - "--disable-network-tests" + - "--disable-tools" + - "--disable-examples" + sources: + - type: archive + url: https://versaweb.dl.sourceforge.net/project/liblo/liblo/0.31/liblo-0.31.tar.gz + sha256: 2b4f446e1220dcd624ecd8405248b08b7601e9a0d87a0b94730c2907dbccc750 + + - name: samplebrain + buildsystem: qmake + build-options: + env: + PREFIX: /app + config-opts: + - "LIBS+=-L/app/lib" + sources: + - type: dir + path: ../../