Commit 0d8b99f6 authored by Pekka Vuorela's avatar Pekka Vuorela

Cosmetic style changes

parent 16541f89
......@@ -32,16 +32,19 @@ public:
* multithreaded environment, unless you like funny results.
*/
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(bool fallback = false);
/**
* Try to find out ond what kind of system this is running
*/
Q_INVOKABLE QString deviceModel();
/**
* Return a string suitable for display in dialogs, ...
*
......
......@@ -276,7 +276,7 @@ bool Sandbox::prepare()
QString Sandbox::createTmpDir(const QString &nameTemplate)
{
static const int REASONABLE_REPEAT_COUNT = 10;
const int REASONABLE_REPEAT_COUNT = 10;
for (int i = 0; i < REASONABLE_REPEAT_COUNT; ++i) {
QString path;
......
......@@ -37,7 +37,8 @@ static void restoreUid()
}
}
Ssu::Ssu(): QObject()
Ssu::Ssu()
: QObject()
{
errorFlag = false;
pendingRequests = 0;
......@@ -223,8 +224,9 @@ bool Ssu::registerDevice(QDomDocument *response)
settings->setValue("registered", false);
setError("Certificate is invalid");
return false;
} else
} else {
settings->setValue("certificate", certificate.toPem());
}
QString privateKeyString = response->elementsByTagName("privateKey").at(0).toElement().text();
QSslKey privateKey(privateKeyString.toLatin1(), QSsl::Rsa);
......@@ -233,8 +235,9 @@ bool Ssu::registerDevice(QDomDocument *response)
settings->setValue("registered", false);
setError("Private key is invalid");
return false;
} else
} else {
settings->setValue("privateKey", privateKey.toPem());
}
// oldUser is just for reference purposes, in case we want to notify
// about owner changes for the device
......@@ -357,7 +360,7 @@ void Ssu::sendRegistration(QString usernameDomain, QString password)
{
errorFlag = false;
QString ssuCaCertificate, ssuRegisterUrl;
QString ssuRegisterUrl;
QString username, domainName;
SsuLog *ssuLog = SsuLog::instance();
......@@ -381,7 +384,7 @@ void Ssu::sendRegistration(QString usernameDomain, QString password)
setDomain(settings->value("default-rnd-domain").toString());
}
ssuCaCertificate = SsuRepoManager::caCertificatePath();
QString ssuCaCertificate = SsuRepoManager::caCertificatePath();
if (ssuCaCertificate.isEmpty()) {
setError("CA certificate for ssu not set ('_ca-certificate in domain')");
return;
......@@ -393,8 +396,9 @@ void Ssu::sendRegistration(QString usernameDomain, QString password)
setError("URL for ssu registration not set (config key 'register-url')");
return;
}
} else
} else {
ssuRegisterUrl = settings->value("register-url").toString();
}
QString IMEI = deviceInfo.deviceUid();
if (IMEI == "") {
......@@ -535,8 +539,9 @@ void Ssu::storeAuthorizedKeys(QByteArray data)
ssuLog->print(LOG_DEBUG, QString("Dropping to %1/%2 for writing authorized keys")
.arg(uid_min)
.arg(pw->pw_gid));
} else
} else {
return;
}
homePath = Sandbox::map(homePath);
......@@ -547,13 +552,14 @@ void Ssu::storeAuthorizedKeys(QByteArray data)
return;
}
if (!dir.exists(homePath + "/.ssh"))
if (!dir.exists(homePath + "/.ssh")) {
if (!dir.mkdir(homePath + "/.ssh")) {
ssuLog->print(LOG_DEBUG, QString("Unable to create .ssh in %1")
.arg(homePath));
restoreUid();
return;
}
}
QFile::setPermissions(homePath + "/.ssh",
QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner);
......@@ -595,8 +601,9 @@ void Ssu::updateCredentials(bool force)
setError("URL for credentials update not set (config key 'credentials-url')");
return;
}
} else
} else {
ssuCredentialsUrl = settings->value("credentials-url").toString();
}
if (!isRegistered()) {
setError("Device is not registered.");
......@@ -659,8 +666,9 @@ void Ssu::updateStoreCredentials()
if (settings->value("ignore-credential-errors").toBool() == true) {
ssuLog->print(LOG_WARNING, QString("Warning: ignore-credential-errors is set, passing auth errors down to libzypp"));
ssuLog->print(LOG_WARNING, QString("Store credentials not received. %1").arg(reply.error().message()));
} else
} else {
setError(QString("Store credentials not received. %1").arg(reply.error().message()));
}
} else {
SsuCoreConfig *settings = SsuCoreConfig::instance();
settings->beginGroup("credentials-store");
......
......@@ -111,8 +111,9 @@ void SsuCoreConfig::setDeviceMode(Ssu::DeviceModeFlags mode, enum Ssu::EditMode
oldMode |= mode;
} else if ((editMode & Ssu::Remove) == Ssu::Remove) {
oldMode &= ~mode;
} else
} else {
oldMode = mode;
}
setValue("deviceMode", oldMode);
sync();
......
......@@ -23,7 +23,8 @@
#include "../constants.h"
SsuDeviceInfo::SsuDeviceInfo(QString model): QObject()
SsuDeviceInfo::SsuDeviceInfo(const QString &model)
: QObject()
{
boardMappings = new SsuSettings(SSU_BOARD_MAPPING_CONFIGURATION, SSU_BOARD_MAPPING_CONFIGURATION_DIR);
if (!model.isEmpty())
......@@ -160,19 +161,16 @@ QString SsuDeviceInfo::deviceVariant(bool fallback)
QString SsuDeviceInfo::deviceModel()
{
QDir dir;
QFile procCpuinfo;
QStringList keys;
if (!cachedModel.isEmpty())
return cachedModel;
boardMappings->beginGroup("file.exists");
keys = boardMappings->allKeys();
QStringList keys = boardMappings->allKeys();
// check if the device can be identified by testing for a file
foreach (const QString &key, keys) {
QString value = boardMappings->value(key).toString();
QDir dir;
if (dir.exists(Sandbox::map(value))) {
cachedModel = key;
break;
......@@ -182,6 +180,7 @@ QString SsuDeviceInfo::deviceModel()
if (!cachedModel.isEmpty()) return cachedModel;
// check if the device can be identified by a string in /proc/cpuinfo
QFile procCpuinfo;
procCpuinfo.setFileName(Sandbox::map("/proc/cpuinfo"));
procCpuinfo.open(QIODevice::ReadOnly | QIODevice::Text);
if (procCpuinfo.isOpen()) {
......@@ -347,7 +346,6 @@ QString SsuDeviceInfo::displayName(const int type)
QString variant = deviceVariant(false);
QString value, key;
switch (type) {
case Ssu::DeviceManufacturer:
key = "/deviceManufacturer";
......
......@@ -30,43 +30,51 @@ public:
* Return the list of adaptations used for the set model
*/
QStringList adaptationRepos();
/**
* Resolve adaptation-specific variables for adaptationName, and store them in storageHash
* Returns "adaptation" if a valid adaptation was found, adaptationName otherwise
*/
QString adaptationVariables(const QString &adaptationName, QHash<QString, QString> *storageHash);
/**
* Check if a given model is available in the deviceinfo database, either directly,
* or as variant. If no model is provided as argument the autodetected or previously
* set model is used.
*/
bool contains(const QString &model = "");
/**
* Try to find the device family for the system this is running on. This function
* temporarily changes the detected model, and therefore should not be used in a
* multithreaded environment, unless you like funny results.
*/
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(bool fallback = false);
/**
* Try to find out ond what kind of system this is running
*/
Q_INVOKABLE QString deviceModel();
/**
* Calculate the device ID used in ssu requests
* @return The first imei from oFono ModemManager API, if available, or WLAN mac address, or device uid fallback code similar to QDeviceInfo::uniqueDeviceID()
*/
Q_INVOKABLE QString deviceUid();
/**
* Return the list of repositories explicitely disabled for this device
* This does not include repositories only disabled in the user configuration.
*/
QStringList disabledRepos();
/**
* Return a string suitable for display in dialogs, ...
*
......@@ -85,10 +93,12 @@ public:
* Disabled repositories are excluded depending on filter settings.
*/
QStringList repos(bool rnd = false, int filter = Ssu::NoFilter);
/**
* Override device model autodetection
*/
Q_INVOKABLE void setDeviceModel(QString model = "");
/**
* Return a variable from the given variable section. 'var'- is automatically
* prepended to the section name if not specified already. Recursive search
......@@ -96,11 +106,13 @@ public:
* returned will be the first occurence of the variable.
*/
QVariant variable(QString section, const QString &key);
/**
* Return the requested variable section. 'var-' is automatically
* prepended to the section name if not specified already.
*/
void variableSection(QString section, QHash<QString, QString> *storageHash);
/**
* Return a value from an adaptation section. Returns an empty string
* or a given default value if key does not exist.
......@@ -111,7 +123,6 @@ public:
*/
QVariant value(const QString &key, const QVariant &value = QVariant());
private:
SsuSettings *boardMappings;
QString cachedFamily, cachedModel, cachedVariant;
......
......@@ -18,7 +18,8 @@
#include "../constants.h"
SsuFeatureManager::SsuFeatureManager(): QObject()
SsuFeatureManager::SsuFeatureManager()
: QObject()
{
featureSettings = new SsuSettings(SSU_FEATURE_CONFIGURATION, SSU_FEATURE_CONFIGURATION_DIR);
}
......
......@@ -26,9 +26,6 @@ SsuLog *SsuLog::instance()
void SsuLog::print(int priority, QString message)
{
QByteArray ba = message.toUtf8();
const char *ca = ba.constData();
// directly go through qsettings here to avoid recursive invocation
// of coreconfig / ssulog
if (ssuLogLevel == -1) {
......@@ -45,6 +42,9 @@ void SsuLog::print(int priority, QString message)
if (priority > ssuLogLevel)
return;
QByteArray ba = message.toUtf8();
const char *ca = ba.constData();
if (sd_journal_print(priority, "ssu: %s", ca) < 0 && fallbackLogPath != "") {
QFile logfile;
QTextStream logstream;
......
......@@ -21,9 +21,9 @@
#include "../constants.h"
SsuRepoManager::SsuRepoManager(): QObject()
SsuRepoManager::SsuRepoManager()
: QObject()
{
}
int SsuRepoManager::add(QString repo, QString repoUrl)
......@@ -47,8 +47,9 @@ int SsuRepoManager::add(QString repo, QString repoUrl)
enabledRepos.append(repo);
enabledRepos.removeDuplicates();
ssuSettings->setValue("enabled-repos", enabledRepos);
} else
} else {
ssuSettings->setValue("repository-urls/" + repo, repoUrl);
}
ssuSettings->sync();
return 0;
......@@ -190,8 +191,7 @@ QStringList SsuRepoManager::repos(bool rnd, SsuDeviceInfo &deviceInfo, int filte
appInstallMode = true;
}
if (filter == Ssu::NoFilter ||
filter == Ssu::UserFilter) {
if (filter == Ssu::NoFilter || filter == Ssu::UserFilter) {
// user defined repositories, or ones overriding URLs for default ones
// -> in update mode we need to check for each of those if it already
// exists. If it exists, keep it, if it does not, disable it
......@@ -242,23 +242,19 @@ void SsuRepoManager::update()
// - delete all non-ssu managed repositories (missing ssu_ prefix)
// - create list of ssu-repositories for current adaptation
// - go through ssu_* repositories, delete all which are not in the list; write others
SsuDeviceInfo deviceInfo;
QStringList ssuFilters;
SsuCoreConfig *ssuSettings = SsuCoreConfig::instance();
int deviceMode = ssuSettings->deviceMode();
SsuLog *ssuLog = SsuLog::instance();
// if device is misconfigured, always assume release mode
bool rndMode = false;
if ((deviceMode & Ssu::DisableRepoManager) == Ssu::DisableRepoManager) {
ssuLog->print(LOG_INFO, "Repo management requested, but not enabled (option 'deviceMode')");
return;
}
// if device is misconfigured, always assume release mode
bool rndMode = false;
if ((deviceMode & Ssu::RndMode) == Ssu::RndMode)
rndMode = true;
......@@ -280,10 +276,11 @@ void SsuRepoManager::update()
}
// ... delete all ssu-managed repositories not valid for this device ...
QStringList ssuFilters;
ssuFilters.append("ssu_*");
QDirIterator it(Sandbox::map(ZYPP_REPO_PATH), ssuFilters);
while (it.hasNext()) {
QString f = it.next();
it.next();
QStringList parts = it.fileName().split("_");
// repo file structure is ssu_<reponame>_<rnd|release>.repo -> splits to 3 parts
......@@ -291,8 +288,9 @@ void SsuRepoManager::update()
if (!repositoryList.contains(parts.at(1)) ||
parts.at(2) != (rndMode ? "rnd.repo" : "release.repo" ))
QFile(it.filePath()).remove();
} else
} else {
QFile(it.filePath()).remove();
}
}
// ... and create all repositories required for this device
......@@ -395,11 +393,6 @@ QString SsuRepoManager::url(QString repoName, bool rndRepo,
QHash<QString, QString> repoParameters,
QHash<QString, QString> parametersOverride)
{
QString r;
QStringList configSections;
SsuVariables var;
SsuCoreConfig *settings = SsuCoreConfig::instance();
SsuSettings repoSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat);
SsuDeviceInfo deviceInfo;
// set debugSplit for incorrectly configured debuginfo repositories (debugSplit
......@@ -408,8 +401,7 @@ QString SsuRepoManager::url(QString repoName, bool rndRepo,
if (repoName.endsWith("-debuginfo") && !repoParameters.contains("debugSplit"))
repoParameters.insert("debugSplit", "debug");
configSections = repoVariables(&repoParameters, rndRepo);
QStringList configSections = repoVariables(&repoParameters, rndRepo);
// Override device model (and therefore all the family, ... stuff)
if (parametersOverride.contains("model"))
......@@ -421,16 +413,20 @@ QString SsuRepoManager::url(QString repoName, bool rndRepo,
repoName = deviceInfo.adaptationVariables(repoName, &repoParameters);
SsuCoreConfig *settings = SsuCoreConfig::instance();
QString domain;
if (parametersOverride.contains("domain")) {
domain = parametersOverride.value("domain");
domain.replace("-", ":");
} else
} else {
domain = settings->domain();
}
// variableSection does autodetection for the domain default section
var.variableSection(&repoSettings,
domain + "-domain", &repoParameters);
SsuSettings repoSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat);
SsuVariables var;
var.variableSection(&repoSettings, domain + "-domain", &repoParameters);
// override arbitrary variables, mostly useful for generating mic URLs
QHash<QString, QString>::const_iterator i = parametersOverride.constBegin();
......@@ -445,6 +441,7 @@ QString SsuRepoManager::url(QString repoName, bool rndRepo,
// 3. URLs from repos.ini
SsuFeatureManager featureManager;
QString r;
if (settings->contains("repository-urls/" + repoName))
r = settings->value("repository-urls/" + repoName).toString();
......
......@@ -14,26 +14,25 @@
#include "ssusettings_p.h"
#include "ssulog_p.h"
SsuSettings::SsuSettings(): QSettings()
SsuSettings::SsuSettings()
: QSettings()
{
}
SsuSettings::SsuSettings(const QString &fileName, Format format, QObject *parent):
QSettings(Sandbox::map(fileName), format, parent)
SsuSettings::SsuSettings(const QString &fileName, Format format, QObject *parent)
: QSettings(Sandbox::map(fileName), format, parent)
{
}
SsuSettings::SsuSettings(const QString &fileName, Format format, const QString &defaultFileName, QObject *parent):
QSettings(Sandbox::map(fileName), format, parent)
SsuSettings::SsuSettings(const QString &fileName, Format format, const QString &defaultFileName, QObject *parent)
: QSettings(Sandbox::map(fileName), format, parent)
{
defaultSettingsFile = Sandbox::map(defaultFileName);
upgrade();
}
SsuSettings::SsuSettings(const QString &fileName, const QString &settingsDirectory, QObject *parent):
QSettings(Sandbox::map(fileName), QSettings::IniFormat, parent)
SsuSettings::SsuSettings(const QString &fileName, const QString &settingsDirectory, QObject *parent)
: QSettings(Sandbox::map(fileName), QSettings::IniFormat, parent)
{
settingsd = Sandbox::map(settingsDirectory);
merge();
......@@ -112,14 +111,14 @@ void SsuSettings::merge(QSettings *masterSettings, const QStringList &settingsFi
*/
void SsuSettings::upgrade()
{
if (defaultSettingsFile.isEmpty())
return;
int configVersion = 0;
int defaultConfigVersion = 0;
SsuLog *ssuLog = SsuLog::instance();
if (defaultSettingsFile == "")
return;
QSettings defaultSettings(defaultSettingsFile, QSettings::IniFormat);
if (contains("configVersion"))
......@@ -133,13 +132,13 @@ void SsuSettings::upgrade()
.arg(defaultConfigVersion));
for (int i = configVersion + 1; i <= defaultConfigVersion; i++) {
QStringList defaultKeys;
QString currentSection = QString("%1/").arg(i);
ssuLog->print(LOG_DEBUG, QString("Processing configuration version %1").arg(i));
defaultSettings.beginGroup(currentSection);
defaultKeys = defaultSettings.allKeys();
QStringList defaultKeys = defaultSettings.allKeys();
defaultSettings.endGroup();
foreach (const QString &key, defaultKeys) {
// Default keys support both commands and new keys
if (key.compare("cmd-remove", Qt::CaseSensitive) == 0) {
......
......@@ -14,9 +14,9 @@
#include "../constants.h"
SsuVariables::SsuVariables(): QObject()
SsuVariables::SsuVariables()
: QObject()
{
}
QString SsuVariables::defaultSection(SsuSettings *settings, QString section)
......@@ -153,9 +153,7 @@ QVariant SsuVariables::variable(QString section, const QString &key)
QVariant SsuVariables::variable(SsuSettings *settings, QString section, const QString &key)
{
QVariant value;
value = readVariable(settings, section, key, 0);
QVariant value = readVariable(settings, section, key, 0);
// first check if the value is defined in the main section, and fall back
// to default sections
......@@ -178,9 +176,9 @@ void SsuVariables::variableSection(SsuSettings *settings, QString section, QHash
{
QString dSection = defaultSection(settings, section);
if (dSection.isEmpty())
if (dSection.isEmpty()) {
readSection(settings, section, storageHash, 0);
else {
} else {
readSection(settings, dSection, storageHash, 0);
readSection(settings, section, storageHash, 0, false);
}
......
......@@ -19,7 +19,8 @@
#include "ssucli.h"
SsuCli::SsuCli(): QObject()
SsuCli::SsuCli()
: QObject()
{
connect(this, SIGNAL(done()),
QCoreApplication::instance(), SLOT(quit()), Qt::DirectConnection);
......@@ -171,7 +172,6 @@ void SsuCli::optMode(QStringList opt)
void SsuCli::optModel(QStringList opt)
{
QTextStream qout(stdout);
QTextStream qerr(stderr);
SsuDeviceInfo deviceInfo;
if (opt.count() == 3 && opt.at(2) == "-s") {
......@@ -413,8 +413,9 @@ void SsuCli::optRepos(QStringList opt)
if (repo.endsWith("-debuginfo")) {
repoName = repo.left(repo.size() - 10);
repoParameters.insert("debugSplit", "debug");
} else if (repoParameters.value("debugSplit") == "debug")
} else if (repoParameters.value("debugSplit") == "debug") {
repoParameters.remove("debugSplit");
}
QString repoUrl = ssu.repoUrl(repoName, rndRepo, repoParameters, repoOverride);
qout << "repo --name=" << repo << "-"
......@@ -426,9 +427,9 @@ void SsuCli::optRepos(QStringList opt)
return;
}
if (device.isEmpty())
if (device.isEmpty()) {
repos = repoManager.repos(rndRepo, deviceInfo, Ssu::BoardFilterUserBlacklist);
else {
} else {
qout << "Printing repository configuration for '" << device << "'" << endl << endl;
repos = repoManager.repos(rndRepo, deviceInfo, Ssu::BoardFilter);
}
......@@ -601,7 +602,6 @@ void SsuCli::optUpdateRepos(QStringList opt)
void SsuCli::run()
{
QTextStream qout(stdout);
QTextStream qerr(stderr);
QStringList arguments = QCoreApplication::arguments();
......
......@@ -47,10 +47,10 @@ private:
void optUpdateRepos(QStringList opt);
enum Actions {
Remove = 0,
Add = 1,
Disable = 2,
Enable = 3,
Remove,
Add,
Disable,
Enable
};
void optModifyRepo(enum Actions action, QStringList opt);
......
......@@ -14,11 +14,12 @@
#include "../constants.h"
int main(int argc, char **argv){
struct stat sb;
int main(int argc, char **argv)
{
struct stat sb;
if (!stat(SSU_CONFIGURATION, &sb)){
chown(SSU_CONFIGURATION, 0, SSU_GROUP_ID);
chmod(SSU_CONFIGURATION, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
}
if (!stat(SSU_CONFIGURATION, &sb)){
chown(SSU_CONFIGURATION, 0, SSU_GROUP_ID);
chmod(SSU_CONFIGURATION, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
}
}
......@@ -16,7 +16,8 @@
const char *Ssud::SERVICE_NAME = "org.nemo.ssu";
const char *Ssud::OBJECT_PATH = "/org/nemo/ssu";
Ssud::Ssud(QObject *parent): QObject(parent)
Ssud::Ssud(QObject *parent)
: QObject(parent)
{
QDBusConnection connection = QDBusConnection::systemBus();
if (!connection.registerObject(OBJECT_PATH, this)) {
......
......@@ -64,13 +64,13 @@ QStringList SsuKickstarter::commandSection(const QString &section, const QString
.arg(SSU_DATA_DIR)
.arg(section)));
if (dir.exists(replaceSpaces(deviceModel.toLower())))
if (dir.exists(replaceSpaces(deviceModel.toLower()))) {
commandFile = replaceSpaces(deviceModel.toLower());
else if (dir.exists(replaceSpaces(deviceInfo.deviceVariant(true).toLower())))
} else if (dir.exists(replaceSpaces(deviceInfo.deviceVariant(true).toLower()))) {
commandFile = replaceSpaces(deviceInfo.deviceVariant(true).toLower());
else if (dir.exists("default"))
} else if (dir.exists("default")) {
commandFile = "default";
else {
} else {
if (description.isEmpty())
result.append("## No suitable configuration found in " + dir.path());
else
......@@ -129,7 +129,7 @@ QStringList SsuKickstarter::repos()
: ""))
.arg(repoUrl)
);
} else
} else {
result.append(QString("repo --name=%1-%2%3 --baseurl=%4")
.arg(repo)
.arg((rndMode ? repoOverride.value("rndRelease")
......@@ -138,6 +138,7 @@ QStringList SsuKickstarter::repos()
: ""))
.arg(repoUrl)
);
}
}
return result;
......@@ -228,12 +229,7 @@ void SsuKickstarter::setRepoParameters(QHash<QString, QString> parameters)
bool SsuKickstarter::write(QString kickstart)
{
QFile ks;
QTextStream kout;
QTextStream qerr(stderr);
SsuDeviceInfo deviceInfo(deviceModel);
SsuRepoManager repoManager;
SsuVariables var;
QStringList commandSections;
// initialize with default 'part' for compatibility, as partitions
......@@ -252,9 +248,11 @@ bool SsuKickstarter::write(QString kickstart)
QHash<QString, QString> defaults;
// get generic repo variables; domain and adaptation specific bits are not interesting
// in the kickstart
SsuRepoManager repoManager;
repoManager.repoVariables(&defaults, rndMode);
// overwrite with kickstart defaults
SsuDeviceInfo deviceInfo(deviceModel);
deviceInfo.variableSection("kickstart-defaults", &defaults);
if (deviceInfo.variable("kickstart-defaults", "commandSections")
.canConvert(QMetaType::QStringList)) {
......@@ -308,7 +306,11 @@ bool SsuKickstarter::write(QString kickstart)
QString outputDir = repoOverride.value("outputdir");
if (!outputDir.isEmpty()) outputDir.append("/");
QFile ks;
if (kickstart.isEmpty()) {
SsuVariables var;
if (repoOverride.contains("filename")) {
QString fileName = QString("%1%2")
.arg(outputDir)
......@@ -321,9 +323,9 @@ bool SsuKickstarter::write(QString kickstart)
qerr << "No filename specified, and no default filename configured" << endl;
return false;
}
} else if (kickstart == "-")
} else if (kickstart == "-") {
opened = ks.open(stdout, QIODevice::WriteOnly);
else {
} else {
ks.setFileName(outputDir + kickstart);
opened = ks.open(QIODevice::WriteOnly);
}
......@@ -331,8 +333,9 @@ bool SsuKickstarter::write(QString kickstart)
if (!opened) {
qerr << "Unable to write output file " << ks.fileName() << ": " << ks.errorString() << endl;
return false;
} else if (!ks.fileName().isEmpty())
} else if (!ks.fileName().isEmpty()) {
qerr << "Writing kickstart to " << ks.fileName() << endl;
}
QString displayName = QString("# DisplayName: %1 %2/%3 (%4) %5")
.arg(repoOverride.value("brand"))
......@@ -365,6 +368,7 @@ bool SsuKickstarter::write(QString kickstart)
QString kickstartType = QString("# KickstartType: %1")
.arg((rndMode ? "rnd" : "release"));
QTextStream kout;
kout.setDevice(&ks);
kout << displayName << endl;
kout << kickstartType << endl;
......
......@@ -16,7 +16,8 @@
#include "libssu/sandbox_p.h"
#include "libssu/ssulog_p.h"