Detect lsof
Also, don't use lsof on Linux since it's not needed. Fixes #1328.
This commit is contained in:
parent
efa4bdbfcd
commit
749696e71c
4 changed files with 12 additions and 4 deletions
|
@ -15,6 +15,7 @@ SQLITE3_LIBS = @SQLITE3_LIBS@
|
||||||
bash = @bash@
|
bash = @bash@
|
||||||
bindir = @bindir@
|
bindir = @bindir@
|
||||||
bro = @bro@
|
bro = @bro@
|
||||||
|
lsof = @lsof@
|
||||||
datadir = @datadir@
|
datadir = @datadir@
|
||||||
datarootdir = @datarootdir@
|
datarootdir = @datarootdir@
|
||||||
docdir = @docdir@
|
docdir = @docdir@
|
||||||
|
|
|
@ -128,6 +128,7 @@ NEED_PROG(xz, xz)
|
||||||
AC_PATH_PROG(dot, dot)
|
AC_PATH_PROG(dot, dot)
|
||||||
AC_PATH_PROG(pv, pv, pv)
|
AC_PATH_PROG(pv, pv, pv)
|
||||||
AC_PATH_PROG(bro, bro, bro)
|
AC_PATH_PROG(bro, bro, bro)
|
||||||
|
AC_PATH_PROG(lsof, lsof, lsof)
|
||||||
|
|
||||||
|
|
||||||
NEED_PROG(cat, cat)
|
NEED_PROG(cat, cat)
|
||||||
|
|
|
@ -426,22 +426,27 @@ void LocalStore::findRuntimeRoots(PathSet & roots)
|
||||||
throw SysError("iterating /proc");
|
throw SysError("iterating /proc");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(__linux__)
|
||||||
try {
|
try {
|
||||||
auto lsofRegex = std::regex(R"(^n(/.*)$)");
|
printError("RUN LSOF %s", LSOF);
|
||||||
|
std::regex lsofRegex(R"(^n(/.*)$)");
|
||||||
auto lsofLines =
|
auto lsofLines =
|
||||||
tokenizeString<std::vector<string>>(runProgram("lsof", true, { "-n", "-w", "-F", "n" }), "\n");
|
tokenizeString<std::vector<string>>(runProgram(LSOF, true, { "-n", "-w", "-F", "n" }), "\n");
|
||||||
for (const auto & line : lsofLines) {
|
for (const auto & line : lsofLines) {
|
||||||
auto match = std::smatch{};
|
std::smatch match;
|
||||||
if (std::regex_match(line, match, lsofRegex))
|
if (std::regex_match(line, match, lsofRegex))
|
||||||
paths.emplace(match[1]);
|
paths.emplace(match[1]);
|
||||||
}
|
}
|
||||||
} catch (ExecError & e) {
|
} catch (ExecError & e) {
|
||||||
/* lsof not installed, lsof failed */
|
/* lsof not installed, lsof failed */
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__linux__)
|
||||||
readFileRoots("/proc/sys/kernel/modprobe", paths);
|
readFileRoots("/proc/sys/kernel/modprobe", paths);
|
||||||
readFileRoots("/proc/sys/kernel/fbsplash", paths);
|
readFileRoots("/proc/sys/kernel/fbsplash", paths);
|
||||||
readFileRoots("/proc/sys/kernel/poweroff_cmd", paths);
|
readFileRoots("/proc/sys/kernel/poweroff_cmd", paths);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (auto & i : paths)
|
for (auto & i : paths)
|
||||||
if (isInStore(i)) {
|
if (isInStore(i)) {
|
||||||
|
|
|
@ -27,7 +27,8 @@ libstore_CXXFLAGS = \
|
||||||
-DNIX_CONF_DIR=\"$(sysconfdir)/nix\" \
|
-DNIX_CONF_DIR=\"$(sysconfdir)/nix\" \
|
||||||
-DNIX_LIBEXEC_DIR=\"$(libexecdir)\" \
|
-DNIX_LIBEXEC_DIR=\"$(libexecdir)\" \
|
||||||
-DNIX_BIN_DIR=\"$(bindir)\" \
|
-DNIX_BIN_DIR=\"$(bindir)\" \
|
||||||
-DBASH_PATH="\"$(bash)\""
|
-DBASH_PATH="\"$(bash)\"" \
|
||||||
|
-DLSOF=\"$(lsof)\"
|
||||||
|
|
||||||
$(d)/local-store.cc: $(d)/schema.sql.hh
|
$(d)/local-store.cc: $(d)/schema.sql.hh
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue