Skip to content

Commit

Permalink
Merge chatterino2 into chatterino7
Browse files Browse the repository at this point in the history
This removes the creation of appimages
as upstream only creates appimages with Qt 5.12.12
and we don't build with this Qt version.
If you're using the appimage, consider switching to flatpack instead.
  • Loading branch information
Nerixyz committed Feb 24, 2023
2 parents 2379061 + a75feba commit 5fdf0ef
Show file tree
Hide file tree
Showing 29 changed files with 226 additions and 81 deletions.
39 changes: 29 additions & 10 deletions .CI/CreateAppImage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

set -e

# Print all commands as they are run
set -x

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
fi

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/qt512/lib/"
export PATH="/opt/qt512/bin:$PATH"
echo "Qt5_DIR set to: ${Qt5_DIR}"

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${Qt5_DIR}/lib"
export PATH="${Qt5_DIR}/bin:$PATH"

script_path=$(readlink -f "$0")
script_dir=$(dirname "$script_path")
Expand All @@ -25,20 +30,32 @@ echo ""

cp "$chatterino_dir"/resources/icon.png ./appdir/chatterino.png

linuxdeployqt_path="linuxdeployqt-6-x86_64.AppImage"
linuxdeployqt_url="https://github.com/probonopd/linuxdeployqt/releases/download/6/linuxdeployqt-6-x86_64.AppImage"
linuxdeployqt_path="linuxdeployqt-x86_64.AppImage"
linuxdeployqt_url="https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"

if [ ! -f "$linuxdeployqt_path" ]; then
wget -nv "$linuxdeployqt_url"
echo "Downloading LinuxDeployQT from $linuxdeployqt_url to $linuxdeployqt_path"
curl --location --fail --silent "$linuxdeployqt_url" -o "$linuxdeployqt_path"
chmod a+x "$linuxdeployqt_path"
fi
if [ ! -f appimagetool-x86_64.AppImage ]; then
wget -nv "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
chmod a+x appimagetool-x86_64.AppImage

appimagetool_path="appimagetool-x86_64.AppImage"
appimagetool_url="https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"

if [ ! -f "$appimagetool_path" ]; then
echo "Downloading AppImageTool from $appimagetool_url to $appimagetool_path"
curl --location --fail --silent "$appimagetool_url" -o "$appimagetool_path"
chmod a+x "$appimagetool_path"
fi

# For some reason, the copyright file for libc was not found. We need to manually copy it from the host system
mkdir -p appdir/usr/share/doc/libc6/
cp /usr/share/doc/libc6/copyright appdir/usr/share/doc/libc6/

echo "Run LinuxDeployQT"
./"$linuxdeployqt_path" \
appdir/usr/share/applications/*.desktop \
--appimage-extract-and-run \
appdir/usr/share/applications/com.chatterino.chatterino.desktop \
-no-translations \
-bundle-non-qt-libs \
-unsupported-allow-new-glibc
Expand All @@ -56,7 +73,9 @@ cd "$here/usr"
exec "$here/usr/bin/chatterino" "$@"' > appdir/AppRun
chmod a+x appdir/AppRun

./appimagetool-x86_64.AppImage appdir
./"$appimagetool_path" \
--appimage-extract-and-run \
appdir

# TODO: Create appimage in a unique directory instead maybe idk?
rm -rf appdir
18 changes: 13 additions & 5 deletions .docker/Dockerfile-ubuntu-20.04-package
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
FROM chatterino-ubuntu-20.04-build

ADD .CI /src/.CI
# In CI, this is set from the aqtinstall action
ENV Qt5_DIR=/opt/qt512

WORKDIR /src/build

# RUN apt-get install -y wget
ADD .CI /src/.CI

# create appimage
# RUN pwd && ./../.CI/CreateAppImage.sh
# Install dependencies necessary for AppImage packaging
RUN apt-get update && apt-get -y install --no-install-recommends \
curl \
libfontconfig \
libxrender1 \
file

# package deb
RUN pwd && ./../.CI/CreateUbuntuDeb.sh
RUN ./../.CI/CreateUbuntuDeb.sh

# package appimage
RUN ./../.CI/CreateAppImage.sh
15 changes: 14 additions & 1 deletion .docker/Dockerfile-ubuntu-22.04-package
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
FROM chatterino-ubuntu-22.04-build

ADD .CI /src/.CI
# In CI, this is set from the aqtinstall action
ENV Qt5_DIR=/opt/qt515

WORKDIR /src/build

ADD .CI /src/.CI

# Install dependencies necessary for AppImage packaging
RUN apt-get update && apt-get -y install --no-install-recommends \
curl \
libxcb-shape0 \
libfontconfig1 \
file

# package deb
RUN ./../.CI/CreateUbuntuDeb.sh

# package appimage
RUN ./../.CI/CreateAppImage.sh
10 changes: 6 additions & 4 deletions .docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
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 .`
`docker buildx 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 .`
`docker buildx 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/"`
Expand All @@ -21,9 +21,11 @@ To extract the final package, you can run the following command:
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 .`
`docker buildx 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 .`
`docker buildx 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/"`

NOTE: The AppImage from Ubuntu 22.04 is broken. Approach with caution
48 changes: 27 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ concurrency:
env:
C2_ENABLE_LTO: ${{ github.ref == 'refs/heads/master' }}
CHATTERINO_REQUIRE_CLEAN_GIT: On
C2_BUILD_WITH_QT6: Off

jobs:
build:
Expand All @@ -34,6 +35,11 @@ jobs:
qt-version: 5.15.2
pch: true
force-lto: false
# Ubuntu 22.04, Qt 6.2.4
- os: ubuntu-22.04
qt-version: 6.2.4
pch: false
force-lto: false
# Test for disabling Precompiled Headers & enabling link-time optimization
- os: ubuntu-22.04
qt-version: 5.15.2
Expand Down Expand Up @@ -68,18 +74,34 @@ jobs:
echo "vs_version=2022" >> "$GITHUB_ENV"
shell: bash

- name: Set BUILD_WITH_QT6
if: startsWith(matrix.qt-version, '6.')
run: |
echo "C2_BUILD_WITH_QT6=ON" >> "$GITHUB_ENV"
shell: bash

- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0 # allows for tags access

- name: Install Qt
uses: jurplel/[email protected]
- name: Install Qt5
if: startsWith(matrix.qt-version, '5.')
uses: jurplel/[email protected]
with:
cache: true
cache-key-prefix: ${{ runner.os }}-QtCache-${{ matrix.qt-version }}-v2
version: ${{ matrix.qt-version }}

- name: Install Qt6
if: startsWith(matrix.qt-version, '6.')
uses: jurplel/[email protected]
with:
cache: true
cache-key-prefix: ${{ runner.os }}-QtCache-${{ matrix.qt-version }}-v2
modules: qt5compat
version: ${{ matrix.qt-version }}

# WINDOWS
- name: Cache conan packages part 1
if: startsWith(matrix.os, 'windows')
Expand Down Expand Up @@ -126,6 +148,7 @@ jobs:
-DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" `
-DBUILD_WITH_CRASHPAD="$Env:C2_ENABLE_CRASHPAD" `
-DCHATTERINO_LTO="$Env:C2_ENABLE_LTO" `
-DBUILD_WITH_QT6="$Env:C2_BUILD_WITH_QT6" `
..
set cl=/MP
nmake /S /NOLOGO
Expand Down Expand Up @@ -211,6 +234,7 @@ jobs:
-DUSE_PRECOMPILED_HEADERS=${{ matrix.pch }} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=On \
-DCHATTERINO_LTO="$C2_ENABLE_LTO" \
-DBUILD_WITH_QT6="$C2_BUILD_WITH_QT6" \
..
make -j"$(nproc)"
shell: bash
Expand All @@ -233,27 +257,13 @@ jobs:
clang-tidy-review-output.json
clang-tidy-review-metadata.json
- name: Package - AppImage (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') && matrix.skip_artifact != 'yes'
run: |
cd build
sh ./../.CI/CreateUbuntuDeb.sh
shell: bash

- name: Upload artifact - AppImage (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') && matrix.skip_artifact != 'yes'
uses: actions/upload-artifact@v3
Expand All @@ -279,6 +289,7 @@ jobs:
-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl \
-DUSE_PRECOMPILED_HEADERS=${{ matrix.pch }} \
-DCHATTERINO_LTO="$C2_ENABLE_LTO" \
-DBUILD_WITH_QT6="$C2_BUILD_WITH_QT6" \
..
make -j"$(sysctl -n hw.logicalcpu)"
shell: bash
Expand Down Expand Up @@ -319,11 +330,6 @@ jobs:
name: chatterino-windows-x86-64-5.15.2-symbols.pdb.7z
path: release-artifacts/

- uses: actions/download-artifact@v3
with:
name: Chatterino-x86_64-5.15.2.AppImage
path: release-artifacts/

- uses: actions/download-artifact@v3
with:
name: Chatterino-ubuntu-22.04-Qt-5.15.2.deb
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/homebrew.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
env:
# This gets updated later on in the run by a bash script to strip the prefix
C2_CASK_NAME: chatterino
# The full version of Chatterino (e.g. v2.4.1)
C2_TAGGED_VERSION: ${{ github.ref_name }}
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}

Expand All @@ -23,4 +24,6 @@ jobs:
- name: Execute brew bump-cask-pr with version
run: |
echo "Running bump-cask-pr for cask '$C2_CASK_NAME' and version '$C2_TAGGED_VERSION'"
brew bump-cask-pr --version "$C2_TAGGED_VERSION" "$C2_CASK_NAME"
C2_TAGGED_VERSION_STRIPPED="${C2_TAGGED_VERSION:1}"
echo "Stripped version: '$C2_TAGGED_VERSION_STRIPPED'"
brew bump-cask-pr --version "$C2_TAGGED_VERSION_STRIPPED" "$C2_CASK_NAME"
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
key: ${{ runner.os }}-QtCache-${{ matrix.qt-version }}

- name: Install Qt
uses: jurplel/install-qt-action@v3.0.0
uses: jurplel/install-qt-action@v3.1.0
with:
cache: true
cache-key-prefix: ${{ runner.os }}-QtCache-${{ matrix.qt-version }}
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unversioned

- Minor: Delete all but the last 5 crashdumps on application start. (#4392)
- Bugfix: Fixed uploaded AppImage not being able most web requests. (#4400)
- Bugfix: Fixed a potential race condition due to using the wrong lock when loading 7TV badges. (#4402)
- Dev: Add capability to build Chatterino with Qt6. (#4393)
- Dev: Fix homebrew update action. (#4394)

## 2.4.1

- Major: Added live emote updates for BTTV. (#4147)
Expand Down
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ find_package(Qt${MAJOR_QT_VERSION} REQUIRED
Concurrent
)

if (BUILD_WITH_QT6)
find_package(Qt${MAJOR_QT_VERSION} REQUIRED
COMPONENTS
Core5Compat
)
endif ()

message(STATUS "Qt version: ${Qt${MAJOR_QT_VERSION}_VERSION}")

if (WIN32)
Expand Down
8 changes: 8 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,14 @@ target_link_libraries(${LIBRARY_PROJECT}
LRUCache
MagicEnum
)

if (BUILD_WITH_QT6)
target_link_libraries(${LIBRARY_PROJECT}
PUBLIC
Qt${MAJOR_QT_VERSION}::Core5Compat
)
endif ()

if (BUILD_WITH_QTKEYCHAIN)
target_link_libraries(${LIBRARY_PROJECT}
PUBLIC
Expand Down
1 change: 0 additions & 1 deletion src/PrecompiledHeader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
# include <QThreadPool>
# include <QTime>
# include <QTimer>
# include <QtWidgets/QAction>
# include <QtWidgets/QApplication>
# include <QtWidgets/QButtonGroup>
# include <QtWidgets/QDialog>
Expand Down
39 changes: 38 additions & 1 deletion src/RunGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,38 @@ namespace {
}
qCDebug(chatterinoCache) << "Deleted" << deletedCount << "files";
}

// We delete all but the five most recent crashdumps. This strategy may be
// improved in the future.
void clearCrashes(QDir dir)
{
// crashpad crashdumps are stored inside the Crashes/report directory
if (!dir.cd("reports"))
{
// no reports directory exists = no files to delete
return;
}

dir.setNameFilters({"*.dmp"});

size_t deletedCount = 0;
// TODO: use std::views::drop once supported by all compilers
size_t filesToSkip = 5;
for (auto &&info : dir.entryInfoList(QDir::Files, QDir::Time))
{
if (filesToSkip > 0)
{
filesToSkip--;
continue;
}

if (QFile(info.absoluteFilePath()).remove())
{
deletedCount++;
}
}
qCDebug(chatterinoApp) << "Deleted" << deletedCount << "crashdumps";
}
} // namespace

void runGui(QApplication &a, Paths &paths, Settings &settings)
Expand Down Expand Up @@ -215,10 +247,15 @@ void runGui(QApplication &a, Paths &paths, Settings &settings)
});

// Clear the cache 1 minute after start.
QTimer::singleShot(60 * 1000, [cachePath = paths.cacheDirectory()] {
QTimer::singleShot(60 * 1000, [cachePath = paths.cacheDirectory(),
crashDirectory = paths.crashdumpDirectory] {
QtConcurrent::run([cachePath]() {
clearCache(cachePath);
});

QtConcurrent::run([crashDirectory]() {
clearCrashes(crashDirectory);
});
});

chatterino::NetworkManager::init();
Expand Down
Loading

0 comments on commit 5fdf0ef

Please sign in to comment.