Compare commits
9 Commits
translatio
...
issue-2225
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b37eb1262 | ||
|
|
89348910c3 | ||
|
|
2f740564c6 | ||
|
|
e04e0260c9 | ||
|
|
e5ee28329d | ||
|
|
0eb387d6de | ||
|
|
0d11de4525 | ||
|
|
44d12379bd | ||
|
|
083b0fb1e5 |
@@ -76,7 +76,7 @@ public:
|
|||||||
* Pass in a suitable error code; using 0 (which would normally mean "ok") instead
|
* Pass in a suitable error code; using 0 (which would normally mean "ok") instead
|
||||||
* gives you a GenericError code.
|
* gives you a GenericError code.
|
||||||
*/
|
*/
|
||||||
static JobResult internalError( const QString&, const QString& details, int errorCode );
|
static JobResult internalError( const QString& message, const QString& details, int errorCode );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit JobResult( const QString& message, const QString& details, int errorCode );
|
explicit JobResult( const QString& message, const QString& details, int errorCode );
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "Workers.h"
|
#include "Workers.h"
|
||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/NamedEnum.h"
|
||||||
#include "utils/System.h"
|
#include "utils/System.h"
|
||||||
#include "utils/Variant.h"
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
@@ -22,6 +23,25 @@
|
|||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
|
const NamedEnumTable< MachineId::SystemdMachineIdStyle >&
|
||||||
|
styleNames()
|
||||||
|
{
|
||||||
|
using T = MachineId::SystemdMachineIdStyle;
|
||||||
|
// *INDENT-OFF*
|
||||||
|
// clang-format off
|
||||||
|
static const NamedEnumTable< MachineId::SystemdMachineIdStyle > names {
|
||||||
|
{ QStringLiteral( "none" ), T::Blank },
|
||||||
|
{ QStringLiteral( "blank" ), T::Blank },
|
||||||
|
{ QStringLiteral( "uuid" ), T::Uuid },
|
||||||
|
{ QStringLiteral( "systemd" ), T::Uuid },
|
||||||
|
{ QStringLiteral( "literal-uninitialized" ), T::Uninitialized },
|
||||||
|
};
|
||||||
|
// clang-format on
|
||||||
|
// *INDENT-ON*
|
||||||
|
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
MachineIdJob::MachineIdJob( QObject* parent )
|
MachineIdJob::MachineIdJob( QObject* parent )
|
||||||
: Calamares::CppJob( parent )
|
: Calamares::CppJob( parent )
|
||||||
{
|
{
|
||||||
@@ -96,7 +116,7 @@ MachineIdJob::exec()
|
|||||||
{
|
{
|
||||||
cWarning() << "Could not create systemd data-directory.";
|
cWarning() << "Could not create systemd data-directory.";
|
||||||
}
|
}
|
||||||
auto r = MachineId::createSystemdMachineId( root, target_systemd_machineid_file );
|
auto r = MachineId::createSystemdMachineId( m_systemd_style, root, target_systemd_machineid_file );
|
||||||
if ( !r )
|
if ( !r )
|
||||||
{
|
{
|
||||||
return r;
|
return r;
|
||||||
@@ -134,6 +154,12 @@ MachineIdJob::setConfigurationMap( const QVariantMap& map )
|
|||||||
{
|
{
|
||||||
m_systemd = Calamares::getBool( map, "systemd", false );
|
m_systemd = Calamares::getBool( map, "systemd", false );
|
||||||
|
|
||||||
|
const auto style = Calamares::getString( map, "systemd-style", QString() );
|
||||||
|
if ( !style.isEmpty() )
|
||||||
|
{
|
||||||
|
m_systemd_style = styleNames().find( style, MachineId::SystemdMachineIdStyle::Uuid );
|
||||||
|
}
|
||||||
|
|
||||||
m_dbus = Calamares::getBool( map, "dbus", false );
|
m_dbus = Calamares::getBool( map, "dbus", false );
|
||||||
if ( map.contains( "dbus-symlink" ) )
|
if ( map.contains( "dbus-symlink" ) )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,16 +10,16 @@
|
|||||||
#ifndef MACHINEIDJOB_H
|
#ifndef MACHINEIDJOB_H
|
||||||
#define MACHINEIDJOB_H
|
#define MACHINEIDJOB_H
|
||||||
|
|
||||||
|
#include "Workers.h"
|
||||||
|
|
||||||
|
#include "CppJob.h"
|
||||||
|
#include "DllMacro.h"
|
||||||
|
#include "utils/PluginFactory.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
|
||||||
#include "CppJob.h"
|
|
||||||
|
|
||||||
#include "utils/PluginFactory.h"
|
|
||||||
|
|
||||||
#include "DllMacro.h"
|
|
||||||
|
|
||||||
/** @brief Write 'random' data: machine id, entropy, UUIDs
|
/** @brief Write 'random' data: machine id, entropy, UUIDs
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -48,6 +48,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool m_systemd = false; ///< write systemd's files
|
bool m_systemd = false; ///< write systemd's files
|
||||||
|
|
||||||
|
MachineId::SystemdMachineIdStyle m_systemd_style = MachineId::SystemdMachineIdStyle::Uuid;
|
||||||
|
|
||||||
bool m_dbus = false; ///< write dbus files
|
bool m_dbus = false; ///< write dbus files
|
||||||
bool m_dbus_symlink = false; ///< .. or just symlink to systemd
|
bool m_dbus_symlink = false; ///< .. or just symlink to systemd
|
||||||
|
|
||||||
|
|||||||
@@ -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,11 +154,26 @@ runCmd( const QStringList& cmd )
|
|||||||
}
|
}
|
||||||
|
|
||||||
Calamares::JobResult
|
Calamares::JobResult
|
||||||
createSystemdMachineId( const QString& rootMountPoint, const QString& fileName )
|
createSystemdMachineId( SystemdMachineIdStyle style, const QString& rootMountPoint, const QString& machineIdFile )
|
||||||
{
|
{
|
||||||
Q_UNUSED( rootMountPoint )
|
switch ( style )
|
||||||
Q_UNUSED( fileName )
|
{
|
||||||
return runCmd( QStringList { QStringLiteral( "systemd-machine-id-setup" ) } );
|
case SystemdMachineIdStyle::Uuid:
|
||||||
|
return runCmd(
|
||||||
|
QStringList { QStringLiteral( "systemd-machine-id-setup" ), QStringLiteral( "--root=" ) + rootMountPoint },
|
||||||
|
false );
|
||||||
|
case SystemdMachineIdStyle::Blank:
|
||||||
|
Calamares::System::instance()->createTargetFile(
|
||||||
|
machineIdFile, QByteArray(), Calamares::System::WriteMode::Overwrite );
|
||||||
|
return Calamares::JobResult::ok();
|
||||||
|
case SystemdMachineIdStyle::Uninitialized:
|
||||||
|
Calamares::System::instance()->createTargetFile(
|
||||||
|
machineIdFile, "uninitialized\n", Calamares::System::WriteMode::Overwrite );
|
||||||
|
return Calamares::JobResult::ok();
|
||||||
|
}
|
||||||
|
return Calamares::JobResult::internalError( QStringLiteral( "Invalid systemd-style" ),
|
||||||
|
QStringLiteral( "Invalid value %1" ).arg( int( style ) ),
|
||||||
|
Calamares::JobResult::InvalidConfiguration );
|
||||||
}
|
}
|
||||||
|
|
||||||
Calamares::JobResult
|
Calamares::JobResult
|
||||||
@@ -165,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
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ createEntropy( const EntropyGeneration kind, const QString& rootMountPoint, cons
|
|||||||
* Creating UUIDs for DBUS and SystemD.
|
* Creating UUIDs for DBUS and SystemD.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/// @brief Create a new DBus UUID file
|
/// @brief Create a new DBus UUID file
|
||||||
Calamares::JobResult createDBusMachineId( const QString& rootMountPoint, const QString& fileName );
|
Calamares::JobResult createDBusMachineId( const QString& rootMountPoint, const QString& fileName );
|
||||||
|
|
||||||
@@ -59,7 +60,15 @@ Calamares::JobResult createDBusMachineId( const QString& rootMountPoint, const Q
|
|||||||
Calamares::JobResult
|
Calamares::JobResult
|
||||||
createDBusLink( const QString& rootMountPoint, const QString& fileName, const QString& systemdFileName );
|
createDBusLink( const QString& rootMountPoint, const QString& fileName, const QString& systemdFileName );
|
||||||
|
|
||||||
Calamares::JobResult createSystemdMachineId( const QString& rootMountPoint, const QString& fileName );
|
enum class SystemdMachineIdStyle
|
||||||
|
{
|
||||||
|
Uuid,
|
||||||
|
Blank,
|
||||||
|
Uninitialized
|
||||||
|
};
|
||||||
|
|
||||||
|
Calamares::JobResult
|
||||||
|
createSystemdMachineId( SystemdMachineIdStyle style, const QString& rootMountPoint, const QString& fileName );
|
||||||
|
|
||||||
|
|
||||||
} // namespace MachineId
|
} // namespace MachineId
|
||||||
|
|||||||
@@ -13,6 +13,13 @@
|
|||||||
# Whether to create /etc/machine-id for systemd.
|
# Whether to create /etc/machine-id for systemd.
|
||||||
# The default is *false*.
|
# The default is *false*.
|
||||||
systemd: true
|
systemd: true
|
||||||
|
# If systemd is true, the kind of /etc/machine-id to create in the target
|
||||||
|
# - uuid (default) generates a UUID
|
||||||
|
# - systemd alias of uuid
|
||||||
|
# - blank creates the file but leaves it empty at 0 bytes
|
||||||
|
# - none alias of blank (use `systemd: false` if you don't want one at all)
|
||||||
|
# - literal-uninitialized creates the file and writes the string "uninitialized\n"
|
||||||
|
systemd-style: uuid
|
||||||
|
|
||||||
# Whether to create /var/lib/dbus/machine-id for D-Bus.
|
# Whether to create /var/lib/dbus/machine-id for D-Bus.
|
||||||
# The default is *false*.
|
# The default is *false*.
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ additionalProperties: false
|
|||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
systemd: { type: boolean, default: false }
|
systemd: { type: boolean, default: false }
|
||||||
|
"systemd-style": { type: string, enum: [ uuid, blank, literal-uninitialized ] }
|
||||||
dbus: { type: boolean, default: false }
|
dbus: { type: boolean, default: false }
|
||||||
"dbus-symlink": { type: boolean, default: false }
|
"dbus-symlink": { type: boolean, default: false }
|
||||||
"entropy-copy": { type: boolean, default: false }
|
"entropy-copy": { type: boolean, default: false }
|
||||||
|
|||||||
Reference in New Issue
Block a user