Commit c30bd373 authored by Aard's avatar Aard

Work around sandbox not sandboxing directories

parent 6a9c80c1
......@@ -21,7 +21,9 @@
*/
SsuKickstarter::SsuKickstarter() {
SsuKickstarter::SsuKickstarter(QString sandbox) {
pathPrefix = sandbox;
SsuDeviceInfo deviceInfo;
deviceModel = deviceInfo.deviceModel();
......@@ -93,7 +95,9 @@ QStringList SsuKickstarter::partitions(){
QString partitionFile;
QFile part;
QDir dir(QString("%1/kickstart/part/").arg(SSU_DATA_DIR));
QDir dir(QString("/%1/%2/kickstart/part/")
.arg(pathPrefix)
.arg(SSU_DATA_DIR));
if (dir.exists(deviceModel.toLower()))
partitionFile = deviceModel.toLower();
......@@ -124,11 +128,13 @@ QStringList SsuKickstarter::scriptletSection(QString name, bool chroot){
QDir dir;
if (chroot)
path = QString("%1/kickstart/%2/")
path = QString("/%1/%2/kickstart/%3/")
.arg(pathPrefix)
.arg(SSU_DATA_DIR)
.arg(name);
else
path = QString("%1/kickstart/%2_nochroot/")
path = QString("/%1/%2/kickstart/%3_nochroot/")
.arg(pathPrefix)
.arg(SSU_DATA_DIR)
.arg(name);
......
......@@ -21,12 +21,13 @@ class Q_CORE_EXPORT SsuKickstarter: public QObject {
*/
class SsuKickstarter {
public:
SsuKickstarter();
SsuKickstarter(QString sandbox="");
void setRepoParameters(QHash<QString, QString> parameters);
bool write(QString kickstart="");
private:
QHash<QString, QString> repoOverride;
QString pathPrefix;
Ssu ssu;
bool rndMode;
QString deviceModel;
......
......@@ -11,6 +11,7 @@
#include <QLibraryInfo>
#include <QTimer>
#include <QStringList>
#include <QDirIterator>
#include "ssukickstarter.h"
#include "constants.h"
......@@ -42,16 +43,38 @@ void SsuKs::run(){
repoParameters.insert(split.at(0), split.at(1));
}
QString sandbox;
Sandbox *sb;
if (repoParameters.contains("sandbox")){
QString sandbox = repoParameters.value("sandbox");
sandbox = repoParameters.value("sandbox");
repoParameters.remove("sandbox");
sb = new Sandbox(sandbox, Sandbox::UseAsSkeleton, Sandbox::ThisProcess);
sb->addWorldFiles(SSU_BOARD_MAPPING_CONFIGURATION_DIR);
sb->addWorldFiles("/etc/ssu");
sb->addWorldFiles("/usr/share/ssu");
// work around sandbox not sandboxing directories
QDirIterator it(SSU_DATA_DIR, QDir::AllEntries|QDir::NoDot|QDir::NoDotDot, QDirIterator::Subdirectories);
while (it.hasNext()){
it.next();
if (it.fileName() == "board-mappings.ini")
continue;
QDir dir;
QFileInfo info = it.fileInfo();
dir.mkpath(sandbox + info.absoluteDir().path());
QFile::copy(it.filePath(), sandbox + it.filePath());
}
QFile::remove(sandbox + "/" + SSU_BOARD_MAPPING_CONFIGURATION);
SsuSettings boardMappings(QString("%1/%2")
.arg(sandbox)
.arg(SSU_BOARD_MAPPING_CONFIGURATION),
QString("%1/%2")
.arg(sandbox)
.arg(SSU_BOARD_MAPPING_CONFIGURATION_DIR));
sb = new Sandbox(sandbox, Sandbox::UseDirectly, Sandbox::ThisProcess);
if (sb->activate())
qout << "Using sandbox at " << sandbox << endl;
else {
......@@ -60,9 +83,9 @@ void SsuKs::run(){
}
}
SsuKickstarter *kickstarter = new SsuKickstarter();
kickstarter->setRepoParameters(repoParameters);
kickstarter->write(fileName);
SsuKickstarter kickstarter(sandbox);
kickstarter.setRepoParameters(repoParameters);
kickstarter.write(fileName);
} else
usage();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment