Skip to content

Commit

Permalink
Separate Ubuntu .deb packages per Ubuntu release (#4357)
Browse files Browse the repository at this point in the history
Our .deb packages are now very Ubuntu-specific and are packages based on our CI builds.
  • Loading branch information
Wissididom authored Feb 11, 2023
1 parent cf80ae8 commit 98c2ff5
Show file tree
Hide file tree
Showing 10 changed files with 288 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .CI/CreateAppImage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
83 changes: 67 additions & 16 deletions .CI/CreateUbuntuDeb.sh
Original file line number Diff line number Diff line change
@@ -1,40 +1,91 @@
#!/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
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 <[email protected]>
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 "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 "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
54 changes: 54 additions & 0 deletions .docker/Dockerfile-ubuntu-20.04-build
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions .docker/Dockerfile-ubuntu-20.04-package
Original file line number Diff line number Diff line change
@@ -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
57 changes: 57 additions & 0 deletions .docker/Dockerfile-ubuntu-22.04-build
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions .docker/Dockerfile-ubuntu-22.04-package
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM chatterino-ubuntu-22.04-build

ADD .CI /src/.CI

WORKDIR /src/build

# package deb
RUN ./../.CI/CreateUbuntuDeb.sh
29 changes: 29 additions & 0 deletions .docker/README.md
Original file line number Diff line number Diff line change
@@ -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/"`
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build*
.mypy_cache
.cache
.docker
41 changes: 33 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 98c2ff5

Please sign in to comment.