From c4c32b1615bfcc3d914a4baab3f467f5f04e33c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20J=C3=BCrgens?= Date: Wed, 13 Jul 2022 22:00:30 +0200 Subject: [PATCH] it doesnt work --- CMakeLists.txt | 14 ++++++++------ scripts/Dockerfile | 4 ++++ scripts/build-appimage.sh | 23 +++++++++++++++++++++++ scripts/prepare-container.sh | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 scripts/Dockerfile create mode 100755 scripts/build-appimage.sh create mode 100755 scripts/prepare-container.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 3961517..0e90596 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.11) project(discord-screenaudio) set(CMAKE_CXX_STANDARD 17) @@ -13,7 +13,7 @@ find_package(Qt5 CONFIG REQUIRED COMPONENTS WebEngineWidgets ) -set(discord-screenaudio_SRC +set(${CMAKE_PROJECT_NAME}_SRC src/main.cpp src/mainwindow.cpp src/virtmic.cpp @@ -27,9 +27,11 @@ include(FetchContent) FetchContent_Declare(rohrkabel GIT_REPOSITORY "https://github.com/Soundux/rohrkabel") FetchContent_MakeAvailable(rohrkabel) -add_executable(discord-screenaudio ${discord-screenaudio_SRC}) +add_executable(${CMAKE_PROJECT_NAME} ${${CMAKE_PROJECT_NAME}_SRC}) -target_link_libraries(discord-screenaudio Qt5::Widgets Qt5::WebEngineWidgets rohrkabel) +target_link_libraries(${CMAKE_PROJECT_NAME} Qt5::Widgets Qt5::WebEngineWidgets rohrkabel) -install(TARGETS discord-screenaudio DESTINATION bin) -install(PROGRAMS assets/discord-screenaudio.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications) +install(TARGETS ${CMAKE_PROJECT_NAME} DESTINATION bin) +install(PROGRAMS assets/${CMAKE_PROJECT_NAME}.desktop DESTINATION share/applications) + +add_custom_target(appimage ${CMAKE_SOURCE_DIR}/scripts/build-appimage.sh WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) diff --git a/scripts/Dockerfile b/scripts/Dockerfile new file mode 100644 index 0000000..ec3c4ba --- /dev/null +++ b/scripts/Dockerfile @@ -0,0 +1,4 @@ +FROM ubuntu:jammy +ADD ./prepare-container.sh /tmp/prepare-container.sh +RUN /tmp/prepare-container.sh +WORKDIR /work diff --git a/scripts/build-appimage.sh b/scripts/build-appimage.sh new file mode 100755 index 0000000..f388d02 --- /dev/null +++ b/scripts/build-appimage.sh @@ -0,0 +1,23 @@ +#!/usr/bin/bash + +set -e + +# Check if inside of docker container +if [ ! -f /.dockerenv ]; then + # Check if docker is available + if ! command -v docker >/dev/null 2>&1; then + echo "Error: Docker is not available." + exit 1 + fi + docker run --rm -v "$PWD":/work discord-screenaudio-buildenv bash /work/scripts/build-appimage.sh + exit 0 +fi + +tmpdir="$(mktemp -d)" +builddir="$tmpdir/build" +appdir="$tmpdir/AppDir" +cmake -B "$builddir" -S "$PWD" +cmake --build "$builddir" --config Release +DESTDIR="$appdir" cmake --install "$builddir" --prefix "/usr" + +linuxdeployqt "$appdir/usr/share/applications/discord-screenaudio.desktop" -appimage -extra-plugins=iconengines,platformthemes/libqgtk3.so diff --git a/scripts/prepare-container.sh b/scripts/prepare-container.sh new file mode 100755 index 0000000..87da3c3 --- /dev/null +++ b/scripts/prepare-container.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +set -e +cd "$(dirname "$0")" + +if [ ! -f /.dockerenv ]; then + # Check if docker is available + if ! command -v docker >/dev/null 2>&1; then + echo "Error: Docker is not available." + exit 1 + fi + docker build -t discord-screenaudio-buildenv . + exit 0 +fi + +echo "-> Installing dependencies with apt..." +export DEBIAN_FRONTEND=noninteractive +apt-get update +apt-get install -y curl build-essential qtbase5-dev qtwebengine5-dev qt5-qmake cmake git libpipewire-0.3-dev + +echo "-> Installing linuxdeployqt..." +tmpdir="$(mktemp -d)" +curl -Lo "$tmpdir/linuxdeployqt.AppImage" "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage" +chmod +x "$tmpdir/linuxdeployqt.AppImage" +sed '0,/AI\x02/{s|AI\x02|\x00\x00\x00|}' -i -i "$tmpdir/linuxdeployqt.AppImage" +(cd "$tmpdir" && ./linuxdeployqt.AppImage --appimage-extract) +mv -v "$tmpdir/squashfs-root" "/opt/linuxdeployqt" +ln -sv "/opt/linuxdeployqt/AppRun" "/usr/local/bin/linuxdeployqt" + +echo "-> Cleaning up..." +rm -rf "$tmpdir" +rm /tmp/prepare-container.sh +apt-get clean