Skip to content

Commit 67115ea

Browse files
danttiDanielNicolettiKDAB
authored andcommitted
Pass exclude-libraries as env var to linuxdeploy plugins
Excluding libraries doesn't properly work as of now because plugins are not notified of such exclusions, by passing the env var and automatically reading it plugins just need to be recompiled.
1 parent 97f3b52 commit 67115ea

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

include/linuxdeploy/util/misc.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,23 @@ namespace linuxdeploy {
135135
}
136136

137137
return {};
138-
};
138+
}
139+
140+
// sets strings vector with strings from envVar if exists
141+
static bool stringVectorFromEnv(const char *envVar, char delimiter, std::vector<std::string> &strings) {
142+
const auto ret = getenv(envVar);
143+
if (ret) {
144+
strings = split(ret, delimiter);
145+
return true;
146+
}
147+
return false;
148+
}
149+
150+
// set envVar with value from strings
151+
static bool stringVectorToEnv(const char *envVar, char delimiter, const std::vector<std::string> &strings) {
152+
const auto ret = join(strings, std::string{delimiter});
153+
return setenv(envVar, ret.c_str(), 1) == 0;
154+
}
139155
}
140156
}
141157
}

src/core/appdir.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ namespace linuxdeploy {
125125
public:
126126
PrivateData() : copyOperationsStorage(), stripOperations(), setElfRPathOperations(), visitedFiles(), appDirPath(), excludeLibraryPatterns() {
127127
copyrightFilesManager = copyright::ICopyrightFilesManager::getInstance();
128-
};
128+
util::misc::stringVectorFromEnv("LINUXDEPLOY_EXCLUDED_LIBRARIES", ';', excludeLibraryPatterns);
129+
}
129130

130131
public:
131132
// calculate library directory name for given ELF file, taking system architecture into account
@@ -656,7 +657,8 @@ namespace linuxdeploy {
656657
AppDir::AppDir(const std::string& path) : AppDir(fs::path(path)) {}
657658

658659
void AppDir::setExcludeLibraryPatterns(const std::vector<std::string> &excludeLibraryPatterns) {
659-
d->excludeLibraryPatterns = excludeLibraryPatterns;
660+
d->excludeLibraryPatterns.insert(d->excludeLibraryPatterns.end(), excludeLibraryPatterns.begin(), excludeLibraryPatterns.end());
661+
util::misc::stringVectorToEnv("LINUXDEPLOY_EXCLUDED_LIBRARIES", ';', d->excludeLibraryPatterns);
660662
}
661663

662664
bool AppDir::createBasicStructure() const {

0 commit comments

Comments
 (0)