Skip to content

Commit

Permalink
Merge branch 'master' into scaling-is-fun
Browse files Browse the repository at this point in the history
  • Loading branch information
kornes committed Oct 3, 2023
2 parents 257c046 + 38a7ce6 commit 4f24c50
Show file tree
Hide file tree
Showing 773 changed files with 52,664 additions and 15,639 deletions.
56 changes: 43 additions & 13 deletions .CI/CreateAppImage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,33 @@

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"
if [ -n "$Qt5_DIR" ]; then
echo "Using Qt DIR from Qt5_DIR: $Qt5_DIR"
_QT_DIR="$Qt5_DIR"
elif [ -n "$Qt6_DIR" ]; then
echo "Using Qt DIR from Qt6_DIR: $Qt6_DIR"
_QT_DIR="$Qt6_DIR"
fi

if [ -n "$_QT_DIR" ]; then
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${_QT_DIR}/lib"
export PATH="${_QT_DIR}/bin:$PATH"
else
echo "No Qt environment variable set, assuming system-installed Qt"
fi

script_path=$(readlink -f "$0")
script_dir=$(dirname "$script_path")
chatterino_dir=$(dirname "$script_dir")

qmake_path=$(command -v qmake)

echo "Running LDD on chatterino binary:"
ldd ./bin/chatterino
Expand All @@ -26,24 +40,35 @@ 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 \
-qmake="$qmake_path"
-unsupported-allow-new-glibc

rm -rf appdir/home
rm -f appdir/AppRun
Expand All @@ -58,4 +83,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
46 changes: 33 additions & 13 deletions .CI/CreateDMG.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
#!/bin/sh
#!/usr/bin/env bash

if [ -d bin/chatterino.app ] && [ ! -d chatterino.app ]; then
>&2 echo "Moving bin/chatterino.app down one directory"
mv bin/chatterino.app chatterino.app
set -eo pipefail

if [ ! -d chatterino.app ]; then
echo "ERROR: No 'chatterino.app' dir found in the build directory. Make sure you've run ./CI/MacDeploy.sh"
exit 1
fi

if [ -z "$OUTPUT_DMG_PATH" ]; then
echo "ERROR: Must specify the path for where to save the final .dmg. Make sure you've set the OUTPUT_DMG_PATH environment variable."
exit 1
fi

if [ -z "$SKIP_VENV" ]; then
echo "Creating python3 virtual environment"
python3 -m venv venv
echo "Entering python3 virtual environment"
. venv/bin/activate
echo "Installing dmgbuild"
python3 -m pip install dmgbuild
fi

if [ -n "$MACOS_CODESIGN_CERTIFICATE" ]; then
echo "Codesigning force deep inside the app"
codesign -s "$MACOS_CODESIGN_CERTIFICATE" --deep --force chatterino.app
echo "Done!"
fi

echo "Running MACDEPLOYQT"
$Qt5_DIR/bin/macdeployqt chatterino.app
echo "Creating python3 virtual environment"
python3 -m venv venv
echo "Entering python3 virtual environment"
. venv/bin/activate
echo "Installing dmgbuild"
python3 -m pip install dmgbuild
echo "Running dmgbuild.."
dmgbuild --settings ./../.CI/dmg-settings.py -D app=./chatterino.app Chatterino2 chatterino-osx.dmg
dmgbuild --settings ./../.CI/dmg-settings.py -D app=./chatterino.app Chatterino2 "$OUTPUT_DMG_PATH"
echo "Done!"

if [ -n "$MACOS_CODESIGN_CERTIFICATE" ]; then
echo "Codesigning the dmg"
codesign -s "$MACOS_CODESIGN_CERTIFICATE" --deep --force "$OUTPUT_DMG_PATH"
echo "Done!"
fi
97 changes: 81 additions & 16 deletions .CI/CreateUbuntuDeb.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,100 @@
#!/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)"

# The final path where we'll save the .deb package
deb_path="Chatterino-ubuntu-${ubuntu_release}-x86_64.deb"

# 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)
if [ -n "$Qt6_DIR" ]; then
echo "Qt6_DIR set, assuming Qt6"
dependencies="libc6, libstdc++6, libqt6core6, libqt6widgets6, libqt6network6, libqt6core5compat6, libqt6svg6, qt6-qpa-plugins, qt6-image-formats-plugins"
else
dependencies="libc6, libstdc++6, libqt5core5a, libqt5concurrent5, libqt5dbus5, libqt5gui5, libqt5network5, libqt5svg5, libqt5widgets5, qt5-image-formats-plugins, libboost-filesystem1.74.0"
fi
;;
*)
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
fi

chatterino_version=$(git describe | cut -c 2-)
echo "Found Chatterino version $chatterino_version via git"
chatterino_version=$(git describe 2>/dev/null) || true
if [ "$(echo "$chatterino_version" | cut -c1-1)" = 'v' ]; then
chatterino_version="$(echo "$chatterino_version" | cut -c2-)"
else
chatterino_version="0.0.0-dev"
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 <mm2pl@kotmisia.pl>
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"
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" "$deb_path"
breakline


echo "Package info"
dpkg --info "$deb_path"
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..."
dpkg-deb --build "$packaging_dir" "Chatterino.deb"
echo "Package contents"
dpkg --contents "$deb_path"
breakline
6 changes: 0 additions & 6 deletions .CI/InstallQTStylePlugins.sh

This file was deleted.

39 changes: 39 additions & 0 deletions .CI/MacDeploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

# Bundle relevant qt & system dependencies into the ./chatterino.app folder

set -eo pipefail

if [ -d bin/chatterino.app ] && [ ! -d chatterino.app ]; then
>&2 echo "Moving bin/chatterino.app down one directory"
mv bin/chatterino.app chatterino.app
fi

if [ -n "$Qt5_DIR" ]; then
echo "Using Qt DIR from Qt5_DIR: $Qt5_DIR"
_QT_DIR="$Qt5_DIR"
elif [ -n "$Qt6_DIR" ]; then
echo "Using Qt DIR from Qt6_DIR: $Qt6_DIR"
_QT_DIR="$Qt6_DIR"
fi

if [ -n "$_QT_DIR" ]; then
export PATH="${_QT_DIR}/bin:$PATH"
else
echo "No Qt environment variable set, assuming system-installed Qt"
fi

echo "Running MACDEPLOYQT"

_macdeployqt_args=()

if [ -n "$MACOS_CODESIGN_CERTIFICATE" ]; then
_macdeployqt_args+=("-codesign=$MACOS_CODESIGN_CERTIFICATE")
fi

macdeployqt chatterino.app "${_macdeployqt_args[@]}"

if [ -n "$MACOS_CODESIGN_CERTIFICATE" ]; then
# Validate that chatterino.app was codesigned correctly
codesign -v chatterino.app
fi
51 changes: 51 additions & 0 deletions .CI/build-installer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
if (-not (Test-Path -PathType Container Chatterino2)) {
Write-Error "Couldn't find a folder called 'Chatterino2' in the current directory.";
exit 1
}

# Check if we're on a tag
$OldErrorActionPref = $ErrorActionPreference;
$ErrorActionPreference = 'Continue';
git describe --exact-match --match 'v*' *> $null;
$isTagged = $?;
$ErrorActionPreference = $OldErrorActionPref;

$defines = $null;
if ($isTagged) {
# This is a release.
# Make sure, any existing `modes` file is overwritten for the user,
# for example when updating from nightly to stable.
Write-Output "" | Out-File Chatterino2/modes -Encoding ASCII;
$installerBaseName = "Chatterino.Installer";
}
else {
Write-Output nightly | Out-File Chatterino2/modes -Encoding ASCII;
$defines = "/DIS_NIGHTLY=1";
$installerBaseName = "Chatterino.Nightly.Installer";
}

if ($Env:GITHUB_OUTPUT) {
# This is used in CI when creating the artifact
"C2_INSTALLER_BASE_NAME=$installerBaseName" >> "$Env:GITHUB_OUTPUT"
}

# Copy vc_redist.x64.exe
if ($null -eq $Env:VCToolsRedistDir) {
Write-Error "VCToolsRedistDir is not set. Forgot to set Visual Studio environment variables?";
exit 1
}
Copy-Item "$Env:VCToolsRedistDir\vc_redist.x64.exe" .;

$VCRTVersion = (Get-Item "$Env:VCToolsRedistDir\vc_redist.x64.exe").VersionInfo;

# Build the installer
ISCC `
/DWORKING_DIR="$($pwd.Path)\" `
/DINSTALLER_BASE_NAME="$installerBaseName" `
/DSHIPPED_VCRT_BUILD="$($VCRTVersion.FileBuildPart)" `
/DSHIPPED_VCRT_VERSION="$($VCRTVersion.FileDescription)" `
$defines `
/O. `
"$PSScriptRoot\chatterino-installer.iss";

Move-Item "$installerBaseName.exe" "$installerBaseName$($Env:VARIANT_SUFFIX).exe"
Loading

0 comments on commit 4f24c50

Please sign in to comment.