[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;
|
args << "-o" << options;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto r = CalamaresUtils::System::instance()->runCommand(
|
auto r = CalamaresUtils::System::instance()->runCommand( args, 10 );
|
||||||
CalamaresUtils::System::RunLocation::RunInHost, args, QString(), QString(), 10 );
|
|
||||||
sync();
|
sync();
|
||||||
return r.getExitCode();
|
return r.getExitCode();
|
||||||
}
|
}
|
||||||
|
@ -23,14 +23,7 @@
|
|||||||
|
|
||||||
void CalamaresUtils::Partition::sync()
|
void CalamaresUtils::Partition::sync()
|
||||||
{
|
{
|
||||||
auto* s = CalamaresUtils::System::instance();
|
auto r = CalamaresUtils::System::runCommand( { "/sbin/udevadm", "settle" }, 10 );
|
||||||
|
|
||||||
auto r = s->runCommand( CalamaresUtils::System::RunLocation::RunInHost,
|
|
||||||
{ "/sbin/udevadm", "settle" },
|
|
||||||
QString(),
|
|
||||||
QString(),
|
|
||||||
10 // timeout seconds
|
|
||||||
);
|
|
||||||
|
|
||||||
if ( r.getExitCode() != 0 )
|
if ( r.getExitCode() != 0 )
|
||||||
{
|
{
|
||||||
@ -38,10 +31,5 @@ void CalamaresUtils::Partition::sync()
|
|||||||
r.explainProcess( "udevadm", 10 );
|
r.explainProcess( "udevadm", 10 );
|
||||||
}
|
}
|
||||||
|
|
||||||
s->runCommand( CalamaresUtils::System::RunLocation::RunInHost,
|
CalamaresUtils::System::runCommand( { "/bin/sync" }, 10 );
|
||||||
{ "/bin/sync" },
|
|
||||||
QString(),
|
|
||||||
QString(),
|
|
||||||
10 // timeout seconds
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -123,6 +123,18 @@ public:
|
|||||||
const QString& stdInput = QString(),
|
const QString& stdInput = QString(),
|
||||||
int timeoutSec = 0 );
|
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().
|
/** @brief Convenience wrapper for runCommand().
|
||||||
* Runs the command in the location specified through the boolean
|
* Runs the command in the location specified through the boolean
|
||||||
* doChroot(), which is what you usually want for running commands
|
* doChroot(), which is what you usually want for running commands
|
||||||
|
Loading…
Reference in New Issue
Block a user