diff --git a/.gitignore b/.gitignore index 4cab043..539bc80 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/AppRun b/AppRun new file mode 100755 index 0000000..53bf7c4 --- /dev/null +++ b/AppRun @@ -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" "$@" diff --git a/Makefile b/Makefile index c5e29b5..509428e 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/collect_so_files.sh b/collect_so_files.sh new file mode 100755 index 0000000..930375a --- /dev/null +++ b/collect_so_files.sh @@ -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 binary’s dependencies +ldd "$BINARY" | grep -o '/[^ ]\+' | while read -r lib; do + copy_with_deps "$lib" +done + diff --git a/r.desktop b/r.desktop new file mode 100644 index 0000000..09a1745 --- /dev/null +++ b/r.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Name=r +Exec=usr/bin/r +Type=Application +Icon=r +Categories=Utility; diff --git a/r.png b/r.png new file mode 100644 index 0000000..d5a8df0 Binary files /dev/null and b/r.png differ diff --git a/tools.h b/tools.h index 8893e45..61e29d4 100644 --- a/tools.h +++ b/tools.h @@ -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);