diff --git a/include/linuxdeploy/core/appdir.h b/include/linuxdeploy/core/appdir.h index d5c4a08..7448dda 100644 --- a/include/linuxdeploy/core/appdir.h +++ b/include/linuxdeploy/core/appdir.h @@ -43,7 +43,7 @@ namespace linuxdeploy { bool deployLibrary(const boost::filesystem::path& path, const boost::filesystem::path& destination = ""); // deploy executable - bool deployExecutable(const boost::filesystem::path& path); + bool deployExecutable(const boost::filesystem::path& path, const boost::filesystem::path& destination = ""); // deploy desktop file bool deployDesktopFile(const desktopfile::DesktopFile& desktopFile); diff --git a/src/core/appdir.cpp b/src/core/appdir.cpp index 4a9b92e..e0c7e82 100644 --- a/src/core/appdir.cpp +++ b/src/core/appdir.cpp @@ -270,7 +270,7 @@ namespace linuxdeploy { return true; } - bool deployExecutable(const bf::path& path) { + bool deployExecutable(const bf::path& path, const boost::filesystem::path& destination) { if (hasBeenVisitedAlready(path)) { ldLog() << LD_DEBUG << "File has been visited already:" << path << std::endl; return true; @@ -280,9 +280,29 @@ namespace linuxdeploy { // FIXME: make executables executable - deployFile(path, appDirPath / "usr/bin/"); + auto destinationPath = destination.empty() ? appDirPath / "usr/bin/" : destination; - setElfRPathOperations[appDirPath / "usr/bin" / path.filename()] = "$ORIGIN/../lib"; + deployFile(path, destination); + + std::string rpath = "$ORIGIN/../lib"; + + if (!destination.empty()) { + std::string rpathDestination = destination.string(); + + if (destination.string().back() == '/') { + rpathDestination = destination.string(); + + while (rpathDestination.back() == '/') + rpathDestination.erase(rpathDestination.end() - 1, rpathDestination.end()); + } else { + rpathDestination = destination.parent_path().string(); + } + + auto relPath = bf::relative(bf::absolute(appDirPath) / "usr/lib", bf::absolute(rpathDestination)); + rpath = "$ORIGIN/" + relPath.string(); + } + + setElfRPathOperations[destination / path.filename()] = rpath; if (!deployElfDependencies(path)) return false; @@ -427,8 +447,8 @@ namespace linuxdeploy { return d->deployLibrary(path, 0, destination); } - bool AppDir::deployExecutable(const bf::path& path) { - return d->deployExecutable(path); + bool AppDir::deployExecutable(const bf::path& path, const boost::filesystem::path& destination) { + return d->deployExecutable(path, destination); } bool AppDir::deployDesktopFile(const desktopfile::DesktopFile& desktopFile) {