[machineid] Run systemd-machine-id in host, telling it to modify target
This commit is contained in:
parent
e04e0260c9
commit
2f740564c6
@ -141,9 +141,10 @@ createEntropy( const EntropyGeneration kind, const QString& rootMountPoint, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Calamares::JobResult
|
static Calamares::JobResult
|
||||||
runCmd( const QStringList& cmd )
|
runCmd( const QStringList& cmd, bool inTarget )
|
||||||
{
|
{
|
||||||
auto r = Calamares::System::instance()->targetEnvCommand( cmd );
|
auto r = inTarget ? Calamares::System::instance()->targetEnvCommand( cmd )
|
||||||
|
: Calamares::System::instance()->runCommand( cmd, std::chrono::seconds( 0 ) );
|
||||||
if ( r.getExitCode() )
|
if ( r.getExitCode() )
|
||||||
{
|
{
|
||||||
return r.explainProcess( cmd, std::chrono::seconds( 0 ) );
|
return r.explainProcess( cmd, std::chrono::seconds( 0 ) );
|
||||||
@ -153,16 +154,14 @@ runCmd( const QStringList& cmd )
|
|||||||
}
|
}
|
||||||
|
|
||||||
Calamares::JobResult
|
Calamares::JobResult
|
||||||
createSystemdMachineId( SystemdMachineIdStyle style, const QString& rootMountPoint, const QString& fileName )
|
createSystemdMachineId( SystemdMachineIdStyle style, const QString& rootMountPoint, const QString& machineIdFile )
|
||||||
{
|
{
|
||||||
Q_UNUSED( rootMountPoint )
|
|
||||||
Q_UNUSED( fileName )
|
|
||||||
const QString machineIdFile = QStringLiteral( "/etc/machine-id" );
|
|
||||||
|
|
||||||
switch ( style )
|
switch ( style )
|
||||||
{
|
{
|
||||||
case SystemdMachineIdStyle::Uuid:
|
case SystemdMachineIdStyle::Uuid:
|
||||||
return runCmd( QStringList { QStringLiteral( "systemd-machine-id-setup" ) } );
|
return runCmd(
|
||||||
|
QStringList { QStringLiteral( "systemd-machine-id-setup" ), QStringLiteral( "--root=" ) + rootMountPoint },
|
||||||
|
false );
|
||||||
case SystemdMachineIdStyle::Blank:
|
case SystemdMachineIdStyle::Blank:
|
||||||
Calamares::System::instance()->createTargetFile(
|
Calamares::System::instance()->createTargetFile(
|
||||||
machineIdFile, QByteArray(), Calamares::System::WriteMode::Overwrite );
|
machineIdFile, QByteArray(), Calamares::System::WriteMode::Overwrite );
|
||||||
@ -182,14 +181,14 @@ createDBusMachineId( const QString& rootMountPoint, const QString& fileName )
|
|||||||
{
|
{
|
||||||
Q_UNUSED( rootMountPoint )
|
Q_UNUSED( rootMountPoint )
|
||||||
Q_UNUSED( fileName )
|
Q_UNUSED( fileName )
|
||||||
return runCmd( QStringList { QStringLiteral( "dbus-uuidgen" ), QStringLiteral( "--ensure" ) } );
|
return runCmd( QStringList { QStringLiteral( "dbus-uuidgen" ), QStringLiteral( "--ensure" ) }, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
Calamares::JobResult
|
Calamares::JobResult
|
||||||
createDBusLink( const QString& rootMountPoint, const QString& fileName, const QString& systemdFileName )
|
createDBusLink( const QString& rootMountPoint, const QString& fileName, const QString& systemdFileName )
|
||||||
{
|
{
|
||||||
Q_UNUSED( rootMountPoint )
|
Q_UNUSED( rootMountPoint )
|
||||||
return runCmd( QStringList { QStringLiteral( "ln" ), QStringLiteral( "-sf" ), systemdFileName, fileName } );
|
return runCmd( QStringList { QStringLiteral( "ln" ), QStringLiteral( "-sf" ), systemdFileName, fileName }, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace MachineId
|
} // namespace MachineId
|
||||||
|
Loading…
Reference in New Issue
Block a user