package=appimage_runtime
-$(package)_version=c1ea7509bc179a05d907baca64f41875662f35f2
+$(package)_version=c9553b05938b22849ac3255ac923bf8e775ce539
$(package)_download_path=https://github.com/AppImage/type2-runtime/archive/
$(package)_file_name=$($(package)_version).tar.gz
-$(package)_sha256_hash=a7906c7d1610eacb6c67a16c554fac8875b05424fea49e291311c3e5db2237a3
+$(package)_sha256_hash=4a27451013b571cf9f5a13660719d091cc79f2344aafa2e48578ddc0e4618af1
$(package)_dependencies=libsquashfuse zstd
$(package)_patches=depends-fix.patch
define $(package)_build_cmds
cd src/runtime && \
export host_prefix="$(host_prefix)" && \
- $(MAKE) runtime-fuse2 -e CC=$($(package)_cc) LDLAGS="$($(package)_ldflags)" && \
- "${HOST}-strip" runtime-fuse2 && \
- echo -ne 'AI\x02' | dd of=runtime-fuse2 bs=1 count=3 seek=8 conv=notrunc
+ $(MAKE) runtime-fuse3 -e CC=$($(package)_cc) LDLAGS="$($(package)_ldflags)" && \
+ "${HOST}-strip" runtime-fuse3
endef
define $(package)_stage_cmds
cd src/runtime && \
- cp -a runtime-fuse2 $($(package)_staging_prefix_dir)/runtime
+ cp -a runtime-fuse3 $($(package)_staging_prefix_dir)/runtime
endef
\ No newline at end of file
package=libfuse
-$(package)_version=2.9.9
-$(package)_download_path=https://github.com/libfuse/libfuse/releases/download/fuse-2.9.9/
+$(package)_version=3.16.2
+$(package)_download_path=https://github.com/libfuse/libfuse/releases/download/fuse-$($(package)_version)
$(package)_file_name=fuse-$($(package)_version).tar.gz
-$(package)_sha256_hash=d0e69d5d608cc22ff4843791ad097f554dd32540ddc9bed7638cc6fea7c1b4b5
-$(package)_patches = arm64.patch no-dlopen.patch
+$(package)_sha256_hash=f797055d9296b275e981f5f62d4e32e089614fc253d1ef2985851025b8a0ce87
+$(package)_patches=toolchain.txt mount.c.diff no-dlopen.patch set_fusermount_path.patch
-define $(package)_config_cmds
- $($(package)_autoconf)
+define $(package)_preprocess_cmds
+ patch -p1 < $($(package)_patch_dir)/set_fusermount_path.patch && \
+ patch -p1 < $($(package)_patch_dir)/no-dlopen.patch && \
+ patch -p1 < $($(package)_patch_dir)/mount.c.diff && \
+ cp $($(package)_patch_dir)/toolchain.txt toolchain.txt && \
+ sed -i -e 's|@host_prefix@|$(host_prefix)|' \
+ -e 's|@cc@|$($(package)_cc)|' \
+ -e 's|@cxx@|$($(package)_cxx)|' \
+ -e 's|@ar@|$($(package)_ar)|' \
+ -e 's|@strip@|$(host_STRIP)|' \
+ -e 's|@arch@|$(host_arch)|' \
+ toolchain.txt
endef
-define $(package)_preprocess_cmds
- patch -p1 -i $($(package)_patch_dir)/arm64.patch && \
- patch -p1 -i $($(package)_patch_dir)/no-dlopen.patch
+define $(package)_config_cmds
+ meson setup --cross-file toolchain.txt build
endef
define $(package)_build_cmds
- $(MAKE)
+ ninja -C build
endef
define $(package)_stage_cmds
- $(MAKE) DESTDIR=$($(package)_staging_dir) install
+ DESTDIR=$($(package)_staging_dir) ninja -C build install
endef
+diff --git a/src/runtime/Makefile b/src/runtime/Makefile
+index d0cbf1f..905b130 100644
--- a/src/runtime/Makefile
+++ b/src/runtime/Makefile
-@@ -1,15 +1,15 @@
+@@ -1,21 +1,21 @@
CC = gcc
CFLAGS = -std=gnu99 -s -Os -D_FILE_OFFSET_BITS=64 -DGIT_COMMIT=\"${GIT_COMMIT}\" -T data_sections.ld -ffunction-sections -fdata-sections -Wl,--gc-sections -static
-LIBS = -lsquashfuse -lsquashfuse_ll -lzstd -lz
+LIBS = -lsquashfuse -lsquashfuse_ll -lzstd -lpthread
- all: runtime-fuse2 runtime-fuse3
+ all: runtime-fuse3 runtime-fuse3
# Compile runtime
- runtime-fuse2.o: runtime.c
-- $(CC) -I/usr/local/include/squashfuse -I/usr/include/fuse -o runtime-fuse2.o -c $(CFLAGS) $^
-+ $(CC) -I${host_prefix}/include -I${host_prefix}/include/fuse -o runtime-fuse2.o -c $(CFLAGS) $^
+ runtime-fuse3.o: runtime.c
+- $(CC) -I/usr/local/include/squashfuse -I/usr/include/fuse -o runtime-fuse3.o -c $(CFLAGS) $^
++ $(CC) -I${host_prefix}/include -I${host_prefix}/include/squashfuse -I${host_prefix}/include/fuse -o runtime-fuse3.o -c $(CFLAGS) $^
- runtime-fuse2: runtime-fuse2.o
-- $(CC) $(CFLAGS) $^ $(LIBS) -lfuse -o runtime-fuse2
-+ $(CC) $(CFLAGS) $^ -L${host_prefix}/lib $(LIBS) -lfuse -lpthread -o runtime-fuse2
+ runtime-fuse3: runtime-fuse3.o
+ $(CC) $(CFLAGS) $^ $(LIBS) -lfuse -o runtime-fuse3
runtime-fuse3.o: runtime.c
- $(CC) -I/usr/local/include/squashfuse -I/usr/include/fuse3 -o runtime-fuse3.o -c $(CFLAGS) $^
---
-2.40.0
-
+- $(CC) -I/usr/local/include/squashfuse -I/usr/include/fuse3 -o runtime-fuse3.o -c $(CFLAGS) $^
++ $(CC) -I${host_prefix}/include -I${host_prefix}/include/squashfuse -I${host_prefix}/include/fuse3 -o runtime-fuse3.o -c $(CFLAGS) $^
+
+ runtime-fuse3: runtime-fuse3.o
+- $(CC) $(CFLAGS) $^ $(LIBS) -lfuse3 -o runtime-fuse3
++ $(CC) $(CFLAGS) $^ -L${host_prefix}/lib $(LIBS) -lfuse3 -lpthread -o runtime-fuse3
+
+ clean:
+ rm -f *.o runtime-fuse3 runtime-fuse3
+++ /dev/null
-From 914871b20a901e3e1e981c92bc42b1c93b7ab81b Mon Sep 17 00:00:00 2001
-From: Riku Voipio <riku.voipio@linaro.org>
-Date: Thu, 07 Feb 2013 11:04:21 +0000
-Subject: fuse_kernel.h: clean includes
-
-Use <linux/types.h> for linux and define types used for other operating systems
-using <stdint.h> types.
----
-(limited to 'include/fuse_kernel.h')
-
-diff --git a/include/fuse_kernel.h b/include/fuse_kernel.h
-index 501450c..df8e9b9 100644
---- a/include/fuse_kernel.h
-+++ b/include/fuse_kernel.h
-@@ -91,12 +91,16 @@
- #ifndef _LINUX_FUSE_H
- #define _LINUX_FUSE_H
-
--#include <sys/types.h>
-+#ifdef __linux__
-+#include <linux/types.h>
-+#else
-+#include <stdint.h>
- #define __u64 uint64_t
- #define __s64 int64_t
- #define __u32 uint32_t
- #define __s32 int32_t
- #define __u16 uint16_t
-+#endif
-
- /*
- * Version negotiation:
---
-cgit v0.9.0.3-67-gacbf
-
--- /dev/null
+diff --git a/lib/mount.c b/lib/mount.c
+index d71e6fc..e9c2ff0 100644
+--- a/lib/mount.c
++++ b/lib/mount.c
+@@ -41,7 +41,6 @@
+ #define umount2(mnt, flags) unmount(mnt, (flags == 2) ? MNT_FORCE : 0)
+ #endif
+
+-#define FUSERMOUNT_PROG "fusermount3"
+ #define FUSE_COMMFD_ENV "_FUSE_COMMFD"
+
+ #ifndef HAVE_FORK
+@@ -117,17 +116,87 @@ static const struct fuse_opt fuse_mount_opts[] = {
+ FUSE_OPT_END
+ };
+
++int fileExists(const char* path);
++char* findBinaryInFusermountDir(const char* binaryName);
++
++int fileExists(const char* path) {
++ FILE* file = fopen(path, "r");
++ if (file) {
++ fclose(file);
++ return 1;
++ }
++ return 0;
++}
++
++char* findBinaryInFusermountDir(const char* binaryName) {
++ // For security reasons, we do not search the binary on the $PATH;
++ // instead, we check if the binary exists in FUSERMOUNT_DIR
++ // as defined in meson.build
++ char* binaryPath = malloc(strlen(FUSERMOUNT_DIR) + strlen(binaryName) + 2);
++ strcpy(binaryPath, FUSERMOUNT_DIR);
++ strcat(binaryPath, "/");
++ strcat(binaryPath, binaryName);
++ if (fileExists(binaryPath)) {
++ return binaryPath;
++ }
++
++ // Debian, Ubuntu
++ char* binaryPath2 = malloc(strlen(binaryName) + 6);
++ strcat(binaryPath2, "/bin/");
++ strcat(binaryPath2, binaryName);
++ if (fileExists(binaryPath2)) {
++ return binaryPath2;
++ }
++
++ // If the binary does not exist in FUSERMOUNT_DIR, return NULL
++ return NULL;
++}
++
++static const char *fuse_mount_prog(void)
++{
++ // Check if the FUSERMOUNT_PROG environment variable is set and if so, use it
++ const char *prog = getenv("FUSERMOUNT_PROG");
++ if (prog) {
++ if (access(prog, X_OK) == 0)
++ return prog;
++ }
++
++ // Check if there is a binary "fusermount3"
++ prog = findBinaryInFusermountDir("fusermount3");
++ if (access(prog, X_OK) == 0)
++ return prog;
++
++ // Check if there is a binary called "fusermount"
++ // This is known to work for our purposes
++ prog = findBinaryInFusermountDir("fusermount");
++ if (access(prog, X_OK) == 0)
++ return prog;
++
++ // For i = 4...99, check if there is a binary called "fusermount" + i
++ // It is not yet known whether this will work for our purposes, but it is better than not even attempting
++ for (int i = 4; i < 100; i++) {
++ prog = findBinaryInFusermountDir("fusermount" + i);
++ if (access(prog, X_OK) == 0)
++ return prog;
++ }
++
++ // If all else fails, return NULL
++ return NULL;
++}
++
+ static void exec_fusermount(const char *argv[])
+ {
+- execv(FUSERMOUNT_DIR "/" FUSERMOUNT_PROG, (char **) argv);
+- execvp(FUSERMOUNT_PROG, (char **) argv);
++ const char *fusermount_prog = fuse_mount_prog();
++ if (fusermount_prog) {
++ execv(fusermount_prog, (char **) argv);
++ }
+ }
+
+ void fuse_mount_version(void)
+ {
+ int pid = fork();
+ if (!pid) {
+- const char *argv[] = { FUSERMOUNT_PROG, "--version", NULL };
++ const char *argv[] = { fuse_mount_prog(), "--version", NULL };
+ exec_fusermount(argv);
+ _exit(1);
+ } else if (pid != -1)
+@@ -300,7 +369,7 @@ void fuse_kern_unmount(const char *mountpoint, int fd)
+ return;
+
+ if(pid == 0) {
+- const char *argv[] = { FUSERMOUNT_PROG, "-u", "-q", "-z",
++ const char *argv[] = { fuse_mount_prog(), "-u", "-q", "-z",
+ "--", mountpoint, NULL };
+
+ exec_fusermount(argv);
+@@ -346,7 +415,7 @@ static int setup_auto_unmount(const char *mountpoint, int quiet)
+ }
+ }
+
+- argv[a++] = FUSERMOUNT_PROG;
++ argv[a++] = fuse_mount_prog();
+ argv[a++] = "--auto-unmount";
+ argv[a++] = "--";
+ argv[a++] = mountpoint;
+@@ -407,7 +476,7 @@ static int fuse_mount_fusermount(const char *mountpoint, struct mount_opts *mo,
+ }
+ }
+
+- argv[a++] = FUSERMOUNT_PROG;
++ argv[a++] = fuse_mount_prog();
+ if (opts) {
+ argv[a++] = "-o";
+ argv[a++] = opts;
+@@ -421,7 +490,7 @@ static int fuse_mount_fusermount(const char *mountpoint, struct mount_opts *mo,
+ snprintf(env, sizeof(env), "%i", fds[0]);
+ setenv(FUSE_COMMFD_ENV, env, 1);
+ exec_fusermount(argv);
+- perror("fuse: failed to exec fusermount3");
++ perror("fuse: failed to exec fusermount");
+ _exit(1);
+ }
+
+diff --git a/lib/fuse.c b/lib/fuse.c
+index 2a88918..34a46c3 100644
--- a/lib/fuse.c
+++ b/lib/fuse.c
-@@ -227,32 +227,6 @@ static struct fuse_module *fuse_modules;
+@@ -242,50 +242,7 @@ static void fuse_unregister_module(struct fuse_module *m)
- static int fuse_load_so_name(const char *soname)
+ static int fuse_load_so_module(const char *module)
{
+- int ret = -1;
+- char *tmp;
- struct fusemod_so *so;
+- fuse_module_factory_t *factory;
-
+- tmp = malloc(strlen(module) + 64);
+- if (!tmp) {
+- fuse_log(FUSE_LOG_ERR, "fuse: memory allocation failed\n");
+- return -1;
+- }
+- sprintf(tmp, "libfusemod_%s.so", module);
- so = calloc(1, sizeof(struct fusemod_so));
- if (!so) {
-- fprintf(stderr, "fuse: memory allocation failed\n");
-- return -1;
+- fuse_log(FUSE_LOG_ERR, "fuse: failed to allocate module so\n");
+- goto out;
- }
-
-- fuse_current_so = so;
-- so->handle = dlopen(soname, RTLD_NOW);
-- fuse_current_so = NULL;
-- if (!so->handle) {
-- fprintf(stderr, "fuse: %s\n", dlerror());
-- goto err;
+- so->handle = dlopen(tmp, RTLD_NOW);
+- if (so->handle == NULL) {
+- fuse_log(FUSE_LOG_ERR, "fuse: dlopen(%s) failed: %s\n",
+- tmp, dlerror());
+- goto out_free_so;
- }
-- if (!so->ctr) {
-- fprintf(stderr, "fuse: %s did not register any modules\n",
-- soname);
-- goto err;
+-
+- sprintf(tmp, "fuse_module_%s_factory", module);
+- factory = (fuse_module_factory_t*)dlsym(so->handle, tmp);
+- if (factory == NULL) {
+- fuse_log(FUSE_LOG_ERR, "fuse: symbol <%s> not found in module: %s\n",
+- tmp, dlerror());
+- goto out_dlclose;
- }
-- return 0;
+- ret = fuse_register_module(module, *factory, so);
+- if (ret)
+- goto out_dlclose;
+-
+-out:
+- free(tmp);
+- return ret;
-
--err:
-- if (so->handle)
-- dlclose(so->handle);
+-out_dlclose:
+- dlclose(so->handle);
+-out_free_so:
- free(so);
- return -1;
+- goto out;
++ return -1;
}
-@@ -314,7 +288,6 @@ static void fuse_put_module(struct fuse_module *m)
+ static struct fuse_module *fuse_find_module(const char *module)
+@@ -335,7 +292,6 @@ static void fuse_put_module(struct fuse_module *m)
else
mp = &(*mp)->next;
}
- dlclose(so->handle);
free(so);
}
- }
---
-2.40.0
-
+ } else if (!m->ctr) {
--- /dev/null
+diff --git a/lib/meson.build b/lib/meson.build
+index 9044630..ea09d45 100644
+--- a/lib/meson.build
++++ b/lib/meson.build
+@@ -32,7 +32,7 @@ else
+ deps += cc.find_library('rt')
+ endif
+
+-fusermount_path = join_paths(get_option('prefix'), get_option('bindir'))
++fusermount_path = '/usr/bin'
+ libfuse = library('fuse3', libfuse_sources, version: meson.project_version(),
+ soversion: '3', include_directories: include_dirs,
+ dependencies: deps, install: true,
--- /dev/null
+[binaries]
+c = '@cc@'
+cpp = '@cxx@'
+ar = '@ar@'
+strip = '@strip@'
+pkgconfig = '/home/user/.guix-profile/bin/pkg-config'
+
+[host_machine]
+system = 'linux'
+cpu_family = '@arch@'
+cpu = '@arch@'
+endian = 'little'
+
+[project options]
+utils = false
+
+[built-in options]
+default_library = 'static'
+prefix = '@host_prefix@'
\ No newline at end of file