Skip to content

Commit

Permalink
Fix several bugs related to repo management
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernd Wachter committed Mar 29, 2013
1 parent 4b10f8c commit 306d4e8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
25 changes: 13 additions & 12 deletions libssu/ssudeviceinfo.cpp
Expand Up @@ -23,9 +23,7 @@ SsuDeviceInfo::SsuDeviceInfo(): QObject(){
QStringList SsuDeviceInfo::adaptationRepos(){
QStringList result;

QString model = deviceVariant();
if (model == "")
model = deviceModel();
QString model = deviceVariant(true);

if (boardMappings->contains(model + "/adaptation-repos"))
result = boardMappings->value(model + "/adaptation-repos").toStringList();
Expand All @@ -37,9 +35,7 @@ QString SsuDeviceInfo::deviceFamily(){
if (!cachedFamily.isEmpty())
return cachedFamily;

QString model = deviceVariant();
if (model == "")
model = deviceModel();
QString model = deviceVariant(true);

cachedFamily = "UNKNOWN";

Expand All @@ -49,7 +45,7 @@ QString SsuDeviceInfo::deviceFamily(){
return cachedFamily;
}

QString SsuDeviceInfo::deviceVariant(){
QString SsuDeviceInfo::deviceVariant(bool fallback){
if (!cachedVariant.isEmpty())
return cachedVariant;

Expand All @@ -59,6 +55,9 @@ QString SsuDeviceInfo::deviceVariant(){
cachedVariant = boardMappings->value("variants/" + deviceModel()).toString();
}

if (cachedVariant == "" && fallback)
return deviceModel();

return cachedVariant;
}

Expand Down Expand Up @@ -156,9 +155,7 @@ QString SsuDeviceInfo::deviceUid(){
QStringList SsuDeviceInfo::disabledRepos(){
QStringList result;

QString model = deviceVariant();
if (model == "")
model = deviceModel();
QString model = deviceVariant(true);

if (boardMappings->contains(model + "/disabled-repos"))
result = boardMappings->value(model + "/disabled-repos").toStringList();
Expand All @@ -182,6 +179,10 @@ QStringList SsuDeviceInfo::repos(bool rnd){

// TODO: add specific repos (developer, sdk, ..)

// add device configured repos
if (boardMappings->contains(deviceVariant(true) + "/repos"))
result.append(boardMappings->value(deviceVariant(true) + "/repos").toStringList());

// read user-defined repositories from ssu.ini
// TODO: in strict mode, filter the repository list from there
QSettings ssuSettings(SSU_CONFIGURATION, QSettings::IniFormat);
Expand All @@ -196,8 +197,8 @@ QStringList SsuDeviceInfo::repos(bool rnd){
result.removeAll(key);

// read the disabled repositories from user configuration
if (ssuSettings.contains("disabledRepos")){
foreach (const QString &key, ssuSettings.value("disabledRepos").toStringList())
if (ssuSettings.contains("disabled-repos")){
foreach (const QString &key, ssuSettings.value("disabled-repos").toStringList())
result.removeAll(key);
}

Expand Down
4 changes: 3 additions & 1 deletion libssu/ssudeviceinfo.h
Expand Up @@ -28,8 +28,10 @@ class SsuDeviceInfo: public QObject {
Q_INVOKABLE QString deviceFamily();
/**
* Try to find the device variant for the system this is running on.
* If the device is not a variant it will return an empty string. If
* fallback is set to true it return the device model in this case.
*/
Q_INVOKABLE QString deviceVariant();
Q_INVOKABLE QString deviceVariant(bool fallback=false);
/**
* Try to find out ond what kind of system this is running
*/
Expand Down
7 changes: 4 additions & 3 deletions libssu/ssurepomanager.cpp
Expand Up @@ -36,7 +36,7 @@ void SsuRepoManager::update(){
// if device is misconfigured, always assume release mode
bool rndMode = false;

if ((deviceMode & Ssu::RepoManager) != Ssu::RepoManager){
if ((deviceMode & Ssu::DisableRepoManager) == Ssu::DisableRepoManager){
ssuLog->print(LOG_INFO, "Repo management requested, but not enabled (option 'deviceMode')");
return;
}
Expand All @@ -57,7 +57,7 @@ void SsuRepoManager::update(){
}

// get list of device-specific repositories...
QStringList repos = deviceInfo.repos();
QStringList repos = deviceInfo.repos(rndMode);

// ... delete all ssu-managed repositories not valid for this device ...
ssuFilters.append("ssu_*");
Expand All @@ -68,7 +68,8 @@ void SsuRepoManager::update(){
QStringList parts = it.fileName().split("_");
// repo file structure is ssu_<reponame>_<rnd|release>.repo -> splits to 3 parts
if (parts.count() == 3){
if (!repos.contains(parts.at(1)))
if (!repos.contains(parts.at(1)) ||
parts.at(2) != (rndMode ? "rnd.repo" : "release.repo" ))
QFile(it.filePath()).remove();
} else
QFile(it.filePath()).remove();
Expand Down

0 comments on commit 306d4e8

Please sign in to comment.