If dont-chroot is set, don't chroot target env calls.

main
Teo Mrnjavac 9 years ago
parent 2c9524aebd
commit 2e3751ffa7

@ -99,24 +99,37 @@ targetEnvOutput( const QStringList& args,
return -3; return -3;
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
if ( !gs || !gs->contains( "rootMountPoint" ) ) if ( !gs ||
( doChroot && !gs->contains( "rootMountPoint" ) ) )
{ {
cLog() << "No rootMountPoint in global storage"; cLog() << "No rootMountPoint in global storage";
return -3; return -3;
} }
QString destDir = gs->value( "rootMountPoint" ).toString(); QProcess process;
if ( !QDir( destDir ).exists() ) QString program;
QStringList arguments;
if ( doChroot )
{ {
cLog() << "rootMountPoint points to a dir which does not exist"; QString destDir = gs->value( "rootMountPoint" ).toString();
return -3; if ( !QDir( destDir ).exists() )
} {
cLog() << "rootMountPoint points to a dir which does not exist";
return -3;
}
QString program( "chroot" ); program = "chroot";
QStringList arguments = { destDir }; arguments = QStringList( { destDir } );
arguments << args; arguments << args;
}
else
{
program = "sh";
arguments = QStringList( { "-c" } );
arguments << args;
}
QProcess process;
process.setProgram( program ); process.setProgram( program );
process.setArguments( arguments ); process.setArguments( arguments );
process.setProcessChannelMode( QProcess::MergedChannels ); process.setProcessChannelMode( QProcess::MergedChannels );

@ -24,6 +24,8 @@
namespace CalamaresUtils namespace CalamaresUtils
{ {
static bool doChroot = true;
/** /**
* Runs the mount utility with the specified parameters. * Runs the mount utility with the specified parameters.
* @returns the program's exit code, or: * @returns the program's exit code, or:

@ -19,6 +19,7 @@
#include "Settings.h" #include "Settings.h"
#include "utils/CalamaresUtils.h" #include "utils/CalamaresUtils.h"
#include "utils/CalamaresUtilsSystem.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/YamlUtils.h" #include "utils/YamlUtils.h"
@ -95,6 +96,9 @@ Settings::Settings( const QString& settingsFilePath,
m_brandingComponentName = QString::fromStdString( config[ "branding" ] m_brandingComponentName = QString::fromStdString( config[ "branding" ]
.as< std::string >() ); .as< std::string >() );
m_promptInstall = config[ "prompt-install" ].as< bool >(); m_promptInstall = config[ "prompt-install" ].as< bool >();
bool doChroot = !config[ "dont-chroot" ].as< bool >();
CalamaresUtils::doChroot = doChroot;
} }
catch ( YAML::Exception& e ) catch ( YAML::Exception& e )
{ {

Loading…
Cancel
Save