diff options
author | Victor Kamensky <kamensky@cisco.com> | 2018-04-05 11:25:28 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-04-06 11:41:01 +0100 |
commit | 5aa93de3a79c8691e74e982d3d4b0099b04f5555 (patch) | |
tree | fa9730f4e96f964c5129917c44e60cafd693639e /meta/recipes-kernel/systemtap/systemtap/0001-sysroot-handle-symbolic-links-with-absolute-name-rel.patch | |
parent | a22b8140c6924eb3b3cd7b5bea66a4d3ed413807 (diff) | |
download | openembedded-core-contrib-5aa93de3a79c8691e74e982d3d4b0099b04f5555.tar.gz |
systemtap: support --sysroot option in variety of situations in cross build
For details on issues fixed please look at commit message of individual
patches.
Upstream-Status: Backport [systemtap@sourceware.org]
Signed-off-by: Victor Kamensky <kamensky@cisco.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-kernel/systemtap/systemtap/0001-sysroot-handle-symbolic-links-with-absolute-name-rel.patch')
-rw-r--r-- | meta/recipes-kernel/systemtap/systemtap/0001-sysroot-handle-symbolic-links-with-absolute-name-rel.patch | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-handle-symbolic-links-with-absolute-name-rel.patch b/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-handle-symbolic-links-with-absolute-name-rel.patch new file mode 100644 index 0000000000..8a3d39a5b8 --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-handle-symbolic-links-with-absolute-name-rel.patch @@ -0,0 +1,117 @@ +From 2041085d1a700201dc088991ca8136e7935bf42f Mon Sep 17 00:00:00 2001 +From: Victor Kamensky <kamensky@cisco.com> +Date: Wed, 21 Mar 2018 11:35:26 -0500 +Subject: [PATCH] sysroot: handle symbolic links with absolute name relative to + sysroot + +In case of symbolic link found under sysroot point to absolute path, +instead of trying to look for such absolute path in host system, +apply sysroot prefix first. + +Upstream-Status: Backport +Signed-off-by: Victor Kamensky <kamensky@cisco.com> +--- + util.cxx | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 76 insertions(+) + +Index: git/util.cxx +=================================================================== +--- git.orig/util.cxx ++++ git/util.cxx +@@ -441,6 +441,64 @@ split_lines(const char *buf, size_t n) + return lines; + } + ++static string ++follow_link(const string& name, const string& sysroot) ++{ ++ char *linkname; ++ ssize_t r; ++ string retpath; ++ struct stat st; ++ ++ const char *f = name.c_str(); ++ ++ lstat(f, &st); ++ ++ linkname = (char *) malloc(st.st_size + 1); ++ ++ if (linkname) ++ { ++ r = readlink(f, linkname, st.st_size + 1); ++ linkname[st.st_size] = '\0'; ++ /* ++ * If we have non-empty sysroot and we got link that ++ * points to absolute path name, we need to look at ++ * this path relative to sysroot itself. access and ++ * stat will follow symbolic links correctly only in ++ * case with empty sysroot. ++ */ ++ while (r != -1 && linkname && linkname[0] == '/') ++ { ++ string fname1 = sysroot + linkname; ++ const char *f1 = fname1.c_str(); ++ if (access(f1, X_OK) == 0 ++ && stat(f1, &st) == 0 ++ && S_ISREG(st.st_mode)) ++ { ++ retpath = fname1; ++ break; ++ } ++ else if (lstat(f1, &st) == 0 ++ && S_ISLNK(st.st_mode)) ++ { ++ free(linkname); ++ linkname = (char *) malloc(st.st_size + 1); ++ if (linkname) ++ { ++ r = readlink(f1, linkname, st.st_size + 1); ++ linkname[st.st_size] = '\0'; ++ } ++ } ++ else ++ { ++ break; ++ } ++ } ++ } ++ free(linkname); ++ ++ return retpath; ++} ++ + // Resolve an executable name to a canonical full path name, with the + // same policy as execvp(). A program name not containing a slash + // will be searched along the $PATH. +@@ -465,6 +523,14 @@ string find_executable(const string& nam + if (name.find('/') != string::npos) // slash in the path already? + { + retpath = sysroot + name; ++ ++ const char *f = retpath.c_str(); ++ if (sysroot != "" ++ && lstat(f, &st) == 0 ++ && S_ISLNK(st.st_mode)) ++ { ++ retpath = follow_link(f, sysroot); ++ } + } + else // Nope, search $PATH. + { +@@ -493,6 +559,16 @@ string find_executable(const string& nam + retpath = fname; + break; + } ++ else if (sysroot != "" ++ && lstat(f, &st) == 0 ++ && S_ISLNK(st.st_mode)) ++ { ++ retpath = follow_link(f, sysroot); ++ if (retpath != "") ++ { ++ break; ++ } ++ } + } + } + } |