init appimage building
This commit is contained in:
1 parent
bfaa00bb38
commit
b60e18fe6b
14 files changed
+625
-3
No files matched your search
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
|
||||
export APPDIR="${APPDIR:-$(cd "$(dirname "$0")" && pwd)}"
|
||||
export PATH="$APPDIR/usr/bin:$PATH"
|
||||
for hook in "$APPDIR"/apprun-hooks/*.sh; do
|
||||
# shellcheck source=/dev/null
|
||||
[[ ! -f "$hook" ]] || source "$hook"
|
||||
done
|
||||
exec "$APPDIR/usr/bin/meshcore_open" "$@"
|
||||
@@ -0,0 +1,27 @@
|
||||
ARG BASE_IMAGE=ubuntu:24.04@sha256:fe81560990fae86dc4743202b2cb4d3df98d0bcf949173cecef15ce1127ef852
|
||||
FROM ${BASE_IMAGE} AS build
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
ca-certificates clang cmake ninja-build pkg-config libgtk-3-dev \
|
||||
librsvg2-dev libgirepository1.0-dev libgdk-pixbuf-2.0-dev libgtk-3-bin \
|
||||
libgdk-pixbuf2.0-bin libgdk-pixbuf2.0-dev binutils patchelf curl jq \
|
||||
file desktop-file-utils xdg-user-dirs git rsync unzip xz-utils make g++ \
|
||||
libssl-dev libunwind-dev libvulkan-dev libgl1-mesa-dev libglu1-mesa-dev \
|
||||
libasound2-dev libsecret-1-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY appimage-tools.json /opt/packaging/
|
||||
RUN set -eu; curl --fail --location --retry 3 --connect-timeout 20 --max-time 600 \
|
||||
"$(jq -er .flutter.url /opt/packaging/appimage-tools.json)" --output /tmp/flutter.tar.xz \
|
||||
&& printf '%s /tmp/flutter.tar.xz\n' "$(jq -er .flutter.sha256 /opt/packaging/appimage-tools.json)" | sha256sum --check \
|
||||
&& tar -xJf /tmp/flutter.tar.xz -C /opt && rm /tmp/flutter.tar.xz \
|
||||
&& chmod -R a+rwX /opt/flutter
|
||||
ENV PATH="/opt/flutter/bin:${PATH}"
|
||||
|
||||
FROM ${BASE_IMAGE} AS runtime-test
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
xvfb xauth x11-utils x11-apps xdotool imagemagick dbus-x11 libgl1 libegl1 libgles2 \
|
||||
libgl1-mesa-dri fonts-dejavu-core \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
@@ -0,0 +1,7 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=MeshCore Open
|
||||
Exec=meshcore_open
|
||||
Icon=com.meshcore.meshcore_open
|
||||
Terminal=false
|
||||
Categories=Network;InstantMessaging;
|
||||
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
project="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
source "$project/scripts/build_appimage.sh"
|
||||
temporary="$(mktemp -d)"
|
||||
trap 'rm -rf "$temporary"' EXIT
|
||||
|
||||
assert_fails() {
|
||||
if "$@" >"$temporary/error" 2>&1; then
|
||||
printf 'Expected failure: %s\n' "$*" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
assert_fails packaging_enabled Debug
|
||||
assert_fails packaging_enabled Profile
|
||||
packaging_enabled Release
|
||||
MESHCORE_BUILD_APPIMAGE=0 assert_fails packaging_enabled Release
|
||||
assert_fails check_bundle "$temporary/missing"
|
||||
|
||||
mkdir -p "$temporary/bundle/lib" "$temporary/bundle/data/flutter_assets"
|
||||
touch "$temporary/bundle/meshcore_open" "$temporary/bundle/lib/libapp.so" \
|
||||
"$temporary/bundle/data/icudtl.dat"
|
||||
chmod +x "$temporary/bundle/meshcore_open"
|
||||
check_bundle "$temporary/bundle"
|
||||
rm "$temporary/bundle/lib/libapp.so"
|
||||
assert_fails check_bundle "$temporary/bundle"
|
||||
touch "$temporary/bundle/lib/libapp.so"
|
||||
MESHCORE_BUILD_APPIMAGE=0 bash "$project/scripts/build_appimage.sh" \
|
||||
"$project" /missing "$temporary/output" Release x64
|
||||
bash "$project/scripts/build_appimage.sh" "$project" /missing "$temporary/output" Debug x64
|
||||
[[ ! -d "$temporary/output" ]]
|
||||
assert_fails bash "$project/scripts/build_appimage.sh" \
|
||||
"$project" /missing "$temporary/output" Release arm64
|
||||
|
||||
stage_bundle "$project" "$temporary/bundle" "$temporary/AppDir with spaces"
|
||||
check_bundle "$temporary/AppDir with spaces/usr/bin"
|
||||
[[ -x "$temporary/AppDir with spaces/AppRun" ]]
|
||||
[[ -f "$temporary/AppDir with spaces/usr/share/applications/com.meshcore.meshcore_open.desktop" ]]
|
||||
|
||||
printf 'fixture\n' > "$temporary/input"
|
||||
checksum="$(sha256sum "$temporary/input")"
|
||||
checksum="${checksum%% *}"
|
||||
download_verified "file://$temporary/input" "$checksum" "$temporary/cache/tool"
|
||||
download_verified 'https://invalid.example/offline' "$checksum" "$temporary/cache/tool"
|
||||
assert_fails download_verified "file://$temporary/input" \
|
||||
'0000000000000000000000000000000000000000000000000000000000000000' "$temporary/cache/invalid"
|
||||
[[ ! -e "$temporary/cache/invalid" ]]
|
||||
printf 'corruption\n' >> "$temporary/cache/tool"
|
||||
assert_fails download_verified "file://$temporary/input" "$checksum" "$temporary/cache/tool"
|
||||
|
||||
printf 'AppImage packaging contract tests passed\n'
|
||||
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
image="$(realpath "$1")"
|
||||
mkdir -p "$2"
|
||||
output="$(realpath "$2")"
|
||||
workspace="$(mktemp -d)"
|
||||
app_pid=''
|
||||
bus_pid=''
|
||||
cleanup() {
|
||||
[[ -z "$app_pid" ]] || kill "$app_pid" 2>/dev/null || true
|
||||
[[ -z "$bus_pid" ]] || kill "$bus_pid" 2>/dev/null || true
|
||||
rm -rf "$workspace"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
cd "$workspace"
|
||||
printf 'AppImage runtime test: extracting image\n'
|
||||
cp "$image" "$workspace/extractor"
|
||||
printf '\0\0\0' | dd of="$workspace/extractor" bs=1 seek=8 count=3 conv=notrunc status=none
|
||||
timeout 60 "$workspace/extractor" --appimage-extract > /dev/null
|
||||
appdir="$workspace/squashfs-root"
|
||||
[[ -x "$appdir/AppRun" && -f "$appdir/usr/bin/lib/libapp.so" && \
|
||||
-f "$appdir/usr/bin/data/icudtl.dat" && -d "$appdir/usr/bin/data/flutter_assets" ]]
|
||||
[[ -f "$appdir/usr/bin/lib/libonnxruntime.so.1" && \
|
||||
-f "$appdir/usr/share/glib-2.0/schemas/gschemas.compiled" ]]
|
||||
ldd "$appdir/usr/bin/meshcore_open" > "$output/dependencies.log" 2>&1
|
||||
while IFS= read -r -d '' library; do
|
||||
printf '\n%s\n' "${library#"$appdir/"}" >> "$output/dependencies.log"
|
||||
ldd "$library" >> "$output/dependencies.log" 2>&1 || true
|
||||
done < <(find "$appdir/usr/bin/lib" "$appdir/usr/lib" -type f -name '*.so*' -print0)
|
||||
if grep 'not found' "$output/dependencies.log"; then
|
||||
printf 'Unresolved AppImage dependencies\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$workspace/home/Documents" "$workspace/home/config"
|
||||
printf 'XDG_DOCUMENTS_DIR="%s/Documents"\n' "$workspace/home" > "$workspace/home/config/user-dirs.dirs"
|
||||
bus_pid="$(dbus-daemon --session --address="unix:path=$workspace/system-bus" --fork --print-pid)"
|
||||
printf 'AppImage runtime test: launching application\n'
|
||||
env -u LD_LIBRARY_PATH -u GTK_PATH -u GSETTINGS_SCHEMA_DIR \
|
||||
HOME="$workspace/home" XDG_CONFIG_HOME="$workspace/home/config" \
|
||||
XDG_DATA_HOME="$workspace/home/data" XDG_CACHE_HOME="$workspace/home/cache" \
|
||||
DBUS_SYSTEM_BUS_ADDRESS="unix:path=$workspace/system-bus" \
|
||||
dbus-run-session -- "$appdir/AppRun" > "$output/startup.log" 2>&1 &
|
||||
app_pid=$!
|
||||
window="$(timeout 60 xdotool search --sync --onlyvisible --limit 1 --name 'MeshCore Open|meshcore_open')"
|
||||
colors=0
|
||||
deadline=$((SECONDS + 60))
|
||||
while (( SECONDS < deadline )); do
|
||||
kill -0 "$app_pid"
|
||||
xwd -silent -id "$window" -out "$workspace/window.xwd"
|
||||
convert "$workspace/window.xwd" "$output/startup.png"
|
||||
colors="$(identify -format '%k' "$output/startup.png")"
|
||||
(( colors < 20 )) || break
|
||||
done
|
||||
(( colors >= 20 )) || { printf 'Application window remained blank\n' >&2; exit 1; }
|
||||
[[ -s "$output/startup.png" ]]
|
||||
if grep -Ei 'error while loading shared libraries|cannot open shared object|failed to load asset|unhandled exception' "$output/startup.log"; then
|
||||
exit 1
|
||||
fi
|
||||
printf 'Extracted AppImage startup passed; screenshot: %s/startup.png\n' "$output"
|
||||
Reference in new issue
Block a user