void-packages/srcpkgs/systemtap/patches/fix-musl.patch

128 lines
3.6 KiB
Diff

diff --git a/buildrun.cxx b/buildrun.cxx
index 0048d07..904ce47 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -29,6 +29,7 @@ extern "C" {
#include <string.h>
#include <errno.h>
#include <sys/resource.h>
+#include "gnu_basename.h"
}
// A bit of obfuscation for Gentoo's sake.
@@ -943,7 +944,7 @@ make_kernel_run_command (systemtap_session& s, const string& remotedir,
if (remotedir.empty())
opt_u.append(s.uprobes_path);
else
- opt_u.append(remotedir + "/" + basename(s.uprobes_path.c_str()));
+ opt_u.append(remotedir + "/" + gnu_basename(s.uprobes_path.c_str()));
}
cmd.push_back(opt_u);
}
diff --git a/client-http.cxx b/client-http.cxx
index fca7362..d6096b9 100644
--- a/client-http.cxx
+++ b/client-http.cxx
@@ -38,6 +38,7 @@ extern "C" {
#include <elfutils/libdw.h>
#include <fcntl.h>
#include <nss3/nss.h>
+#include <paths.h>
#ifdef HAVE_RPMCRYPTO_H
#include <rpm/rpmcrypto.h>
@@ -1016,7 +1017,7 @@ http_client_backend::include_file_or_directory (const string &subdir,
// Canonicalize the given path and remove the leading /.
string rpath;
- char *cpath = canonicalize_file_name (path.c_str ());
+ char *cpath = realpath (path.c_str (), NULL);
if (! cpath)
{
// It can not be canonicalized. Use the name relative to
diff --git a/client-nss.cxx b/client-nss.cxx
index 55266fe..a775ed1 100644
--- a/client-nss.cxx
+++ b/client-nss.cxx
@@ -576,7 +576,7 @@ nss_client_backend::include_file_or_directory (const string &subdir,
// Canonicalize the given path and remove the leading /.
string rpath;
- char *cpath = canonicalize_file_name (path.c_str ());
+ char *cpath = realpath (path.c_str (), NULL);
if (! cpath)
{
// It can not be canonicalized. Use the name relative to
diff --git a/gnu_basename.h b/gnu_basename.h
new file mode 100644
index 0000000..dce5f19
--- /dev/null
+++ b/gnu_basename.h
@@ -0,0 +1,12 @@
+#ifndef GNU_BASENAME_H
+#define GNU_BASENAME_H
+
+#include <string.h>
+
+#if defined(__GLIBC__)
+#define gnu_basename(src) basename(src)
+#else
+#define gnu_basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src)
+#endif
+
+#endif
diff --git a/remote.cxx b/remote.cxx
index bffeaa9..bd6c7c4 100644
--- a/remote.cxx
+++ b/remote.cxx
@@ -16,6 +16,7 @@ extern "C" {
#include <unistd.h>
#include <sys/socket.h>
#include <sys/un.h>
+#include "gnu_basename.h"
}
#include <cstdio>
@@ -472,7 +473,7 @@ class stapsh : public remote {
if (!s->uprobes_path.empty())
{
- string remoteuprobes = basename(s->uprobes_path.c_str());
+ string remoteuprobes = gnu_basename(s->uprobes_path.c_str());
if ((rc = send_file(s->uprobes_path, remoteuprobes)))
return rc;
diff --git a/session.cxx b/session.cxx
index a22baab..77eedf9 100644
--- a/session.cxx
+++ b/session.cxx
@@ -42,6 +42,7 @@ extern "C" {
#include <unistd.h>
#include <sys/wait.h>
#include <wordexp.h>
+#include <paths.h>
}
#if HAVE_NSS
@@ -1537,7 +1538,7 @@ systemtap_session::parse_cmdline (int argc, char * const argv [])
} else {
char *spath;
assert(optarg);
- spath = canonicalize_file_name (optarg);
+ spath = realpath (optarg, NULL);
if (spath == NULL) {
cerr << _F("ERROR: %s is an invalid directory for --sysroot", optarg) << endl;
return 1;
diff --git a/util.h b/util.h
index c708aa6..ef4a6fe 100644
--- a/util.h
+++ b/util.h
@@ -27,6 +27,7 @@ extern "C" {
#include <spawn.h>
#include <assert.h>
#include <poll.h>
+#include <unistd.h>
}
// Sanity check C++11 support. We're only requiring GCC 4.4's level of