Merge pull request #200 from solemnwarning/exclude-library

Add --exclude-library option.
This commit is contained in:
TheAssassin 2022-05-03 19:09:03 +02:00 committed by GitHub
commit 097212aa1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View File

@ -38,6 +38,9 @@ namespace linuxdeploy {
// shortcut for using a normal string instead of a path
explicit AppDir(const std::string& path);
// Set additional shared library name patterns to be excluded from deployment.
void setExcludeLibraryPatterns(const std::vector<std::string> &excludeLibraryPatterns);
// creates basic directory structure of an AppDir in "FHS" mode
bool createBasicStructure() const;

View File

@ -98,6 +98,7 @@ namespace linuxdeploy {
class AppDir::PrivateData {
public:
bf::path appDirPath;
std::vector<std::string> excludeLibraryPatterns;
// store deferred operations
// these can be executed by calling excuteDeferredOperations
@ -121,7 +122,7 @@ namespace linuxdeploy {
bool disableCopyrightFilesDeployment = false;
public:
PrivateData() : copyOperationsStorage(), stripOperations(), setElfRPathOperations(), visitedFiles(), appDirPath() {
PrivateData() : copyOperationsStorage(), stripOperations(), setElfRPathOperations(), visitedFiles(), appDirPath(), excludeLibraryPatterns() {
copyrightFilesManager = copyright::ICopyrightFilesManager::getInstance();
};
@ -392,8 +393,8 @@ namespace linuxdeploy {
return false;
}
static auto isInExcludelist = [](const bf::path& fileName) {
for (const auto& excludePattern : generatedExcludelist) {
static auto isInExcludelist = [](const bf::path& fileName, const std::vector<std::string> &excludeList) {
for (const auto& excludePattern : excludeList) {
// simple string match is faster than using fnmatch
if (excludePattern == fileName)
return true;
@ -413,7 +414,7 @@ namespace linuxdeploy {
return false;
};
if (!forceDeploy && isInExcludelist(path.filename())) {
if (!forceDeploy && (isInExcludelist(path.filename(), generatedExcludelist) || isInExcludelist(path.filename(), excludeLibraryPatterns))) {
ldLog() << "Skipping deployment of blacklisted library" << path << std::endl;
// mark file as visited
@ -639,6 +640,10 @@ namespace linuxdeploy {
AppDir::AppDir(const std::string& path) : AppDir(bf::path(path)) {}
void AppDir::setExcludeLibraryPatterns(const std::vector<std::string> &excludeLibraryPatterns) {
d->excludeLibraryPatterns = excludeLibraryPatterns;
}
bool AppDir::createBasicStructure() const {
std::vector<std::string> dirPaths = {
"usr/bin/",

View File

@ -33,6 +33,7 @@ int main(int argc, char** argv) {
args::ValueFlag<std::string> appDirPath(parser, "appdir", "Path to target AppDir", {"appdir"});
args::ValueFlagList<std::string> sharedLibraryPaths(parser, "library", "Shared library to deploy", {'l', "library"});
args::ValueFlagList<std::string> excludeLibraryPatterns(parser, "pattern", "Shared library to exclude from deployment (glob pattern)", {"exclude-library"});
args::ValueFlagList<std::string> executablePaths(parser, "executable", "Executable to deploy", {'e', "executable"});
@ -110,6 +111,7 @@ int main(int argc, char** argv) {
}
appdir::AppDir appDir(appDirPath.Get());
appDir.setExcludeLibraryPatterns(excludeLibraryPatterns.Get());
// allow disabling copyright files deployment via environment variable
if (getenv("DISABLE_COPYRIGHT_FILES_DEPLOYMENT") != nullptr) {