-
Notifications
You must be signed in to change notification settings - Fork 0
/
PortageParser.cpp
34 lines (30 loc) · 1019 Bytes
/
PortageParser.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "PortageParser.hpp"
#include <QDebug>
#include <QProcess>
#include <QStringList>
#include <QTextStream>
PortageParser::PortageParser()
{
}
PortageParser::EnvironmentalVariables PortageParser::getEnvironmentalVariables() const
{
QProcess process;
process.start("emerge --info", QProcess::ReadOnly);
process.waitForFinished();
QTextStream info(process.readAllStandardOutput());
process.close();
EnvironmentalVariables envars;
while(!info.atEnd())
{
QString str = info.readLine();
envars.insert(str.section('=', 0, 0, QString::SectionSkipEmpty), str.section('"', 1, 1, QString::SectionSkipEmpty));
}
return envars;
}
PortageParser::Repositories PortageParser::getRepositories() const
{
EnvironmentalVariables envars = getEnvironmentalVariables();
Repositories repositories = Repositories::fromList(envars.value("PORTDIR_OVERLAY").split(' ', QString::SkipEmptyParts));
repositories.insert(envars.value("PORTDIR"));
return repositories;
}