mirror of
https://forgejo.ellis.link/continuwuation/continuwuity/
synced 2026-07-04 23:21:37 +00:00
Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 83b94cc375 | |||
| aab4c5eaee | |||
| 660f1ee790 | |||
| d8f6c0fc67 | |||
| 01dd4575b7 | |||
| 7f2cd69bd9 | |||
| 6ed175f75d | |||
| 3723233605 | |||
| f169d68ba7 | |||
| 6805f16d9c | |||
| 25732963c2 | |||
| 8b6ffc3700 | |||
| 5cd0704e14 | |||
| 3509c5a65a | |||
| 6c800a293c | |||
| 696e29d087 | |||
| 863239f341 | |||
| e7a79b1e03 | |||
| 4af08c2b07 | |||
| 980b39c946 | |||
| 67810682cd | |||
| 53a7e815da | |||
| d3c88c6242 | |||
| 30df03524f | |||
| fa4e0b8802 | |||
| a3422d5625 | |||
| f5003206fa | |||
| dbd5d347ec | |||
| a873329a42 | |||
| d14310a1e5 | |||
| 52fb7b5ede | |||
| ede03e30a7 | |||
| 452afb7829 | |||
| 5a2288fe06 | |||
| 3fc03c9cd7 | |||
| fd501fc290 |
@@ -0,0 +1,154 @@
|
||||
name: Build / Debian DEB
|
||||
|
||||
concurrency:
|
||||
group: "build-debian-${{ forge.ref }}"
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
tags:
|
||||
- 'v*'
|
||||
paths:
|
||||
- 'pkg/debian/**'
|
||||
- 'src/**'
|
||||
- 'Cargo.toml'
|
||||
- 'Cargo.lock'
|
||||
- '.forgejo/workflows/build-debian.yml'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
container: ["ubuntu-latest", "ubuntu-previous", "debian-latest", "debian-oldstable"]
|
||||
container:
|
||||
image: "ghcr.io/tcpipuk/act-runner:${{ matrix.container }}"
|
||||
|
||||
steps:
|
||||
- name: Get Debian version
|
||||
id: debian-version
|
||||
run: |
|
||||
VERSION=$(cat /etc/debian_version)
|
||||
DISTRIBUTION=$(lsb_release -sc 2>/dev/null)
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "distribution=$DISTRIBUTION" >> $GITHUB_OUTPUT
|
||||
echo "Debian distribution: $DISTRIBUTION ($VERSION)"
|
||||
|
||||
- name: Checkout repository with full history
|
||||
uses: https://code.forgejo.org/actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Cache Cargo registry
|
||||
uses: https://code.forgejo.org/actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
key: cargo-debian-${{ steps.debian-version.outputs.distribution }}-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
cargo-debian-${{ steps.debian-version.outputs.distribution }}-
|
||||
|
||||
- name: Setup sccache
|
||||
uses: https://git.tomfos.tr/tom/sccache-action@v1
|
||||
|
||||
- name: Configure sccache environment
|
||||
run: |
|
||||
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
|
||||
echo "CMAKE_C_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV
|
||||
echo "CMAKE_CXX_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV
|
||||
echo "SCCACHE_CACHE_SIZE=10G" >> $GITHUB_ENV
|
||||
# Aggressive GC since cache restores don't increment counter
|
||||
echo "CARGO_INCREMENTAL_GC_TRIGGER=5" >> $GITHUB_ENV
|
||||
|
||||
- name: Setup Rust nightly
|
||||
uses: ./.forgejo/actions/setup-rust
|
||||
with:
|
||||
rust-version: nightly
|
||||
github-token: ${{ secrets.GH_PUBLIC_RO }}
|
||||
|
||||
- name: Get package version and component
|
||||
id: package-meta
|
||||
run: |
|
||||
BASE_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r ".packages[] | select(.name == \"conduwuit\").version" | sed 's/[^a-zA-Z0-9.+]/~/g')
|
||||
# VERSION is the package version, COMPONENT is used in
|
||||
# apt's repository config like a git repo branch
|
||||
if [[ "${{ forge.ref }}" == "refs/tags/"* ]]; then
|
||||
# Use the "stable" component for tagged releases
|
||||
COMPONENT="stable"
|
||||
VERSION=$BASE_VERSION
|
||||
else
|
||||
# Use the "dev" component for development builds
|
||||
SHA=$(echo "${{ forge.sha }}" | cut -c1-7)
|
||||
DATE=$(date +%Y%m%d)
|
||||
if [ "${{ forge.ref_name }}" = "main" ]; then
|
||||
COMPONENT="dev"
|
||||
else
|
||||
# Use the sanitized ref name as the component for feature branches
|
||||
COMPONENT="dev-$(echo '${{ forge.ref_name }}' | sed 's/[^a-zA-Z0-9.+]/-/g' | tr '[:upper:]' '[:lower:]' | cut -c1-30)"
|
||||
fi
|
||||
CLEAN_COMPONENT=$(echo $COMPONENT | sed 's/[^a-zA-Z0-9.+]/~/g')
|
||||
VERSION="$BASE_VERSION~git$DATE.$SHA-$CLEAN_COMPONENT"
|
||||
fi
|
||||
echo "component=$COMPONENT" >> $GITHUB_OUTPUT
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "Component: $COMPONENT"
|
||||
echo "Version: $VERSION"
|
||||
|
||||
- name: Install cargo-deb
|
||||
run: |
|
||||
if command -v cargo-deb &> /dev/null; then
|
||||
echo "cargo-deb already available"
|
||||
else
|
||||
echo "Installing cargo-deb"
|
||||
cargo-binstall -y --no-symlinks cargo-deb
|
||||
fi
|
||||
|
||||
- name: Install build dependencies
|
||||
run: |
|
||||
apt-get update -y
|
||||
# Build dependencies for rocksdb
|
||||
apt-get install -y clang liburing-dev
|
||||
|
||||
- name: Run cargo-deb
|
||||
id: cargo-deb
|
||||
run: |
|
||||
DEB_PATH=$(cargo deb --deb-version ${{ steps.package-meta.outputs.version }})
|
||||
echo "path=$DEB_PATH" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Test deb installation
|
||||
run: |
|
||||
echo "Installing: ${{ steps.cargo-deb.outputs.path }}"
|
||||
|
||||
apt-get install -y ${{ steps.cargo-deb.outputs.path }}
|
||||
|
||||
dpkg -s continuwuity
|
||||
|
||||
[ -f /usr/bin/conduwuit ] && echo "✅ Binary installed successfully"
|
||||
[ -f /usr/lib/systemd/system/conduwuit.service ] && echo "✅ Systemd service installed"
|
||||
[ -f /etc/conduwuit/conduwuit.toml ] && echo "✅ Config file installed"
|
||||
|
||||
- name: Upload deb artifact
|
||||
uses: https://code.forgejo.org/actions/upload-artifact@v3
|
||||
with:
|
||||
name: continuwuity-${{ steps.debian-version.outputs.distribution }}
|
||||
path: ${{ steps.cargo-deb.outputs.path }}
|
||||
|
||||
- name: Publish to Forgejo package registry
|
||||
if: ${{ forge.event_name == 'push' || forge.event_name == 'workflow_dispatch' }}
|
||||
run: |
|
||||
OWNER="continuwuation"
|
||||
DISTRIBUTION=${{ steps.debian-version.outputs.distribution }}
|
||||
COMPONENT=${{ steps.package-meta.outputs.component }}
|
||||
DEB=${{ steps.cargo-deb.outputs.path }}
|
||||
|
||||
echo "Publishing: $DEB in component $COMPONENT for distribution $DISTRIBUTION"
|
||||
|
||||
curl --fail-with-body \
|
||||
-X PUT \
|
||||
-H "Authorization: token ${{ secrets.BUILTIN_REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}" \
|
||||
--upload-file "$DEB" \
|
||||
"${{ forge.server_url }}/api/packages/$OWNER/debian/pool/$DISTRIBUTION/$COMPONENT/upload"
|
||||
+20
-4
@@ -1,12 +1,28 @@
|
||||
# Continuwuity for Debian
|
||||
|
||||
This document provides information about downloading and deploying the Debian package. You can also use this guide for other `apt`-based distributions such as Ubuntu.
|
||||
This document provides information about downloading and deploying the Debian package. You can also use this guide for other deb-based distributions such as Ubuntu.
|
||||
|
||||
### Installation
|
||||
|
||||
See the [generic deployment guide](../deploying/generic.md) for additional information about using the Debian package.
|
||||
To add the Continuwuation apt repository:
|
||||
```bash
|
||||
# Replace with `"dev"` for bleeding-edge builds at your own risk
|
||||
export COMPONENT="stable"
|
||||
# Import the Continuwuation signing key
|
||||
sudo curl https://forgejo.ellis.link/api/packages/continuwuation/debian/repository.key -o /etc/apt/keyrings/forgejo-continuwuation.asc
|
||||
# Add a new apt source list pointing to the repository
|
||||
echo "deb [signed-by=/etc/apt/keyrings/forgejo-continuwuation.asc] https://forgejo.ellis.link/api/packages/continuwuation/debian $(lsb_release -sc) $COMPONENT" | sudo tee /etc/apt/sources.list.d/continuwuation.list
|
||||
# Update remote package lists
|
||||
sudo apt update
|
||||
```
|
||||
|
||||
No `apt` repository is currently available. This feature is in development.
|
||||
To install continuwuity:
|
||||
```bash
|
||||
sudo apt install continuwuity
|
||||
```
|
||||
The `continuwuity` package conflicts with the old `conduwuit` package and will remove it automatically when installed.
|
||||
|
||||
See the [generic deployment guide](../deploying/generic.md) for additional information about using the Debian package.
|
||||
|
||||
### Configuration
|
||||
|
||||
@@ -16,7 +32,7 @@ ### Configuration
|
||||
|
||||
### Running
|
||||
|
||||
The package uses the [`conduwuit.service`](../configuration/examples.md#example-systemd-unit-file) systemd unit file to start and stop Continuwuity. The binary installs at `/usr/sbin/conduwuit`.
|
||||
The package uses the [`conduwuit.service`](../configuration/examples.md#example-systemd-unit-file) systemd unit file to start and stop Continuwuity. The binary installs at `/usr/bin/conduwuit`.
|
||||
|
||||
By default, this package assumes that Continuwuity runs behind a reverse proxy. The default configuration options apply (listening on `localhost` and TCP port `6167`). Matrix federation requires a valid domain name and TLS. To federate properly, you must set up TLS certificates and certificate renewal.
|
||||
|
||||
|
||||
@@ -360,7 +360,7 @@ pub(super) async fn get_remote_thumbnail(
|
||||
) -> Result {
|
||||
let mxc: Mxc<'_> = mxc.as_str().try_into()?;
|
||||
let timeout = Duration::from_millis(timeout.into());
|
||||
let dim = Dim::new(width, height, None);
|
||||
let dim = Dim::new(width, height, None, None);
|
||||
let mut result = self
|
||||
.services
|
||||
.media
|
||||
|
||||
@@ -99,7 +99,7 @@ pub(crate) async fn get_content_thumbnail_route(
|
||||
) -> Result<get_content_thumbnail::v1::Response> {
|
||||
let user = body.sender_user();
|
||||
|
||||
let dim = Dim::from_ruma(body.width, body.height, body.method.clone())?;
|
||||
let dim = Dim::from_ruma(body.width, body.height, body.method.clone(), body.animated)?;
|
||||
let mxc = Mxc {
|
||||
server_name: &body.server_name,
|
||||
media_id: &body.media_id,
|
||||
|
||||
@@ -322,7 +322,7 @@ pub(crate) async fn get_content_thumbnail_legacy_route(
|
||||
media_id: &body.media_id,
|
||||
};
|
||||
|
||||
let dim = Dim::from_ruma(body.width, body.height, body.method.clone())?;
|
||||
let dim = Dim::from_ruma(body.width, body.height, body.method.clone(), body.animated)?;
|
||||
match services.media.get_thumbnail(&mxc, &dim).await? {
|
||||
| Some(FileMeta {
|
||||
content,
|
||||
|
||||
@@ -67,7 +67,7 @@ pub(crate) async fn get_content_thumbnail_route(
|
||||
InsecureClientIp(client): InsecureClientIp,
|
||||
body: Ruma<get_content_thumbnail::v1::Request>,
|
||||
) -> Result<get_content_thumbnail::v1::Response> {
|
||||
let dim = Dim::from_ruma(body.width, body.height, body.method.clone())?;
|
||||
let dim = Dim::from_ruma(body.width, body.height, body.method.clone(), body.animated)?;
|
||||
let mxc = Mxc {
|
||||
server_name: services.globals.server_name(),
|
||||
media_id: &body.media_id,
|
||||
|
||||
+5
-3
@@ -22,11 +22,13 @@ crate-type = [
|
||||
]
|
||||
|
||||
[package.metadata.deb]
|
||||
name = "conduwuit"
|
||||
maintainer = "strawberry <strawberry@puppygock.gay>"
|
||||
copyright = "2024, strawberry <strawberry@puppygock.gay>"
|
||||
name = "continuwuity"
|
||||
maintainer = "continuwuity developers <contact@continuwuity.org>"
|
||||
copyright = "2024, continuwuity developers"
|
||||
license-file = ["../../LICENSE", "3"]
|
||||
depends = "$auto, ca-certificates"
|
||||
breaks = ["conduwuit (<<0.5.0)"]
|
||||
replaces = ["conduwuit (<<0.5.0)"]
|
||||
extended-description = """\
|
||||
a cool hard fork of Conduit, a Matrix homeserver written in Rust"""
|
||||
section = "net"
|
||||
|
||||
@@ -372,7 +372,7 @@ pub async fn fetch_remote_thumbnail_legacy(
|
||||
})
|
||||
.await?;
|
||||
|
||||
let dim = Dim::from_ruma(body.width, body.height, body.method.clone())?;
|
||||
let dim = Dim::from_ruma(body.width, body.height, body.method.clone(), body.animated)?;
|
||||
self.upload_thumbnail(
|
||||
&mxc,
|
||||
None,
|
||||
|
||||
@@ -16,12 +16,13 @@
|
||||
|
||||
use super::{FileMeta, data::Metadata};
|
||||
|
||||
/// Dimension specification for a thumbnail.
|
||||
/// Dimension and format specification for a thumbnail.
|
||||
#[derive(Debug)]
|
||||
pub struct Dim {
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub method: Method,
|
||||
pub animated: bool,
|
||||
}
|
||||
|
||||
impl super::Service {
|
||||
@@ -179,8 +180,14 @@ fn into_filemeta(data: Metadata, content: Vec<u8>) -> FileMeta {
|
||||
}
|
||||
|
||||
impl Dim {
|
||||
/// Instantiate a Dim from Ruma integers with optional method.
|
||||
pub fn from_ruma(width: UInt, height: UInt, method: Option<Method>) -> Result<Self> {
|
||||
/// Instantiate a Dim from Ruma integers with optional method and animation
|
||||
/// flag.
|
||||
pub fn from_ruma(
|
||||
width: UInt,
|
||||
height: UInt,
|
||||
method: Option<Method>,
|
||||
animated: Option<bool>,
|
||||
) -> Result<Self> {
|
||||
let width = width
|
||||
.try_into()
|
||||
.map_err(|e| err!(Request(InvalidParam("Width is invalid: {e:?}"))))?;
|
||||
@@ -188,17 +195,19 @@ pub fn from_ruma(width: UInt, height: UInt, method: Option<Method>) -> Result<Se
|
||||
.try_into()
|
||||
.map_err(|e| err!(Request(InvalidParam("Height is invalid: {e:?}"))))?;
|
||||
|
||||
Ok(Self::new(width, height, method))
|
||||
Ok(Self::new(width, height, method, animated))
|
||||
}
|
||||
|
||||
/// Instantiate a Dim with optional method
|
||||
/// Instantiate a Dim with optional method and animation flag.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn new(width: u32, height: u32, method: Option<Method>) -> Self {
|
||||
pub fn new(width: u32, height: u32, method: Option<Method>, animated: Option<bool>) -> Self {
|
||||
Self {
|
||||
width,
|
||||
height,
|
||||
method: method.unwrap_or(Method::Scale),
|
||||
// "When not provided, the server SHOULD NOT return an animated thumbnail"
|
||||
animated: animated.unwrap_or(false),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,6 +238,7 @@ pub fn scaled(&self, image: &Self) -> Result<Self> {
|
||||
width: x,
|
||||
height: y,
|
||||
method: Method::Scale,
|
||||
animated: self.animated,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -238,11 +248,11 @@ pub fn scaled(&self, image: &Self) -> Result<Self> {
|
||||
#[must_use]
|
||||
pub fn normalized(&self) -> Self {
|
||||
match (self.width, self.height) {
|
||||
| (0..=32, 0..=32) => Self::new(32, 32, Some(Method::Crop)),
|
||||
| (0..=96, 0..=96) => Self::new(96, 96, Some(Method::Crop)),
|
||||
| (0..=320, 0..=240) => Self::new(320, 240, Some(Method::Scale)),
|
||||
| (0..=640, 0..=480) => Self::new(640, 480, Some(Method::Scale)),
|
||||
| (0..=800, 0..=600) => Self::new(800, 600, Some(Method::Scale)),
|
||||
| (0..=32, 0..=32) => Self::new(32, 32, Some(Method::Crop), Some(self.animated)),
|
||||
| (0..=96, 0..=96) => Self::new(96, 96, Some(Method::Crop), Some(self.animated)),
|
||||
| (0..=320, 0..=240) => Self::new(320, 240, Some(Method::Scale), Some(self.animated)),
|
||||
| (0..=640, 0..=480) => Self::new(640, 480, Some(Method::Scale), Some(self.animated)),
|
||||
| (0..=800, 0..=600) => Self::new(800, 600, Some(Method::Scale), Some(self.animated)),
|
||||
| _ => Self::default(),
|
||||
}
|
||||
}
|
||||
@@ -260,6 +270,7 @@ fn default() -> Self {
|
||||
width: 0,
|
||||
height: 0,
|
||||
method: Method::Scale,
|
||||
animated: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user