Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/linuxdeploy/core/appdir.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
13 changes: 9 additions & 4 deletions src/core/appdir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
};

Expand Down Expand Up @@ -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) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just capture this, then you can access member variables.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its passing in the exclude list because isInExcludelist is used to check both lists (command line and built-in), or is there a different variable that could be captured I'm not seeing?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I thought it might be easier to move the logic entirely into the lambda. But this seems okay, too.

for (const auto& excludePattern : excludeList) {
// simple string match is faster than using fnmatch
if (excludePattern == fileName)
return true;
Expand All @@ -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
Expand Down Expand Up @@ -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/",
Expand Down
2 changes: 2 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"});

Expand Down Expand Up @@ -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) {
Expand Down