Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/auriamg/macdylibbundler.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaleb Hearon <chearon@moresteam.com>2016-11-08 17:45:27 +0300
committerCaleb Hearon <chearon@moresteam.com>2016-11-08 17:52:48 +0300
commit917afba5bf65f23e5e7bf2d59ef4b4436749bf80 (patch)
tree6ae47f7f40ef430f3295eaed5a4670369288b8e9
parentab6c8a4cc9e3f87a82d9ba98cf99c887b844396e (diff)
fix paths that contain (but not are) symlinks
if part of the path contains a symbolic link, the readlink command will identify it as a regular file. it only tells you if the "last" part of the path is a symbolic link fix this by resolving all paths with realpath() and checking if different. the full symbolic link is stored now instead of just suffix
-rw-r--r--src/Dependency.cpp37
1 files changed, 17 insertions, 20 deletions
diff --git a/src/Dependency.cpp b/src/Dependency.cpp
index 21e06d2..ec37863 100644
--- a/src/Dependency.cpp
+++ b/src/Dependency.cpp
@@ -88,27 +88,24 @@ bool missing_prefixes = false;
Dependency::Dependency(std::string path)
{
+ char original_file_buffer[PATH_MAX];
+ std::string original_file;
+
+ if (not realpath(rtrim(path).c_str(), original_file_buffer))
+ {
+ std::cerr << "\n/!\\ WARNING : Cannot resolve path '" << path.c_str() << "'" << std::endl;
+ original_file = path;
+ }
+ else
+ {
+ original_file = original_file_buffer;
+ }
+
// check if given path is a symlink
- std::string cmd = "readlink -n " + path;
- const bool is_symlink = system( (cmd+" > /dev/null").c_str())==0;
- if (is_symlink)
+ if (original_file != rtrim(path))
{
- char original_file_buffer[PATH_MAX];
- std::string original_file;
-
- if (not realpath(rtrim(path).c_str(), original_file_buffer))
- {
- std::cerr << "\n/!\\ WARNING : Cannot resolve symlink '" << path.c_str() << "'" << std::endl;
- original_file = path;
- }
- else
- {
- original_file = original_file_buffer;
- }
- //original_file = original_file.substr(0, original_file.find("\n") );
-
filename = stripPrefix(original_file);
- prefix = path.substr(0, path.rfind("/")+1);
+ prefix = original_file.substr(0, original_file.rfind("/")+1);
addSymlink(path);
}
else
@@ -194,7 +191,7 @@ std::string Dependency::getInnerPath()
}
-void Dependency::addSymlink(std::string s){ symlinks.push_back(stripPrefix(s)); }
+void Dependency::addSymlink(std::string s){ symlinks.push_back(s); }
// comapres the given Dependency with this one. If both refer to the same file,
// it returns true and merges both entries into one.
@@ -240,7 +237,7 @@ void Dependency::fixFileThatDependsOnMe(std::string file_to_fix)
for(int n=0; n<symamount; n++)
{
std::string command = std::string("install_name_tool -change ") +
- prefix+symlinks[n] + " " + getInnerPath() + " " + file_to_fix;
+ symlinks[n] + " " + getInnerPath() + " " + file_to_fix;
if( systemp( command ) != 0 )
{