[libcalamares] Provide overload of runCommand()
- Most of the time the working dir and stdin are not important, you just want to run a command in the host, so simplify that by providing a suitable overload. - Use that overload from the partition service (for mount and sync).
This commit is contained in:
parent
93eb712824
commit
add90e873b
@ -69,8 +69,7 @@ mount( const QString& devicePath, const QString& mountPoint, const QString& file
|
||||
args << "-o" << options;
|
||||
}
|
||||
|
||||
auto r = CalamaresUtils::System::instance()->runCommand(
|
||||
CalamaresUtils::System::RunLocation::RunInHost, args, QString(), QString(), 10 );
|
||||
auto r = CalamaresUtils::System::instance()->runCommand( args, 10 );
|
||||
sync();
|
||||
return r.getExitCode();
|
||||
}
|
||||
|
@ -23,14 +23,7 @@
|
||||
|
||||
void CalamaresUtils::Partition::sync()
|
||||
{
|
||||
auto* s = CalamaresUtils::System::instance();
|
||||
|
||||
auto r = s->runCommand( CalamaresUtils::System::RunLocation::RunInHost,
|
||||
{ "/sbin/udevadm", "settle" },
|
||||
QString(),
|
||||
QString(),
|
||||
10 // timeout seconds
|
||||
);
|
||||
auto r = CalamaresUtils::System::runCommand( { "/sbin/udevadm", "settle" }, 10 );
|
||||
|
||||
if ( r.getExitCode() != 0 )
|
||||
{
|
||||
@ -38,10 +31,5 @@ void CalamaresUtils::Partition::sync()
|
||||
r.explainProcess( "udevadm", 10 );
|
||||
}
|
||||
|
||||
s->runCommand( CalamaresUtils::System::RunLocation::RunInHost,
|
||||
{ "/bin/sync" },
|
||||
QString(),
|
||||
QString(),
|
||||
10 // timeout seconds
|
||||
);
|
||||
CalamaresUtils::System::runCommand( { "/bin/sync" }, 10 );
|
||||
}
|
||||
|
@ -123,6 +123,18 @@ public:
|
||||
const QString& stdInput = QString(),
|
||||
int timeoutSec = 0 );
|
||||
|
||||
/** @brief Convenience wrapper for runCommand()
|
||||
*
|
||||
* Runs the given command-line @p args in the host in the current direcory
|
||||
* with no input, and the given @p timeoutSec for completion.
|
||||
*/
|
||||
static inline ProcessResult runCommand(
|
||||
const QStringList& args,
|
||||
int timeoutSec )
|
||||
{
|
||||
return runCommand( RunLocation::RunInHost, args, QString(), QString(), timeoutSec );
|
||||
}
|
||||
|
||||
/** @brief Convenience wrapper for runCommand().
|
||||
* Runs the command in the location specified through the boolean
|
||||
* doChroot(), which is what you usually want for running commands
|
||||
|
Loading…
Reference in New Issue
Block a user