diff --git a/.CI/CreateAppImage.sh b/.CI/CreateAppImage.sh index 486c14ff6..d245ec9f1 100755 --- a/.CI/CreateAppImage.sh +++ b/.CI/CreateAppImage.sh @@ -57,3 +57,6 @@ exec "$here/usr/bin/chatterino" "$@"' > appdir/AppRun chmod a+x appdir/AppRun ./appimagetool-x86_64.AppImage appdir + +# TODO: Create appimage in a unique directory instead maybe idk? +rm -rf appdir diff --git a/.CI/CreateUbuntuDeb.sh b/.CI/CreateUbuntuDeb.sh index 752f211b3..ac627d649 100755 --- a/.CI/CreateUbuntuDeb.sh +++ b/.CI/CreateUbuntuDeb.sh @@ -1,6 +1,37 @@ #!/bin/sh + set -e +breakline() { + printf "================================================================================\n\n" +} + +# Configured in the CI step +install_prefix="appdir/usr" + +# The directory we finally pack into our .deb package +packaging_dir="package" + +# Get the Ubuntu Release (e.g. 20.04 or 22.04) +ubuntu_release="$(lsb_release -rs)" + +# Refactor opportunity: +case "$ubuntu_release" in + 20.04) + dependencies="libc6, libstdc++6, libqt5core5a, libqt5concurrent5, libqt5dbus5, libqt5gui5, libqt5network5, libqt5svg5, libqt5widgets5, qt5-image-formats-plugins, libboost-filesystem1.71.0" + ;; + 22.04) + dependencies="libc6, libstdc++6, libqt5core5a, libqt5concurrent5, libqt5dbus5, libqt5gui5, libqt5network5, libqt5svg5, libqt5widgets5, qt5-image-formats-plugins, libboost-filesystem1.74.0" + ;; + *) + echo "Unsupported Ubuntu release $ubuntu_release" + exit 1 + ;; +esac + +echo "Building Ubuntu .deb file on '$ubuntu_release'" +echo "Dependencies: $dependencies" + if [ ! -f ./bin/chatterino ] || [ ! -x ./bin/chatterino ]; then echo "ERROR: No chatterino binary file found. This script must be run in the build folder, and chatterino must be built first." exit 1 @@ -8,33 +39,53 @@ fi chatterino_version=$(git describe 2>/dev/null | cut -c 2-) || true if [ -z "$chatterino_version" ]; then + # Fall back to this in case the build happened outside of a git repo chatterino_version="0.0.0-dev" - echo "Falling back to setting the version to '$chatterino_version'" -else - echo "Found Chatterino version $chatterino_version via git" fi -rm -vrf "./package" || true # delete any old packaging dir +# Make sure no old remnants of a previous packaging remains +rm -vrf "$packaging_dir" -# create ./package/ from scratch -mkdir package/DEBIAN -p -packaging_dir="$(realpath ./package)" +mkdir -p "$packaging_dir/DEBIAN" echo "Making control file" cat >> "$packaging_dir/DEBIAN/control" << EOF Package: chatterino -Section: net -Priority: optional +Version: $chatterino_version Architecture: amd64 Maintainer: Mm2PL -Description: Testing out chatterino as a Ubuntu package -Depends: libc6, libqt5concurrent5, libqt5core5a, libqt5dbus5, libqt5gui5, libqt5multimedia5, libqt5network5, libqt5svg5, libqt5widgets5, libssl1.1, libstdc++6 +Depends: $dependencies +Section: net +Priority: optional +Homepage: https://github.com/Chatterino/chatterino2 +Description: Ubuntu package built for $ubuntu_release EOF -echo "Version: $chatterino_version" >> "$packaging_dir/DEBIAN/control" +cat "$packaging_dir/DEBIAN/control" +breakline -echo "Running make install in package dir" -DESTDIR="$packaging_dir" make INSTALL_ROOT="$packaging_dir" -j"$(nproc)" install; find "$packaging_dir/" -echo "" -echo "Building package..." +echo "Running make install" +make install +find "$install_prefix" +breakline + + +echo "Merge install into packaging dir" +cp -rv "$install_prefix/" "$packaging_dir/" +find "$packaging_dir" +breakline + + +echo "Building package" dpkg-deb --build "$packaging_dir" "Chatterino-x86_64.deb" +breakline + + +echo "Package info" +dpkg --info Chatterino-x86_64.deb +breakline + + +echo "Package contents" +dpkg --contents Chatterino-x86_64.deb # Shows folders and files inside .deb file +breakline diff --git a/.docker/Dockerfile-ubuntu-20.04-build b/.docker/Dockerfile-ubuntu-20.04-build new file mode 100644 index 000000000..f5a8ffa7c --- /dev/null +++ b/.docker/Dockerfile-ubuntu-20.04-build @@ -0,0 +1,54 @@ +FROM ubuntu:20.04 + +ENV TZ=UTC +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +RUN apt-get update && apt-get -y install --no-install-recommends \ + cmake \ + virtualenv \ + rapidjson-dev \ + libfuse2 \ + libssl-dev \ + libboost-dev \ + libxcb-randr0-dev \ + libboost-system-dev \ + libboost-filesystem-dev \ + libpulse-dev \ + libxkbcommon-x11-0 \ + build-essential \ + libgl1-mesa-dev \ + libxcb-icccm4 \ + libxcb-image0 \ + libxcb-keysyms1 \ + libxcb-render-util0 \ + libxcb-xinerama0 + +RUN apt-get -y install \ + git \ + lsb-release \ + python3-pip && \ + apt-get clean all + +# Install Qt as we do in CI + +RUN pip3 install -U pip && \ + pip3 install aqtinstall && \ + aqt install-qt linux desktop 5.12.12 && \ + mkdir -p /opt/qt512 && \ + mv /5.12.12/gcc_64/* /opt/qt512 + +ADD . /src + +RUN mkdir /src/build + +# cmake +RUN cd /src/build && \ + CXXFLAGS=-fno-sized-deallocation cmake \ + -DCMAKE_INSTALL_PREFIX=appdir/usr/ \ + -DCMAKE_PREFIX_PATH=/opt/qt512/lib/cmake \ + -DBUILD_WITH_QTKEYCHAIN=OFF \ + .. + +# build +RUN cd /src/build && \ + make -j8 diff --git a/.docker/Dockerfile-ubuntu-20.04-package b/.docker/Dockerfile-ubuntu-20.04-package new file mode 100644 index 000000000..6c41156f3 --- /dev/null +++ b/.docker/Dockerfile-ubuntu-20.04-package @@ -0,0 +1,13 @@ +FROM chatterino-ubuntu-20.04-build + +ADD .CI /src/.CI + +WORKDIR /src/build + +# RUN apt-get install -y wget + +# create appimage +# RUN pwd && ./../.CI/CreateAppImage.sh + +# package deb +RUN pwd && ./../.CI/CreateUbuntuDeb.sh diff --git a/.docker/Dockerfile-ubuntu-22.04-build b/.docker/Dockerfile-ubuntu-22.04-build new file mode 100644 index 000000000..21f2ceb15 --- /dev/null +++ b/.docker/Dockerfile-ubuntu-22.04-build @@ -0,0 +1,57 @@ +FROM ubuntu:22.04 + +ENV TZ=UTC +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +RUN apt-get update && apt-get -y install --no-install-recommends \ + cmake \ + virtualenv \ + rapidjson-dev \ + libfuse2 \ + libssl-dev \ + libboost-dev \ + libxcb-randr0-dev \ + libboost-system-dev \ + libboost-filesystem-dev \ + libpulse-dev \ + libxkbcommon-x11-0 \ + build-essential \ + libgl1-mesa-dev \ + libxcb-icccm4 \ + libxcb-image0 \ + libxcb-keysyms1 \ + libxcb-render-util0 \ + libxcb-xinerama0 + +RUN apt-get -y install \ + git \ + lsb-release \ + python3-pip && \ + apt-get clean all + +# Install Qt as we do in CI + +RUN pip3 install -U pip && \ + pip3 install aqtinstall && \ + aqt install-qt linux desktop 5.15.2 && \ + mkdir -p /opt/qt515 && \ + mv /5.15.2/gcc_64/* /opt/qt515 + +ADD . /src + +RUN mkdir /src/build + +# Apply Qt patches +RUN patch "/opt/qt515/include/QtConcurrent/qtconcurrentthreadengine.h" /src/.patches/qt5-on-newer-gcc.patch + +# cmake +RUN cd /src/build && \ + CXXFLAGS=-fno-sized-deallocation cmake \ + -DCMAKE_INSTALL_PREFIX=appdir/usr/ \ + -DCMAKE_PREFIX_PATH=/opt/qt515/lib/cmake \ + -DBUILD_WITH_QTKEYCHAIN=OFF \ + .. + +# build +RUN cd /src/build && \ + make -j8 diff --git a/.docker/Dockerfile-ubuntu-22.04-package b/.docker/Dockerfile-ubuntu-22.04-package new file mode 100644 index 000000000..193c666a2 --- /dev/null +++ b/.docker/Dockerfile-ubuntu-22.04-package @@ -0,0 +1,8 @@ +FROM chatterino-ubuntu-22.04-build + +ADD .CI /src/.CI + +WORKDIR /src/build + +# package deb +RUN ./../.CI/CreateUbuntuDeb.sh diff --git a/.docker/README.md b/.docker/README.md new file mode 100644 index 000000000..869a1e391 --- /dev/null +++ b/.docker/README.md @@ -0,0 +1,29 @@ +## Groups + +### Ubuntu 20.04 package + +`Dockerfile-ubuntu-20.04-package` relies on `Dockerfile-ubuntu-20.04-build` + +To build, from the repo root + +1. Build a docker image that contains all the build artifacts and source from building Chatterino on Ubuntu 20.04 + `docker build -t chatterino-ubuntu-20.04-build -f .docker/Dockerfile-ubuntu-20.04-build .` +1. Build a docker image that uses the above-built image & packages it into a .deb file + `docker build -t chatterino-ubuntu-20.04-package -f .docker/Dockerfile-ubuntu-20.04-package .` + +To extract the final package, you can run the following command: +`docker run -v $PWD:/opt/mount --rm -it chatterino-ubuntu-20.04-package bash -c "cp /src/build/Chatterino-x86_64.deb /opt/mount/"` + +### Ubuntu 22.04 package + +`Dockerfile-ubuntu-22.04-package` relies on `Dockerfile-ubuntu-22.04-build` + +To build, from the repo root + +1. Build a docker image that contains all the build artifacts and source from building Chatterino on Ubuntu 22.04 + `docker build -t chatterino-ubuntu-22.04-build -f .docker/Dockerfile-ubuntu-22.04-build .` +1. Build a docker image that uses the above-built image & packages it into a .deb file + `docker build -t chatterino-ubuntu-22.04-package -f .docker/Dockerfile-ubuntu-22.04-package .` + +To extract the final package, you can run the following command: +`docker run -v $PWD:/opt/mount --rm -it chatterino-ubuntu-22.04-package bash -c "cp /src/build/Chatterino-x86_64.deb /opt/mount/"` diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..1d2b1be66 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +build* +.mypy_cache +.cache +.docker diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7d55046e5..f2d5c7c50 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,18 +17,32 @@ env: jobs: build: + name: "Build ${{ matrix.os }}, Qt ${{ matrix.qt-version }} (PCH:${{ matrix.pch }}, LTO:${{ matrix.force-lto }})" runs-on: ${{ matrix.os }} strategy: matrix: - os: [windows-latest, ubuntu-20.04, macos-latest] + os: [windows-latest, macos-latest] qt-version: [5.15.2, 5.12.12] pch: [true] force-lto: [false] + skip_artifact: ["no"] include: + # Ubuntu 20.04, Qt 5.12 - os: ubuntu-20.04 + qt-version: 5.12.12 + pch: true + force-lto: false + # Ubuntu 22.04, Qt 5.15 + - os: ubuntu-22.04 + qt-version: 5.15.2 + pch: true + force-lto: false + # Test for disabling Precompiled Headers & enabling link-time optimization + - os: ubuntu-22.04 qt-version: 5.15.2 pch: false force-lto: true + skip_artifact: "yes" fail-fast: false steps: @@ -147,12 +161,18 @@ jobs: libxcb-render-util0 \ libxcb-xinerama0 + - name: Apply Qt patches (Ubuntu) + if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.qt-version, '5.') + run: | + patch "$Qt5_DIR/include/QtConcurrent/qtconcurrentthreadengine.h" .patches/qt5-on-newer-gcc.patch + shell: bash + - name: Build (Ubuntu) if: startsWith(matrix.os, 'ubuntu') run: | mkdir build cd build - cmake \ + CXXFLAGS=-fno-sized-deallocation cmake \ -DCMAKE_INSTALL_PREFIX=appdir/usr/ \ -DCMAKE_BUILD_TYPE=Release \ -DPAJLADA_SETTINGS_USE_BOOST_FILESYSTEM=On \ @@ -182,31 +202,31 @@ jobs: clang-tidy-review-metadata.json - name: Package - AppImage (Ubuntu) - if: startsWith(matrix.os, 'ubuntu') + if: startsWith(matrix.os, 'ubuntu') && matrix.skip_artifact != 'yes' run: | cd build sh ./../.CI/CreateAppImage.sh shell: bash - name: Package - .deb (Ubuntu) - if: startsWith(matrix.os, 'ubuntu') + if: startsWith(matrix.os, 'ubuntu') && matrix.skip_artifact != 'yes' run: | cd build sh ./../.CI/CreateUbuntuDeb.sh shell: bash - name: Upload artifact - AppImage (Ubuntu) - if: startsWith(matrix.os, 'ubuntu') + if: startsWith(matrix.os, 'ubuntu') && matrix.skip_artifact != 'yes' uses: actions/upload-artifact@v3 with: name: Chatterino-x86_64-${{ matrix.qt-version }}.AppImage path: build/Chatterino-x86_64.AppImage - name: Upload artifact - .deb (Ubuntu) - if: startsWith(matrix.os, 'ubuntu') + if: startsWith(matrix.os, 'ubuntu') && matrix.skip_artifact != 'yes' uses: actions/upload-artifact@v3 with: - name: Chatterino-${{ matrix.qt-version }}.deb + name: Chatterino-${{ matrix.os }}-Qt-${{ matrix.qt-version }}.deb path: build/Chatterino-x86_64.deb # MACOS @@ -266,7 +286,12 @@ jobs: - uses: actions/download-artifact@v3 with: - name: Chatterino-5.15.2.deb + name: Chatterino-ubuntu-20.04.deb + path: release-artifacts/ + + - uses: actions/download-artifact@v3 + with: + name: Chatterino-ubuntu-22.04.deb path: release-artifacts/ - uses: actions/download-artifact@v3 diff --git a/.patches/qt5-on-newer-gcc.patch b/.patches/qt5-on-newer-gcc.patch new file mode 100644 index 000000000..2abdc120f --- /dev/null +++ b/.patches/qt5-on-newer-gcc.patch @@ -0,0 +1,20 @@ +This patch ensures Qt 5.15 in particular can build with modern compilers + +See https://bugreports.qt.io/browse/QTBUG-91909 and https://codereview.qt-project.org/c/qt/qtbase/+/339417 +--- + +diff --git a/src/concurrent/qtconcurrentthreadengine.h b/src/concurrent/qtconcurrentthreadengine.h +index cbd8ad04..4cd5b85 100644 +--- a/src/concurrent/qtconcurrentthreadengine.h ++++ b/src/concurrent/qtconcurrentthreadengine.h +@@ -256,8 +256,8 @@ + class ThreadEngineStarter : public ThreadEngineStarterBase + { + public: +- ThreadEngineStarter(ThreadEngine *_threadEngine) +- :ThreadEngineStarterBase(_threadEngine) {} ++ ThreadEngineStarter(ThreadEngine *_threadEngine) ++ : ThreadEngineStarterBase(_threadEngine) {} + + void startBlocking() + {