Fix AppImage share path

This commit is contained in:
xarkes 2017-10-23 23:54:35 +02:00
parent a45fd094ad
commit 18fe4375d4

View File

@ -16,15 +16,16 @@
void set_appimage_symlink(char* argv0) void set_appimage_symlink(char* argv0)
{ {
char* path = strdup(argv0); char* path = realpath("/proc/self/exe", NULL);
char* i = strrchr(path, '/'); char* i = strrchr(path, '/');
*(i+1) = '\0'; *(i+1) = '\0';
char* dest = strcat(path, "usr/"); char* dest = strcat(path, "../");
struct stat buf; struct stat buf;
if (lstat(PREFIX, &buf) == 0 && S_ISLNK(buf.st_mode)) { if (lstat(PREFIX, &buf) == 0 && S_ISLNK(buf.st_mode)) {
remove(PREFIX); remove(PREFIX);
} }
symlink(dest, PREFIX); symlink(dest, PREFIX);
printf("'%s' '%s' '%s'\n", path, i, dest);
free(path); free(path);
} }
#endif #endif