Fix share path for AppImage

This commit is contained in:
xarkes 2017-10-23 11:22:15 +02:00
parent 41be016467
commit 37b73ed223
2 changed files with 36 additions and 4 deletions

View File

@ -52,9 +52,9 @@ after_success:
before_script:
- git submodule init ; git submodule update
- cd radare2
# Hack to modify r2 prefixes
- sed -i s,__WINDOWS__,1, libr/include/r_userconf.h.acr
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
# PREFIX modification for AppImage
PREFIX=/tmp/.cutter_usr/
INSTALL_TARGET=install sys/install.sh;
else
LDFLAGS=-headerpad_max_install_names INSTALL_TARGET=install sys/install.sh;

View File

@ -7,6 +7,28 @@
#include "dialogs/NewFileDialog.h"
#include "dialogs/OptionsDialog.h"
#ifdef __unix__
#define SYMLINK "/tmp/.cutter_usr"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
void set_appimage_symlink(char* argv0)
{
char* path = strdup(argv0);
char* i = strrchr(path, '/');
*(i+1) = '\0';
char* dest = strcat(path, "usr/");
struct stat buf;
if (lstat(SYMLINK, &buf) == 0 && S_ISLNK(buf.st_mode)) {
remove(SYMLINK);
}
symlink(dest, SYMLINK);
free(path);
}
#endif
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
@ -21,7 +43,6 @@ int main(int argc, char *argv[])
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
#endif
QCommandLineParser cmd_parser;
cmd_parser.setApplicationDescription(QObject::tr("A Qt and C++ GUI for radare2 reverse engineering framework"));
cmd_parser.addHelpOption();
@ -85,5 +106,16 @@ int main(int argc, char *argv[])
main->openNewFile(args[0], anal_level_specified ? anal_level : -1);
}
return a.exec();
// Hack to make it work with AppImage
#ifdef __unix__
set_appimage_symlink(argv[0]);
#endif
int ret = a.exec();
#ifdef __unix__
remove(SYMLINK);
#endif
return ret;
}