Skip to content

Commit 097212a

Browse files
authored
Merge pull request #200 from solemnwarning/exclude-library
Add --exclude-library option.
2 parents ed42a40 + 37b640f commit 097212a

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

include/linuxdeploy/core/appdir.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ namespace linuxdeploy {
3838
// shortcut for using a normal string instead of a path
3939
explicit AppDir(const std::string& path);
4040

41+
// Set additional shared library name patterns to be excluded from deployment.
42+
void setExcludeLibraryPatterns(const std::vector<std::string> &excludeLibraryPatterns);
43+
4144
// creates basic directory structure of an AppDir in "FHS" mode
4245
bool createBasicStructure() const;
4346

src/core/appdir.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ namespace linuxdeploy {
9898
class AppDir::PrivateData {
9999
public:
100100
bf::path appDirPath;
101+
std::vector<std::string> excludeLibraryPatterns;
101102

102103
// store deferred operations
103104
// these can be executed by calling excuteDeferredOperations
@@ -121,7 +122,7 @@ namespace linuxdeploy {
121122
bool disableCopyrightFilesDeployment = false;
122123

123124
public:
124-
PrivateData() : copyOperationsStorage(), stripOperations(), setElfRPathOperations(), visitedFiles(), appDirPath() {
125+
PrivateData() : copyOperationsStorage(), stripOperations(), setElfRPathOperations(), visitedFiles(), appDirPath(), excludeLibraryPatterns() {
125126
copyrightFilesManager = copyright::ICopyrightFilesManager::getInstance();
126127
};
127128

@@ -392,8 +393,8 @@ namespace linuxdeploy {
392393
return false;
393394
}
394395

395-
static auto isInExcludelist = [](const bf::path& fileName) {
396-
for (const auto& excludePattern : generatedExcludelist) {
396+
static auto isInExcludelist = [](const bf::path& fileName, const std::vector<std::string> &excludeList) {
397+
for (const auto& excludePattern : excludeList) {
397398
// simple string match is faster than using fnmatch
398399
if (excludePattern == fileName)
399400
return true;
@@ -413,7 +414,7 @@ namespace linuxdeploy {
413414
return false;
414415
};
415416

416-
if (!forceDeploy && isInExcludelist(path.filename())) {
417+
if (!forceDeploy && (isInExcludelist(path.filename(), generatedExcludelist) || isInExcludelist(path.filename(), excludeLibraryPatterns))) {
417418
ldLog() << "Skipping deployment of blacklisted library" << path << std::endl;
418419

419420
// mark file as visited
@@ -639,6 +640,10 @@ namespace linuxdeploy {
639640

640641
AppDir::AppDir(const std::string& path) : AppDir(bf::path(path)) {}
641642

643+
void AppDir::setExcludeLibraryPatterns(const std::vector<std::string> &excludeLibraryPatterns) {
644+
d->excludeLibraryPatterns = excludeLibraryPatterns;
645+
}
646+
642647
bool AppDir::createBasicStructure() const {
643648
std::vector<std::string> dirPaths = {
644649
"usr/bin/",

src/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ int main(int argc, char** argv) {
3333
args::ValueFlag<std::string> appDirPath(parser, "appdir", "Path to target AppDir", {"appdir"});
3434

3535
args::ValueFlagList<std::string> sharedLibraryPaths(parser, "library", "Shared library to deploy", {'l', "library"});
36+
args::ValueFlagList<std::string> excludeLibraryPatterns(parser, "pattern", "Shared library to exclude from deployment (glob pattern)", {"exclude-library"});
3637

3738
args::ValueFlagList<std::string> executablePaths(parser, "executable", "Executable to deploy", {'e', "executable"});
3839

@@ -110,6 +111,7 @@ int main(int argc, char** argv) {
110111
}
111112

112113
appdir::AppDir appDir(appDirPath.Get());
114+
appDir.setExcludeLibraryPatterns(excludeLibraryPatterns.Get());
113115

114116
// allow disabling copyright files deployment via environment variable
115117
if (getenv("DISABLE_COPYRIGHT_FILES_DEPLOYMENT") != nullptr) {

0 commit comments

Comments
 (0)