If there are no .conf files for the pkg repos yet, have it run "pkg update" to generate them and re-try the repo list function.

This commit is contained in:
Ken Moore
2016-08-02 12:23:35 -04:00
parent a652d1bf0a
commit 31ea5f3497
2 changed files with 6 additions and 2 deletions

View File

@@ -327,10 +327,14 @@ QJsonArray PKG::list_categories(QString repo){
else{ return QJsonArray(); }
}
QJsonArray PKG::list_repos(){
QJsonArray PKG::list_repos(bool updated){
QString dbdir = "/var/db/pkg/repo-%1.sqlite";
QDir confdir("/usr/local/etc/pkg/repos");
QStringList confs = confdir.entryList(QStringList() << "*.conf", QDir::Files);
if(confs.isEmpty() && !updated){
QProcess::execute("pkg update"); //need to update pkg configs
return list_repos(true); //try again recursively (will not try to update again)
}
QStringList found;
found << "local"; //There is always a local database (for installed pkgs)
for(int i=0; i<confs.length(); i++){

View File

@@ -23,7 +23,7 @@ public:
static QJsonObject pkg_info(QStringList origins, QString repo, QString category = "", bool fullresults = true);
static QStringList pkg_search(QString repo, QString searchterm, QStringList searchexcludes, QString category = "");
static QJsonArray list_categories(QString repo);
static QJsonArray list_repos();
static QJsonArray list_repos(bool updated = false);
//pkg modification routines (dispatcher events for notifications)
static QJsonObject pkg_install(QStringList origins, QString repo);