Fix up sysadm to work with the corrupted/modified version of the pkg config files that sysup now auto-generates.

This commit is contained in:
Ken Moore
2018-12-11 09:32:29 -05:00
parent f467df4133
commit b7fa03d2b8

View File

@@ -379,13 +379,19 @@ QJsonArray PKG::list_repos(bool updated){
QDir confdir(repodirs[d]);
QStringList confs = confdir.entryList(QStringList() << "*.conf", QDir::Files);
for(int i=0; i<confs.length(); i++){
QStringList repoinfo = General::readTextFile(confdir.absoluteFilePath(confs[i])).join("\n").split("\n}");
QStringList contents = General::readTextFile(confdir.absoluteFilePath(confs[i]));
//Scan for any comments on the top of the file and remove them
for(int l=0; l<contents.length(); l++){
if(contents[l].isEmpty() || contents[l].startsWith("#")){ contents.removeAt(l); l--; }
else{ break; }
}
QStringList repoinfo = contents.join("\n").split("\n}");
for(int j=0; j<repoinfo.length(); j++){
//qDebug() << "Repoinfo:" << repoinfo[j];
qDebug() << "Repoinfo:" << repoinfo[j];
QString repo = repoinfo[j].section(":",0,0).simplified();
QString enabled = repoinfo[j].section("enabled:",1,-1).section(":",0,0).toLower();
bool isEnabled = (enabled.contains("yes") || enabled.contains("true"));
//qDebug() << "Checking Repo:" << repo << enabled << isEnabled;
qDebug() << "Checking Repo:" << repo << enabled << isEnabled;
if(QFile::exists(dbdir.arg(repo)) && isEnabled){ found << repo; }
} //loop over repos listed in conf
} //loop over confs in repodir