feat: add AppImage build support with desktop integration and packaging scripts

Implement AppImage packaging pipeline including desktop file generation, icon bundling, and AppStream metadata. The build script creates a portable Linux executable with automatic desktop integration using linuxdeploy and appimagetool. Key additions include the .desktop launcher file, application icon in multiple resolutions, and AppStream metainfo for software center compatibility. The packaging process compiles the application, bundles all runtime dependencies, and generates a self-contained AppImage binary in the dist/ directory.
This commit is contained in:
retoor 2025-04-08 22:00:21 +00:00
parent 91ab658c3c
commit e802a1d3ed
7 changed files with 61 additions and 11 deletions

5
.gitignore vendored
View File

@ -1,4 +1,5 @@
.vscode
AppImage
.venv
.history
.backup*
@ -12,3 +13,7 @@ auth.h
tests
rpylib.so
rd
bin
claude.sh
grok.sh
ollama.sh

4
AppRun Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
HERE="$(dirname "$(readlink -f "$0")")"
export LD_LIBRARY_PATH="$HERE/usr/lib:$LD_LIBRARY_PATH"
exec "$HERE/usr/bin/r" "$@"

View File

@ -1,8 +1,8 @@
all: build build_rd build_free build_rpylib run build_mingw
all: build build_rpylib run build_mingw
# Variables for compiler and flags
CC = gcc
CFLAGS = -Ofast -Werror -Wall -lreadline -lncurses -lcurl -lssl -lcrypto -ljson-c -lm -lsqlite3
CFLAGS = -Ofast -Werror -Wall -lreadline -lncurses -lcurl -lgnutls -ljson-c -lsqlite3 -lm $(pkg-config --cflags --libs gnutls gmp) -lnettle -lssl -lcrypto
# MinGW Variables
MINGW_CC = x86_64-w64-mingw32-gcc # Change to x86_64-w64-mingw32-gcc for 64-bit
@ -10,17 +10,24 @@ MINGW_CFLAGS = -Ofast -Werror -Wall -lreadline -lcurl -lssl -lcrypto -ljson-c -l
# Targets
build:
$(CC) main.c $(CFLAGS) -o r
$(CC) main.c $(CFLAGS) -o bin/r
-@rm -rf AppImage
mkdir -p AppImage
mkdir -p AppImage/usr
mkdir -p AppImage/usr/bin
mkdir -p AppImage/lib
cp AppRun AppImage/AppRun
cp r.desktop AppImage/r.desktop
cp r.png AppImage/r.png
cp bin/r AppImage/usr/bin/r
./collect_so_files.sh
#./prepare_app_image AppImage/usr/bin/r AppImage
appimagetool-x86_64.AppImage AppImage
mv r-x86_64.AppImage r
publish:
-@publish r
build_free:
$(CC) -DOLLAMA main.c $(CFLAGS) -o rf
@publish rf
build_rd:
$(CC) -DRD main.c $(CFLAGS) -o rd
publish rd
build_rpylib:
$(CC) -shared -o rpylib.so -fPIC rpylib.c -lpython3.12 `python3-config --includes` -I/usr/include/CL -ljson-c -lcurl -lsqlite3
publish rpylib.so

27
collect_so_files.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
# Script: collect_so_files.sh
BINARY="AppImage/usr/bin/r"
LIB_DIR="AppImage/usr/lib"
mkdir -p "$LIB_DIR"
# Function to copy a library and its dependencies
copy_with_deps() {
local lib="$1"
if [ -f "$lib" ] && [ ! -f "$LIB_DIR/$(basename "$lib")" ]; then
cp "$lib" "$LIB_DIR/"
echo "Copied: $lib"
# Recursively check dependencies of this library
ldd "$lib" | grep -o '/[^ ]\+' | while read -r dep; do
if [ -f "$dep" ]; then
copy_with_deps "$dep"
fi
done
fi
}
# Start with the binarys dependencies
ldd "$BINARY" | grep -o '/[^ ]\+' | while read -r lib; do
copy_with_deps "$lib"
done

6
r.desktop Normal file
View File

@ -0,0 +1,6 @@
[Desktop Entry]
Name=r
Exec=usr/bin/r
Type=Application
Icon=r
Categories=Utility;

BIN
r.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@ -368,6 +368,7 @@ char *tool_function_linux_terminal(char *command) {
perror("popen failed");
return strdup("Popen failed!");
}
while (fgets(buffer, sizeof(buffer), fp) != NULL) {
size_t chunk_size = strlen(buffer);