Commit f098f8ee authored by LordTermor's avatar LordTermor

Merge branch 'patch-wildcards' into 'master'

Various changes

See merge request !49
parents 26f159cf 203a062f
......@@ -305,6 +305,11 @@ if [ "${INSTALL}" == "true" ]; then
echo "Error: pacman failed!"
exit 1
fi
${PACMAN} -D --asexplicit ${PACKAGES}
if [ "$?" -ne "0" ]; then
echo "Error: pacman failed!"
exit 1
fi
fi
# Run postinstall function
......@@ -372,14 +377,13 @@ if [ "${REMOVE}" == "true" ]; then
fi
fi
for PKG in "${OPTREMPACKAGES}"
do
# Check if package is needed anywhere, otherwise remove packages
# Usage of -Rsu is not enough, since pacman doesn't consider optional dependencies
if [ "$(pacman -Qi ${PKG} | egrep "Required By|Optional For" | awk '{ print $4}' | grep -v 'None')" == "" ]; then
PACKAGES="${PACKAGES} ${PKG}"
if [ "${OPTREMPACKAGES}" != "" ]; then
${PACMAN} -D --asdeps ${OPTREMPACKAGES}
if [ "$?" -ne "0" ]; then
echo "Error: pacman failed!"
exit 1
fi
done
fi
# Check if packages are installed
MHWD_CHECK_PKGS
......
......@@ -25,6 +25,7 @@
#include "Data.hpp"
#include <dirent.h>
#include <fnmatch.h>
#include <algorithm>
#include <fstream>
......@@ -129,42 +130,42 @@ void Data::getAllDevicesOfConfig(const std::vector<std::shared_ptr<Device>>& dev
{
// Check class ids
bool found = std::find_if(hwdID->classIDs.begin(), hwdID->classIDs.end(), [i_device](const std::string& classID){
return (("*" == classID) || (classID == (*i_device)->classID_));
return !fnmatch(classID.c_str(), (*i_device)->classID_.c_str(), FNM_CASEFOLD);
}) != hwdID->classIDs.end();
if (found)
{
// Check blacklisted class ids
found = std::find_if(hwdID->blacklistedClassIDs.begin(), hwdID->blacklistedClassIDs.end(), [i_device](const std::string& blacklistedClassID){
return (blacklistedClassID == (*i_device)->classID_);
return !fnmatch(blacklistedClassID.c_str(), (*i_device)->classID_.c_str(), FNM_CASEFOLD);
}) != hwdID->blacklistedClassIDs.end();
if (!found)
{
// Check vendor ids
found = std::find_if(hwdID->vendorIDs.begin(), hwdID->vendorIDs.end(), [i_device](const std::string& vendorID){
return (("*" == vendorID) || (vendorID == (*i_device)->vendorID_));
return !fnmatch(vendorID.c_str(), (*i_device)->vendorID_.c_str(), FNM_CASEFOLD);
}) != hwdID->vendorIDs.end();
if (found)
{
// Check blacklisted vendor ids
found = std::find_if(hwdID->blacklistedVendorIDs.begin(), hwdID->blacklistedVendorIDs.end(), [i_device](const std::string& blacklistedVendorID){
return (blacklistedVendorID == (*i_device)->vendorID_);
return !fnmatch(blacklistedVendorID.c_str(), (*i_device)->vendorID_.c_str(), FNM_CASEFOLD);
}) != hwdID->blacklistedVendorIDs.end();
if (!found)
{
// Check device ids
found = std::find_if(hwdID->deviceIDs.begin(), hwdID->deviceIDs.end(), [i_device](const std::string& deviceID){
return (("*" == deviceID) || (deviceID == (*i_device)->deviceID_));
return !fnmatch(deviceID.c_str(), (*i_device)->deviceID_.c_str(), FNM_CASEFOLD);
}) != hwdID->deviceIDs.end();
if (found)
{
// Check blacklisted device ids
found = std::find_if(hwdID->blacklistedDeviceIDs.begin(), hwdID->blacklistedDeviceIDs.end(), [i_device](const std::string& blacklistedDeviceID){
return (blacklistedDeviceID == (*i_device)->deviceID_);
return !fnmatch(blacklistedDeviceID.c_str(), (*i_device)->deviceID_.c_str(), FNM_CASEFOLD);
}) != hwdID->blacklistedDeviceIDs.end();
if (!found)
{
......@@ -281,22 +282,31 @@ std::vector<std::shared_ptr<Config>> Data::getAllLocalConflicts(std::shared_ptr<
installedConfigs = installedPCIConfigs;
}
// Add self to local dependencies vector
dependencies.emplace_back(config);
// Loop thru all MHWD config dependencies (not pacman dependencies)
for (const auto& dependency : dependencies)
{
// Loop thru all MHWD config conflicts
for (const auto& dependencyConflict : dependency->conflicts_)
{
// Then loop thru all already installed configs. If there are no configs installed, there can not be a conflict
for (auto& installedConfig : installedConfigs)
{
if (dependencyConflict == installedConfig->name_)
// Skip yourself
if (installedConfig->name_ == config->name_)
continue;
// Does one of the installed configs conflict one of the to-be-installed configs?
if (!fnmatch(dependencyConflict.c_str(),installedConfig->name_.c_str(), FNM_CASEFOLD))
{
// Check if conflicts is already in the conflicts vector
bool found = std::find_if(conflicts.begin(), conflicts.end(),
[&dependencyConflict](const std::shared_ptr<Config>& conflict)
{
return conflict->name_ == dependencyConflict;
}) != conflicts.end();
// If not, add it to the conflicts vector. This will now be shown to the user.
if (!found)
{
conflicts.emplace_back(installedConfig);
......
......@@ -62,12 +62,8 @@ bool Mhwd::performTransaction(std::shared_ptr<Config> config, MHWD::TRANSACTIONT
// Print dependencies
else if (!transaction.dependencyConfigs_.empty())
{
consoleWriter_.printStatus("Dependencies to install:" +
gatherConfigContent(transaction.dependencyConfigs_) +
"\nProceed with installation? [Y/n]");
std::string input;
std::getline(std::cin, input);
return proceedWithInstallation(input);
consoleWriter_.printStatus("Dependencies to install: " +
gatherConfigContent(transaction.dependencyConfigs_));
}
}
else if (MHWD::TRANSACTIONTYPE::REMOVE == transactionType)
......
......@@ -58,4 +58,4 @@ hash_t hash(char const* str)
}; // End namespace
#endif /* CONFIG_HPP_ */
#endif /* MHWDUTILS_HPP_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment