Commit 10498477 authored by Łukasz Matysiak's avatar Łukasz Matysiak
Browse files

Merge pull request #12 from filipe-marques/master

changes in Mhwd files
parents 9a822c85 3d5cc3ea
## Manjaro HardWare Detection (mhwd)
#### Copyright (C) 2012 2013 2014 2015 Manjaro Developers
#### Project licensed under GNU GPL v.3 - Check COPYING file
#### The Manjaro HardWare Detection (mhwd) command is a unique feature of [Manjaro Linux](http://manjaro.org/) operating system.
#### There are currently two types of mhwd command:
1. mhwd: Enables the automatic detection and configuration of computer hardware the system is running on. This includes both hardware connected internally via PCI (e.g. graphics cards), and connected externally via [USB](http://en.wikipedia.org/wiki/USB) (e.g. flashdrives).
2. mhwd-kernel: Enables the installation and easy management of multiple kernels on your system.
#### For more info about mhwd go to [mhwd wiki page](https://wiki.manjaro.org/index.php?title=Manjaro_Hardware_Detection_Overview).
#### TODO list
- [ ] allow to set the base lib dir
- [ ] force to remove db config
- [ ] show detailed info for one config
- [ ] set architecture from library not from bash
- [ ] pass ids and bus ids to script
- [ ] don't remove packages on reinstallation...
- [ ] add option similar to pacman --root ...
### Contribute
#### Code Convention
The code convention used in this project is CamelCase. For example:
Instead of:
```c++
void Mhwd::set_version_mhwd(std::string version_of_software, std::string year_copyright)
{
}
```
write:
```c++
void Mhwd::setVersionMhwd(std::string versionOfSoftware, std::string yearCopyright)
{
}
```
#### Indentation of Code
Don't use tabs, instead use spaces and count 4 characters.
#### Software need for coding or testing
* C++ tool chain: [g++](https://gcc.gnu.org/) or [clang](http://clang.llvm.org/), [cmake](http://www.cmake.org/), [make](http://www.gnu.org/software/make/)
* Good Knowledge of [C++11](http://isocpp.org/)
* [git](http://git-scm.com/)
#### Building
In a terminal window do:
```shell
[your-name@your-name mhwd]$ mkdir build
[your-name@your-name mhwd]$ cd build/
[your-name@your-name build]$ cmake ..
[your-name@your-name build]$ make
```
now you have the mhwd program in the folder mhwd/bin/
or
```shell
[your-name@your-name build]$ make install
```
to install the files in linux directories!
#### Have a happy coding ! :thumbsup:
allow to set the base lib dir
force to remove db config
show detailed info for one config
set architecture from library not from bash
pass ids and bus ids to script
don't remove packages on reinstallation...
add option similar to pacman --root ...
......@@ -35,19 +35,19 @@
void ConsoleWriter::printStatus(std::string statusMsg) const
{
std::cout << CONSOLE_RED_MESSAGE_COLOR << "> "
<< CONSOLE_COLOR_RESET << statusMsg << std::endl;
<< CONSOLE_COLOR_RESET << statusMsg << "\n";
}
void ConsoleWriter::printError(std::string errorMsg) const
{
std::cout << CONSOLE_RED_MESSAGE_COLOR << "Error: "
<< CONSOLE_COLOR_RESET << errorMsg << std::endl;
<< CONSOLE_COLOR_RESET << errorMsg << "\n";
}
void ConsoleWriter::printWarning(std::string warningMsg) const
{
std::cout << CONSOLE_RED_MESSAGE_COLOR << "Warning: "
<< CONSOLE_COLOR_RESET << warningMsg << std::endl;
<< CONSOLE_COLOR_RESET << warningMsg << "\n";
}
void ConsoleWriter::printMessage(MHWD::MESSAGETYPE type, std::string msg) const
......@@ -100,16 +100,16 @@ void ConsoleWriter::printHelp() const
<< " -a/--auto <usb/pci> <free/nonfree> <classid>\tauto install configs for classid\n"
<< " --pmcachedir <path>\t\t\tset package manager cache path\n"
<< " --pmconfig <path>\t\t\tset package manager config\n"
<< " --pmroot <path>\t\t\tset package manager root\n" << std::endl;
<< " --pmroot <path>\t\t\tset package manager root\n" << "\n";
}
void ConsoleWriter::printVersion(std::string versionMhwd, std::string yearCopy) const
void ConsoleWriter::printVersion(std::string& versionMhwd, std::string& yearCopy) const
{
std::cout << "Manjaro Hardware Detection v"<< versionMhwd <<"\n\n"
<< "Copyright (C) "<< yearCopy <<" Manjaro Linux Developers\n"
<< "This is free software licensed under GNU GPL v3.0\n"
<< "FITNESS FOR A PARTICULAR PURPOSE.\n"
<< std::endl;
<< "\n";
}
void ConsoleWriter::listDevices(const std::vector<std::shared_ptr<Device>>& devices, std::string type) const
......@@ -127,7 +127,7 @@ void ConsoleWriter::listDevices(const std::vector<std::shared_ptr<Device>>& devi
<< std::setw(8) << "CLASS"
<< std::setw(8) << "VENDOR"
<< std::setw(8) << "DEVICE"
<< std::setw(10) << "CONFIGS" << std::endl;
<< std::setw(10) << "CONFIGS" << "\n";
printLine();
for (const auto& device : devices)
{
......@@ -136,9 +136,9 @@ void ConsoleWriter::listDevices(const std::vector<std::shared_ptr<Device>>& devi
<< std::setw(8) << device->classID_
<< std::setw(8) << device->vendorID_
<< std::setw(8) << device->deviceID_
<< std::setw(10) << device->availableConfigs_.size() << std::endl;
<< std::setw(10) << device->availableConfigs_.size() << "\n";
}
std::cout << std::endl << std::endl;
std::cout << "\n\n";
}
}
......@@ -149,16 +149,16 @@ void ConsoleWriter::listConfigs(const std::vector<std::shared_ptr<Config>>& conf
std::cout << std::setw(22) << "NAME"
<< std::setw(22) << "VERSION"
<< std::setw(20) << "FREEDRIVER"
<< std::setw(15) << "TYPE" << std::endl;
<< std::setw(15) << "TYPE" << "\n";
printLine();
for (const auto& config : configs)
{
std::cout << std::setw(22) << config->name_
<< std::setw(22) << config->version_
<< std::setw(20) << std::boolalpha << config->freedriver_
<< std::setw(15) << config->type_ << std::endl;
<< std::setw(15) << config->type_ << "\n";
}
std::cout << std::endl << std::endl;
std::cout << "\n\n";
}
void ConsoleWriter::printAvailableConfigsInDetail(const std::string& deviceType,
......@@ -182,7 +182,7 @@ void ConsoleWriter::printAvailableConfigsInDetail(const std::string& deviceType,
+ device->vendorID_ + ":" + device->deviceID_ + ")");
std::cout << " " << device->className_
<< " " << device->vendorName_
<< " " << device->deviceName_ << std::endl;
<< " " << device->deviceName_ << "\n";
printLine();
if (!device->installedConfigs_.empty())
{
......@@ -200,7 +200,7 @@ void ConsoleWriter::printAvailableConfigsInDetail(const std::string& deviceType,
{
printConfigDetails(*availableConfig);
}
std::cout << std::endl;
std::cout << "\n";
}
}
}
......@@ -224,7 +224,7 @@ void ConsoleWriter::printInstalledConfigs(const std::string& deviceType,
{
printConfigDetails(*config);
}
std::cout << std::endl;
std::cout << "\n";
}
}
......@@ -264,12 +264,12 @@ void ConsoleWriter::printConfigDetails(const Config& config) const
<< "\n DEPENDS:\t" << (dependencies.empty() ? "-" : dependencies)
<< "\n CONFLICTS:\t" << (conflicts.empty() ? "-" : conflicts)
<< "\n CLASSIDS:\t" << classids
<< "\n VENDORIDS:\t" << vendorids << "\n" << std::endl;
<< "\n VENDORIDS:\t" << vendorids << "\n\n";
}
void ConsoleWriter::printLine() const
{
std::cout << std::string(80, '-') << std::endl;
std::cout << std::string(80, '-') << "\n";
}
void ConsoleWriter::printDeviceDetails(hw_item hw, FILE *f) const
......
......@@ -42,7 +42,7 @@ public:
void printWarning(std::string warningMsg) const;
void printMessage(MHWD::MESSAGETYPE type, std::string str) const;
void printHelp() const;
void printVersion(std::string versionMhwd, std::string yearCopy) const;
void printVersion(std::string& versionMhwd, std::string& yearCopy) const;
void listDevices(const std::vector<std::shared_ptr<Device>>& devices,
std::string typeOfDevice) const;
void listConfigs(const std::vector<std::shared_ptr<Config>>& configs,
......
......@@ -552,7 +552,7 @@ MHWD::STATUS Mhwd::installConfig(std::shared_ptr<Config> config)
MHWD::STATUS Mhwd::uninstallConfig(Config *config)
{
std::shared_ptr<Config> installedConfig{getInstalledConfig(config->name_, config->type_)};
// Check if installed
if (nullptr == installedConfig)
{
......@@ -564,8 +564,6 @@ MHWD::STATUS Mhwd::uninstallConfig(Config *config)
}
else
{
// TODO: Should we check for local requirements here?
// Run script
if (!runScript(installedConfig, MHWD::TRANSACTIONTYPE::REMOVE))
{
......@@ -579,6 +577,8 @@ MHWD::STATUS Mhwd::uninstallConfig(Config *config)
// Installed config vectors have to be updated manual with updateInstalledConfigData(Data*)
data_.updateInstalledConfigData();
return MHWD::STATUS::SUCCESS;
}
}
......
......@@ -83,8 +83,6 @@ private:
std::shared_ptr<Config> getDatabaseConfig(const std::string& configName, const std::string& configType);
std::shared_ptr<Config> getAvailableConfig(const std::string& configName, const std::string& configType);
std::vector<Config*> getAllLocalRequirements(Config *config);
MHWD::STATUS performTransaction(const Transaction& transaction);
bool proceedWithInstallation(const std::string& input) const;
......
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