[Libreoffice-commits] online.git: kit/Kit.cpp
Michael Meeks
michael.meeks at collabora.com
Mon Jan 29 15:12:51 UTC 2018
kit/Kit.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 50 insertions(+), 14 deletions(-)
New commits:
commit fbc28b91b38de357b43fbf549ba2bf99832d05f2
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Mon Jan 22 16:39:50 2018 +0000
Avoid copying code into the chroot if LINK_NO_CODE is set.
Change-Id: Ibba7dfa87c779b4d809cc2ac53d0802bba1c37ef
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index c853b3ed..b644a029 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -146,6 +146,39 @@ namespace
}
}
+ bool shouldLinkFile(const char *path)
+ {
+ static bool avoidCode = getenv("LINK_NO_CODE");
+
+ if (!avoidCode)
+ return true;
+
+ switch (linkOrCopyType)
+ {
+ case LinkOrCopyType::LO:
+ {
+ const char *dot = strrchr(path, '.');
+ if (!dot)
+ return true;
+ if (!strcmp(dot, ".dbg") ||
+ !strcmp(dot, ".so"))
+ return false;
+ const char *vers;
+ if ((vers = strstr(path, ".so."))) // .so.[digit]+
+ {
+ for(int i = sizeof (".so."); vers[i] != '\0'; ++i)
+ if (!isdigit(vers[i]) && vers[i] != '.')
+ return true;
+ return false;
+ }
+ return true;
+ }
+ case LinkOrCopyType::NoUsr:
+ default: // LinkOrCopyType::All
+ return true;
+ }
+ }
+
int linkOrCopyFunction(const char *fpath,
const struct stat* /*sb*/,
int typeflag,
@@ -176,21 +209,24 @@ namespace
case FTW_SLN:
File(newPath.parent()).createDirectories();
- if (linkOrCopyVerboseLogging)
- LOG_INF("Linking file \"" << fpath << "\" to \"" << newPath.toString() << "\"");
- if (link(fpath, newPath.toString().c_str()) == -1)
+ if (shouldLinkFile(relativeOldPath))
{
- LOG_SYS("link(\"" << fpath << "\", \"" <<
- newPath.toString() << "\") failed. Will copy.");
- try
- {
- File(fpath).copyTo(newPath.toString());
- }
- catch (const std::exception& exc)
+ if (linkOrCopyVerboseLogging)
+ LOG_INF("Linking file \"" << fpath << "\" to \"" << newPath.toString() << "\"");
+ if (link(fpath, newPath.toString().c_str()) == -1)
{
- LOG_ERR("Copying of '" << fpath << "' to " << newPath.toString() <<
- " failed: " << exc.what() << ". Exiting.");
- std::_Exit(Application::EXIT_SOFTWARE);
+ LOG_SYS("link(\"" << fpath << "\", \"" <<
+ newPath.toString() << "\") failed. Will copy.");
+ try
+ {
+ File(fpath).copyTo(newPath.toString());
+ }
+ catch (const std::exception& exc)
+ {
+ LOG_ERR("Copying of '" << fpath << "' to " << newPath.toString() <<
+ " failed: " << exc.what() << ". Exiting.");
+ std::_Exit(Application::EXIT_SOFTWARE);
+ }
}
}
break;
@@ -2039,7 +2075,7 @@ void lokit_main(const std::string& childRoot,
const auto etcPathString = etcPath.toString();
if (File(filename).exists() && !File(etcPathString).exists() )
{
- linkOrCopy( filename, etcPath, LinkOrCopyType::LO );
+ linkOrCopy( filename, etcPath, LinkOrCopyType::All );
}
}
More information about the Libreoffice-commits
mailing list