ref #652 fix case sensitivity of checked libraries

This commit is contained in:
Andrei Yankovich 2021-08-31 11:42:45 +03:00
parent 65a765fed3
commit f7576405e6
10 changed files with 79 additions and 60 deletions

View File

@ -221,7 +221,7 @@ bool iDistribution::collectInfo(const DistroModule& pkg,
bashShortCutsArray += "\"" + targetInfo.getRunScriptFile() + "\""; bashShortCutsArray += "\"" + targetInfo.getRunScriptFile() + "\"";
} }
if (fileinfo.suffix().compare("exe", ONLY_WIN_CASE_INSENSIATIVE) == 0 || fileinfo.suffix().isEmpty()) { if (fileinfo.suffix().compare("exe", Qt::CaseInsensitive) == 0 || fileinfo.suffix().isEmpty()) {
if (cmdArray.size() > initSize) { if (cmdArray.size() > initSize) {
cmdArray += ","; cmdArray += ",";
bashArray += " "; bashArray += " ";

View File

@ -149,7 +149,7 @@ void DependenciesScanner::recursiveDep(LibInfo &lib, QSet<LibInfo> &res, QSet<QS
if (!scanedLib.isValid()) { if (!scanedLib.isValid()) {
QSet<LibInfo> listDep = {}; QSet<LibInfo> listDep = {};
if (!lib._name.compare(dep.value()._name, ONLY_WIN_CASE_INSENSIATIVE)) if (!lib._name.compare(dep.value()._name, DeployCore::getCaseSensitivity(lib._name)))
continue; continue;
recursiveDep(*dep, listDep, libStack); recursiveDep(*dep, listDep, libStack);

View File

@ -14,12 +14,6 @@
#define DISTRO_DIR QString("DistributionKit") #define DISTRO_DIR QString("DistributionKit")
#ifdef Q_OS_WIN
#define ONLY_WIN_CASE_INSENSIATIVE Qt::CaseInsensitive
#else
#define ONLY_WIN_CASE_INSENSIATIVE Qt::CaseSensitive
#endif
#if defined(DEPLOY_LIBRARY) #if defined(DEPLOY_LIBRARY)
# define DEPLOYSHARED_EXPORT Q_DECL_EXPORT # define DEPLOYSHARED_EXPORT Q_DECL_EXPORT
#else #else

View File

@ -105,12 +105,12 @@ DeployCore::QtModule DeployCore::getQtModule(const QString& path) {
void DeployCore::addQtModule(DeployCore::QtModule &module, const QString &path) { void DeployCore::addQtModule(DeployCore::QtModule &module, const QString &path) {
QuasarAppUtils::Params::log("Current module " + QString::number(module), QuasarAppUtils::Params::log("Current module " + QString::number(module),
QuasarAppUtils::Debug); QuasarAppUtils::Debug);
auto mod = getQtModule(path); auto mod = getQtModule(path);
QuasarAppUtils::Params::log("Add new module from path " + path + QuasarAppUtils::Params::log("Add new module from path " + path +
" module value " + QString::number(mod), " module value " + QString::number(mod),
QuasarAppUtils::Debug); QuasarAppUtils::Debug);
module = static_cast<DeployCore::QtModule>( module = static_cast<DeployCore::QtModule>(
@ -251,15 +251,15 @@ QuasarAppUtils::OptionsDataList DeployCore::avilableOptions() {
}}); }});
help.insert(group, {QuasarAppUtils::OptionData{ help.insert(group, {QuasarAppUtils::OptionData{
{"deb", "-deb"}, "", {"deb", "-deb"}, "",
"Create the deb package for deployment programm" "Create the deb package for deployment programm"
" You can specify the path to your own debian template.", " You can specify the path to your own debian template.",
"cqtdeployer -deb path/to/myCustom/DEBIAN." "cqtdeployer -deb path/to/myCustom/DEBIAN."
}}); }});
help.insert(group, {QuasarAppUtils::OptionData{ help.insert(group, {QuasarAppUtils::OptionData{
{"deploySystem"}, "", {"deploySystem"}, "",
"Deploys all libraries." "Deploys all libraries."
" Not recomendet because there may be conflicts with system libraries" " Not recomendet because there may be conflicts with system libraries"
" (on snap version you need to turn on permission)" " (on snap version you need to turn on permission)"
}}); }});
help.insert(group, {QuasarAppUtils::OptionData{ help.insert(group, {QuasarAppUtils::OptionData{
{"noQt"}, "", {"noQt"}, "",
@ -271,10 +271,10 @@ QuasarAppUtils::OptionsDataList DeployCore::avilableOptions() {
}}); }});
help.insert(group, {QuasarAppUtils::OptionData{ help.insert(group, {QuasarAppUtils::OptionData{
{"getDefaultTemplate"}, "", {"getDefaultTemplate"}, "",
"Extracts defaults deb or qif templates." "Extracts defaults deb or qif templates."
" All templates extract into targetDirectory." " All templates extract into targetDirectory."
" For change target directory use the targetDir option.", " For change target directory use the targetDir option.",
"cqtdeployer -bin myExecutable getDefaultTemplate qif deb." "cqtdeployer -bin myExecutable getDefaultTemplate qif deb."
}}); }});
help.insert(group, {QuasarAppUtils::OptionData{ help.insert(group, {QuasarAppUtils::OptionData{
{"noHashSum"}, "", {"noHashSum"}, "",
@ -302,10 +302,10 @@ QuasarAppUtils::OptionsDataList DeployCore::avilableOptions() {
help.insert(group, {QuasarAppUtils::OptionData{ help.insert(group, {QuasarAppUtils::OptionData{
{"-confFile"}, "{params}", {"-confFile"}, "{params}",
"The path to the json file with all deployment configurations. Using this file," "The path to the json file with all deployment configurations. Using this file,"
" you can add the necessary options, thereby simplifying the command invocation in the console." " you can add the necessary options, thereby simplifying the command invocation in the console."
" However, the parameters in Kansol have a higher priority than in the file." " However, the parameters in Kansol have a higher priority than in the file."
" For more info about this flag see https://github.com/QuasarApp/CQtDeployer/wiki/DeployConfigFileEn" " For more info about this flag see https://github.com/QuasarApp/CQtDeployer/wiki/DeployConfigFileEn"
}}); }});
help.insert(group, {QuasarAppUtils::OptionData{ help.insert(group, {QuasarAppUtils::OptionData{
{"-qmlDir"}, "{params}", {"-qmlDir"}, "{params}",
@ -336,8 +336,8 @@ QuasarAppUtils::OptionsDataList DeployCore::avilableOptions() {
{"-extraLibs"}, "{list,params}", {"-extraLibs"}, "{list,params}",
"Sets the mask of the library name for forced copying.", "Sets the mask of the library name for forced copying.",
"\"-extraLib mySql\" - forces to copy all libraries whose names contain mySql to the project folder." "\"-extraLib mySql\" - forces to copy all libraries whose names contain mySql to the project folder."
" This option is case-insensitive on Windows and case-sensitive on other platforms." " This option is case-insensitive on Windows and case-sensitive on other platforms."
" This option will only search libraries in system environments similar to **deploySystem**." " This option will only search libraries in system environments similar to **deploySystem**."
}}); }});
help.insert(group, {QuasarAppUtils::OptionData{ help.insert(group, {QuasarAppUtils::OptionData{
{"-customScript"}, "{scriptCode}", {"-customScript"}, "{scriptCode}",
@ -364,9 +364,9 @@ QuasarAppUtils::OptionsDataList DeployCore::avilableOptions() {
}}); }});
help.insert(group, {QuasarAppUtils::OptionData{ help.insert(group, {QuasarAppUtils::OptionData{
{"-runScript"}, "{list,parems}", {"-runScript"}, "{list,parems}",
"forces cqtdeployer swap default run script to new from the arguments of option." "forces cqtdeployer swap default run script to new from the arguments of option."
" This option copy all content from input file and insert all code into runScript.sh or .bat", " This option copy all content from input file and insert all code into runScript.sh or .bat",
"cqtdeployer -runScript \"myTargetMame;path/to/my/myCustomLaunchScript.sh,myTargetSecondMame;path/to/my/mySecondCustomLaunchScript.sh\"" "cqtdeployer -runScript \"myTargetMame;path/to/my/myCustomLaunchScript.sh,myTargetSecondMame;path/to/my/mySecondCustomLaunchScript.sh\""
}}); }});
group = "Part 3 Control of packages options"; group = "Part 3 Control of packages options";
@ -374,7 +374,7 @@ QuasarAppUtils::OptionsDataList DeployCore::avilableOptions() {
help.insert(group, {QuasarAppUtils::OptionData{ help.insert(group, {QuasarAppUtils::OptionData{
{"-targetPackage"}, "{package;tar1,package;tar2}", {"-targetPackage"}, "{package;tar1,package;tar2}",
"Creates a new package and adds 'tar1 and tar2' to it. " "Creates a new package and adds 'tar1 and tar2' to it. "
"If you want configure the package that do not have any targets use the allowEmptyPackages option." "If you want configure the package that do not have any targets use the allowEmptyPackages option."
}}); }});
help.insert(group, {QuasarAppUtils::OptionData{ help.insert(group, {QuasarAppUtils::OptionData{
{"-qmlOut"}, "{package;path,path}", {"-qmlOut"}, "{package;path,path}",
@ -408,7 +408,7 @@ QuasarAppUtils::OptionsDataList DeployCore::avilableOptions() {
help.insert(group, {QuasarAppUtils::OptionData{ help.insert(group, {QuasarAppUtils::OptionData{
{"-name"}, "{package;val,val}", {"-name"}, "{package;val,val}",
"Sets name for a package." "Sets name for a package."
"If this if you do not specify a package, the value will be assigned to the default package ("")" "If this if you do not specify a package, the value will be assigned to the default package ("")"
}}); }});
help.insert(group, {QuasarAppUtils::OptionData{ help.insert(group, {QuasarAppUtils::OptionData{
{"-description"}, "{package;val,val}", {"-description"}, "{package;val,val}",
@ -466,16 +466,16 @@ QuasarAppUtils::OptionsDataList DeployCore::avilableOptions() {
}}); }});
help.insert(group, {QuasarAppUtils::OptionData{ help.insert(group, {QuasarAppUtils::OptionData{
{"-enablePlugins"}, "{package;val1;val2,SingeleVa}", {"-enablePlugins"}, "{package;val1;val2,SingeleVa}",
"Enables additional plugins for distribution." "Enables additional plugins for distribution."
" By default disabled next plugins: " + PluginsParser::defaultForbidenPlugins().join(',') + " if you want enable" " By default disabled next plugins: " + PluginsParser::defaultForbidenPlugins().join(',') + " if you want enable"
" it then use '-enablePlugins " + PluginsParser::defaultForbidenPlugins().join(',') + "' option" " it then use '-enablePlugins " + PluginsParser::defaultForbidenPlugins().join(',') + "' option"
}}); }});
help.insert(group, {QuasarAppUtils::OptionData{ help.insert(group, {QuasarAppUtils::OptionData{
{"-disablePlugins"}, "{package;val1;val2,SingeleVal}", {"-disablePlugins"}, "{package;val1;val2,SingeleVal}",
"Disables plugins for distribution. " "Disables plugins for distribution. "
"You can disable any plugin of your Qt build, just see the yourQtFolder/plugins forlder for available plugins." "You can disable any plugin of your Qt build, just see the yourQtFolder/plugins forlder for available plugins."
" Example if you want disable qxcb plugin: -disablePlugins qxcb." " Example if you want disable qxcb plugin: -disablePlugins qxcb."
" Note that the name of the plugin is indicated without its extension" " Note that the name of the plugin is indicated without its extension"
}}); }});
group = "Part 6 QtInstallFramework options"; group = "Part 6 QtInstallFramework options";
@ -589,7 +589,7 @@ QString DeployCore::findProcess(const QString &env, const QString& proc) {
auto files = QDir(path).entryInfoList(QDir::NoDotAndDotDot | QDir::Files); auto files = QDir(path).entryInfoList(QDir::NoDotAndDotDot | QDir::Files);
for (const auto& bin : files) { for (const auto& bin : files) {
if (bin.baseName().compare(proc, ONLY_WIN_CASE_INSENSIATIVE) == 0) { if (bin.baseName().compare(proc, DeployCore::getCaseSensitivity()) == 0) {
return bin.absoluteFilePath(); return bin.absoluteFilePath();
} }
} }
@ -605,7 +605,7 @@ QStringList DeployCore::debugExtensions() {
bool DeployCore::isDebugFile(const QString &file) { bool DeployCore::isDebugFile(const QString &file) {
auto debug = debugExtensions(); auto debug = debugExtensions();
for (const auto& debugEx: debug) { for (const auto& debugEx: debug) {
if (file.contains(debugEx, ONLY_WIN_CASE_INSENSIATIVE)) { if (file.contains(debugEx, Qt::CaseInsensitive)) {
return true; return true;
} }
} }
@ -752,11 +752,11 @@ QtMajorVersion DeployCore::isQtLibName(const QString &lib) {
} }
QString fileName = info.fileName(); QString fileName = info.fileName();
if (fileName.contains("Qt4", ONLY_WIN_CASE_INSENSIATIVE)) { if (fileName.contains("Qt4", getCaseSensitivity(fileName))) {
isQt = QtMajorVersion::Qt4; isQt = QtMajorVersion::Qt4;
} else if (fileName.contains("Qt5", ONLY_WIN_CASE_INSENSIATIVE)) { } else if (fileName.contains("Qt5", getCaseSensitivity(fileName))) {
isQt = QtMajorVersion::Qt5; isQt = QtMajorVersion::Qt5;
} else if (fileName.contains("Qt6", ONLY_WIN_CASE_INSENSIATIVE)) { } else if (fileName.contains("Qt6", getCaseSensitivity(fileName))) {
isQt = QtMajorVersion::Qt6; isQt = QtMajorVersion::Qt6;
} }
@ -774,8 +774,8 @@ bool DeployCore::isExtraLib(const QString &lib) {
} }
bool DeployCore::isAlienLib(const QString &lib) { bool DeployCore::isAlienLib(const QString &lib) {
return lib.contains("/opt/", ONLY_WIN_CASE_INSENSIATIVE) || return lib.contains("/opt/", Qt::CaseSensitive) ||
lib.contains("/PROGRAM FILES", ONLY_WIN_CASE_INSENSIATIVE); lib.contains("/PROGRAM FILES", Qt::CaseInsensitive);
} }
bool DeployCore::isAllowedLib(const QString &lib) { bool DeployCore::isAllowedLib(const QString &lib) {
@ -920,6 +920,25 @@ QFileInfo DeployCore::findItem(const QString &bin) {
} }
return QFileInfo(bin); return QFileInfo(bin);
}
Qt::CaseSensitivity DeployCore::getCaseSensitivity(const QString &checkedFile) {
if (checkedFile.isEmpty()) {
#ifdef Q_OS_WIN
return Qt::CaseInsensitive;
#else
return Qt::CaseSensitive;
#endif
}
QString sufix = QFileInfo(checkedFile).completeSuffix();
if (sufix.compare("dll", Qt::CaseInsensitive) == 0 ||
sufix.compare("exe", Qt::CaseInsensitive)) {
return Qt::CaseInsensitive;
}
return Qt::CaseSensitive;
}; };
QString DeployCore::systemLibsFolderName() { QString DeployCore::systemLibsFolderName() {

View File

@ -303,6 +303,12 @@ public:
*/ */
static QFileInfo findItem(const QString &file); static QFileInfo findItem(const QString &file);
/**
* @brief getCaseSensitivity This method return case sensitivity for a @a checkedFile. Usualy return Qt::CaseSensiativy exept windows binaryes files like a dll and exe.
* @param checkedFile This is checked file. By default empty value.
* @return Qt CaseSensitivity value
*/
static Qt::CaseSensitivity getCaseSensitivity(const QString& checkedFile = "");
}; };
#define internalError() DeployCore::printInternalError(__FUNCTION__, __FILE__, __LINE__) #define internalError() DeployCore::printInternalError(__FUNCTION__, __FILE__, __LINE__)

View File

@ -390,7 +390,7 @@ void Extracter::extractLib(const QString &file,
for (const auto &line : data.getAllDep()) { for (const auto &line : data.getAllDep()) {
if (mask.size() && !line.getName().contains(mask, ONLY_WIN_CASE_INSENSIATIVE)) { if (mask.size() && !line.getName().contains(mask, DeployCore::getCaseSensitivity())) {
continue; continue;
} }

View File

@ -178,7 +178,7 @@ bool FileManager::fileActionPrivate(const QString &file, const QString &target,
bool copy = !masks; bool copy = !masks;
if (masks) { if (masks) {
for (const auto &mask : qAsConst(*masks)) { for (const auto &mask : qAsConst(*masks)) {
if (info.absoluteFilePath().contains(mask, ONLY_WIN_CASE_INSENSIATIVE)) { if (info.absoluteFilePath().contains(mask, DeployCore::getCaseSensitivity())) {
copy = true; copy = true;
break; break;
} }
@ -263,7 +263,7 @@ bool FileManager::smartCopyFile(const QString &file,
bool ifFileTarget) { bool ifFileTarget) {
auto config = DeployCore::_config; auto config = DeployCore::_config;
if (file.contains(config->getTargetDir(), ONLY_WIN_CASE_INSENSIATIVE)) { if (file.contains(config->getTargetDir(), DeployCore::getCaseSensitivity())) {
if (!moveFile(file, target, mask)) { if (!moveFile(file, target, mask)) {
QuasarAppUtils::Params::log("Failed to move the file. Trying to copy it"); QuasarAppUtils::Params::log("Failed to move the file. Trying to copy it");
@ -309,7 +309,7 @@ bool FileManager::copyFolder(const QString &from,
if (!force) { if (!force) {
QString skipFilter = ""; QString skipFilter = "";
for (const auto &i: filter) { for (const auto &i: filter) {
if (item.fileName().contains(i, ONLY_WIN_CASE_INSENSIATIVE)) { if (item.fileName().contains(i, DeployCore::getCaseSensitivity())) {
skipFilter = i; skipFilter = i;
break; break;
} }
@ -496,7 +496,7 @@ bool FileManager::copyFiles(const QStringList &source,
QString skipFilter = ""; QString skipFilter = "";
for (const auto &i: filter) { for (const auto &i: filter) {
if (info.fileName().contains(i, ONLY_WIN_CASE_INSENSIATIVE)) { if (info.fileName().contains(i, DeployCore::getCaseSensitivity())) {
skipFilter = i; skipFilter = i;
break; break;
} }

View File

@ -27,7 +27,7 @@ void IgnoreRule::addRule(const IgnoreData &rule) {
} }
bool IgnoreRule::check(const LibInfo &info, const QString& ignoreLabel) const { bool IgnoreRule::check(const LibInfo &info, const QString& ignoreLabel) const {
if (info.fullPath().contains(ignoreLabel, ONLY_WIN_CASE_INSENSIATIVE)) { if (info.fullPath().contains(ignoreLabel, DeployCore::getCaseSensitivity())) {
QuasarAppUtils::Params::log(info.fullPath() + " ignored by filter" + ignoreLabel); QuasarAppUtils::Params::log(info.fullPath() + " ignored by filter" + ignoreLabel);
return true; return true;
} }

View File

@ -86,11 +86,11 @@ bool QtDir::isQt(QString path) const {
path = PathUtils::fixPath(path); path = PathUtils::fixPath(path);
return return
(!libs.isEmpty() && path.contains(libs, ONLY_WIN_CASE_INSENSIATIVE)) || (!libs.isEmpty() && path.contains(libs, DeployCore::getCaseSensitivity())) ||
(!bins.isEmpty() && path.contains(bins, ONLY_WIN_CASE_INSENSIATIVE)) || (!bins.isEmpty() && path.contains(bins, DeployCore::getCaseSensitivity())) ||
(!libexecs.isEmpty() && path.contains(libexecs, ONLY_WIN_CASE_INSENSIATIVE)) || (!libexecs.isEmpty() && path.contains(libexecs, DeployCore::getCaseSensitivity())) ||
(!plugins.isEmpty() && path.contains(plugins, ONLY_WIN_CASE_INSENSIATIVE)) || (!plugins.isEmpty() && path.contains(plugins, DeployCore::getCaseSensitivity())) ||
(!qmls.isEmpty() && path.contains(qmls, ONLY_WIN_CASE_INSENSIATIVE)) || (!qmls.isEmpty() && path.contains(qmls, DeployCore::getCaseSensitivity())) ||
(!translations.isEmpty() && path.contains(translations, ONLY_WIN_CASE_INSENSIATIVE)) || (!translations.isEmpty() && path.contains(translations, DeployCore::getCaseSensitivity())) ||
(!resources.isEmpty() && path.contains(resources, ONLY_WIN_CASE_INSENSIATIVE)); (!resources.isEmpty() && path.contains(resources, DeployCore::getCaseSensitivity()));
} }

View File

@ -20,7 +20,7 @@ ModulesQt513::~ModulesQt513() {
QSet<QString> ModulesQt513::ignoreFilter(const QSet<QString> &input, const QString &filter) const { QSet<QString> ModulesQt513::ignoreFilter(const QSet<QString> &input, const QString &filter) const {
QSet<QString> res; QSet<QString> res;
for (auto& val : input) { for (auto& val : input) {
if (!val.contains(filter, ONLY_WIN_CASE_INSENSIATIVE)) { if (!val.contains(filter, DeployCore::getCaseSensitivity())) {
res.insert(val); res.insert(val);
} }
} }