Skip to content

Commit

Permalink
[ssuks] Make default operation 'write kickstart for current machine'
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernd Wachter committed Jun 13, 2013
1 parent 7b3694a commit 9fcbd9d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 39 deletions.
3 changes: 2 additions & 1 deletion ssuks/ssukickstarter.cpp
Expand Up @@ -298,7 +298,8 @@ 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())
qerr << "Writing kickstart to " << ks.fileName() << endl;

QString displayName = QString("# DisplayName: %1 %2/%3 (%4) %5")
.arg(repoOverride.value("brand"))
Expand Down
79 changes: 41 additions & 38 deletions ssuks/ssuks.cpp
Expand Up @@ -28,54 +28,57 @@ void SsuKs::run(){
QTextStream qerr(stderr);
QHash<QString, QString> repoParameters;

if (arguments.count() == 1 && arguments.at(0) == "help"){
usage();
return;
}

QString fileName;
if (arguments.count() >= 1 && !arguments.at(0).contains("=")){
fileName = arguments.at(0);
arguments.removeFirst();
}

if (arguments.count() >= 1){
for (int i=0; i<arguments.count(); i++){
if (arguments.at(i).count("=") != 1){
qout << "Invalid flag: " << arguments.at(i) << endl;
QCoreApplication::exit(1);
return;
}
QStringList split = arguments.at(i).split("=");
repoParameters.insert(split.at(0), split.at(1));
for (int i=0; i<arguments.count(); i++){
if (arguments.at(i).count("=") != 1){
qout << "Invalid flag: " << arguments.at(i) << endl;
QCoreApplication::exit(1);
return;
}
QStringList split = arguments.at(i).split("=");
repoParameters.insert(split.at(0), split.at(1));
}

QString sandbox;
Sandbox *sb;
if (repoParameters.contains("sandbox")){
sandbox = repoParameters.value("sandbox");
repoParameters.remove("sandbox");

sb = new Sandbox(sandbox, Sandbox::UseDirectly, Sandbox::ThisProcess);

if (!sb->addWorldFiles(SSU_DATA_DIR)){
qerr << "Failed to copy files into sandbox, using empty sandbox" << endl;
}

QString sandbox;
Sandbox *sb;
if (repoParameters.contains("sandbox")){
sandbox = repoParameters.value("sandbox");
repoParameters.remove("sandbox");

sb = new Sandbox(sandbox, Sandbox::UseDirectly, Sandbox::ThisProcess);

if (!sb->addWorldFiles(SSU_DATA_DIR)){
qerr << "Failed to copy files into sandbox, using empty sandbox" << endl;
}

if (sb->activate())
qerr << "Using sandbox at " << sandbox << endl;
else {
qerr << "Failed to activate sandbox" << endl;
QCoreApplication::exit(1);
return;
}

// force re-merge of settings
QFile::remove(Sandbox::map(SSU_BOARD_MAPPING_CONFIGURATION));
SsuSettings(SSU_BOARD_MAPPING_CONFIGURATION, SSU_BOARD_MAPPING_CONFIGURATION_DIR);
if (sb->activate())
qerr << "Using sandbox at " << sandbox << endl;
else {
qerr << "Failed to activate sandbox" << endl;
QCoreApplication::exit(1);
return;
}

SsuKickstarter kickstarter;
kickstarter.setRepoParameters(repoParameters);
QCoreApplication::exit(!kickstarter.write(fileName));
return;
} else
usage();
// force re-merge of settings
QFile::remove(Sandbox::map(SSU_BOARD_MAPPING_CONFIGURATION));
SsuSettings(SSU_BOARD_MAPPING_CONFIGURATION, SSU_BOARD_MAPPING_CONFIGURATION_DIR);
}

SsuKickstarter kickstarter;
kickstarter.setRepoParameters(repoParameters);
QCoreApplication::exit(!kickstarter.write(fileName));
return;


QCoreApplication::exit(0);
}
Expand Down

0 comments on commit 9fcbd9d

Please sign in to comment.