From 126fa22dd6fe4d457116a4d3616f665aba719d02 Mon Sep 17 00:00:00 2001 From: darealshinji Date: Thu, 30 Nov 2023 11:41:00 +0100 Subject: [PATCH] don't save build files in AppHook directory --- checkrt.c | 17 +++++++---------- template.sh | 11 +++++------ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/checkrt.c b/checkrt.c index 916d996..726923a 100644 --- a/checkrt.c +++ b/checkrt.c @@ -107,9 +107,10 @@ void copy_lib(const char *libname, const char *dirname1, const char *dirname2) char *src = get_libpath(libname); if (!src) err(EXIT_FAILURE, "cannot find %s in system", libname); + printf("Copy library: %s\n", src); + /* create target directory */ - const size_t len = strlen(dirname1) + strlen(dirname2) + strlen(libname) + 4; - char *target = malloc(len); + char *target = malloc(strlen(dirname1) + strlen(dirname2) + strlen(libname) + 3); sprintf(target, "%s/%s", dirname1, dirname2); mkdir(target, 0775); @@ -126,8 +127,6 @@ void copy_lib(const char *libname, const char *dirname1, const char *dirname2) ssize_t nread; uint8_t buf[512*1024]; - DEBUG_PRINT("copy from [[%s]] to: %s", src, target); - while ((nread = read(fd_in, buf, sizeof(buf))) > 0) { if (write(fd_out, buf, nread) != nread) { err(EXIT_FAILURE, "error writing to file: %s", target); @@ -153,14 +152,14 @@ char *find_symbol(mmap_t *mem, const char *sym_prefix) /* filesize check */ #define CHECK_FSIZE(x) \ if (x >= mem->size) { \ - DEBUG_PRINT("%s", "offset exceeds filesize"); \ + fprintf(stderr, "%s\n", "offset exceeds filesize"); \ return NULL; \ } /* overflow + filesize check */ #define CHECK_OVERFLOW(a, b) \ if (__builtin_add_overflow(a, b, &tmp)) { \ - DEBUG_PRINT("%s", "overflow detected"); \ + fprintf(stderr, "%s\n", "overflow detected"); \ return NULL; \ } \ CHECK_FSIZE(tmp) @@ -208,7 +207,7 @@ char *find_symbol(mmap_t *mem, const char *sym_prefix) /* do some extra checks to prevent floating-point exceptions * or similar issues */ if (sh_sz < sh_esz || sh_sz == 0 || sh_esz == 0) { - DEBUG_PRINT("error: problematic math division [%ld/%ld] in section header found: %s", + fprintf(stderr, "problematic math division [%ld/%ld] in section header found: %s\n", sh_sz, sh_esz, mem->filename); return NULL; } @@ -291,8 +290,7 @@ char *symbol_version(const char *lib, const char *sym_prefix) bool use_bundled_library(const char *libname, const char *dirname1, const char *dirname2, const char *sym_prefix) { bool rv = false; - size_t len = strlen(dirname1) + strlen(dirname2) + strlen(libname) + 4; - char *lib_bundle = malloc(len); + char *lib_bundle = malloc(strlen(dirname1) + strlen(dirname2) + strlen(libname) + 3); sprintf(lib_bundle, "%s/%s/%s", dirname1, dirname2, libname); @@ -361,7 +359,6 @@ void copy_libraries() char *dir = get_exe_dir(); copy_lib("libgcc_s.so.1", dir, "gcc"); copy_lib("libstdc++.so.6", dir, "cxx"); - fprintf(stderr, "%s\n", "Files copied"); FREE(dir); } diff --git a/template.sh b/template.sh index 4fb4487..f0fdef5 100644 --- a/template.sh +++ b/template.sh @@ -33,9 +33,10 @@ if [ "$APPDIR" == "" ]; then fi APPDIR="$(realpath "$APPDIR")" -echo "Installing AppRun hook 'checkrt'" +CHECKRTDIR="$APPDIR/checkrt" -mkdir -p "$APPDIR/apprun-hooks/checkrt" +echo "Installing AppRun hook 'checkrt'" +mkdir -p "$APPDIR/apprun-hooks" cat > "$APPDIR/apprun-hooks/linuxdeploy-plugin-checkrt.sh" << \EOF #! /usr/bin/env bash @@ -44,8 +45,6 @@ if [ -z "$APPDIR" ]; then APPDIR="$(dirname "$(realpath "$0")")" fi -CHECKRTDIR="$APPDIR/apprun-hooks/checkrt" - if [ -x "$CHECKRTDIR/checkrt" ]; then CHECKRT_LIBS="$($CHECKRTDIR/checkrt)" @@ -67,7 +66,8 @@ if [ -n "$CHECKRT_DEBUG" ]; then fi EOF -cd "$APPDIR/apprun-hooks/checkrt" +mkdir -p "$CHECKRTDIR" +cd "$CHECKRTDIR" save_files @@ -80,5 +80,4 @@ echo "Compiling exec.so" cc -shared -O2 -fPIC exec.c -o exec.so $LDFLAGS rm checkrt.c exec.c -echo "Copy libgcc_s.so.1 and libstdc++.so.6" ./checkrt --copy